Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations IDS on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Get the Part Name after Selection in Assembly 1

Status
Not open for further replies.

Pitar1

Mechanical
May 14, 2021
4
Hello,
I am currently working on a piece of code in which I use the BlockUI Styler in assembly.
I select two faces from two different parts to get and save the distance between the two faces.
I would now like to receive the names of the parts which belong to the selected faces.
Does anyone here have an idea.
Thanks for your help

Public Function apply_cb() As Integer
Dim errorCode As Integer = 0
Try

'---- Enter your callback code here -----
Dim theUfSession As UFSession = UFSession.GetUFSession()
Dim workpart As Part = theSession.Parts.Work
Dim lw As ListingWindow = theSession.ListingWindow
lw.Open()

Dim Select0Props As PropertyList = face_select0.GetProperties()
Dim faces0() As TaggedObject = Select0Props.GetTaggedObjectVector("SelectedObjects")
Select0Props.Dispose()
Select0Props = Nothing

Dim Select01Props As PropertyList = face_select01.GetProperties()
Dim faces01() As TaggedObject = Select01Props.GetTaggedObjectVector("SelectedObjects")
Select01Props.Dispose()
Select01Props = Nothing

For Each face0 As Face In faces0

For Each face01 As Face In faces01

'lw.WriteLine(face0.ToString)
'lw.WriteLine(face01.ToString)
'--> this does not work
'I need the name of the feature or the name of the Part

Dim guess1(2) As Double
Dim guess2(2) As Double
Dim pt1(2) As Double
Dim pt2(2) As Double
Dim minDist As Double
theUfSession.Modl.AskMinimumDist(face0.Tag, face01.Tag, 0, guess1, 0, guess2, minDist, pt1, pt2)
Next
Next


Catch ex As Exception

'---- Enter your exception handling code here -----
errorCode = 1
theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString)
End Try
apply_cb = errorCode
End Function
 
Replies continue below

Recommended for you

It sounds like you are working in an assembly context. Do you want the name of the component part file (the path to the part) or do you want the component display name? One of the below should work.

Code:
{face variable}.OwningComponent.DisplayName
{face variable}.OwningComponent.Prototype.OwningPart.FullPath or .Leaf

www.nxjournaling.com
 
Super works perfectly.
Thank you very much
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor