Currently I am trying to retrieve data on some welds which I can then output to a text file. Currently I allow the user to select which welds to use by using this:
If SelectObjects("Select Weld Objects", _
mySelectedObjects) = Selection.Response.Ok Then
I then process each selected element with the following:
For Each Obj As NXObject in mySelectedObjects
Next
I can retrieve various properties with something similar to:
x_pos = Obj.getRealAttribute("X_Pos")
Problem:
Now where I am having a problem is trying to find the file / part that the selected point belongs to. There is no attribute that lists the part. I do not know if there is a property for Obj to reference but I have tried things like Obj.Owner, Obj.Part, etc...
Obj.owningpart.fullpath sort of works but only if the owning weld file is selected. If I select the welds from an assembly then it will simply display that assembly which is not correct.
Is there an easy way to get the part that my selected point belongs to?
re: weld point part
If you are working in the context of an assembly file, each component object is referred to as an "occurrence". You can check to see if the object is an occurrence with the .IsOccurrence property. If it is an occurrence, you can use the .OwningComponent property to find the component that contains the weld. If it is not an occurrence, you can use the .OwningPart property to report the part that owns the weld.
Something like this:
if myWeld.IsOccurrence then
lw.writeline("owning component: " & myWeld.OwningComponent.DisplayName)
lw.writeline("component part file: " & myWeld.prototype.OwningPart.FullPath)
else
lw.writeline("owning part: " & myWeld.OwningPart.FullPath
end if
Awesome that works! Thank you
Awesome that works! Thank you very much!