Can some body let me know, how to select an object through code.
I have the objects Tag. through which i can get the the NXObject from NXOpen.Utilities.NXObjectManager.Get method.
But how to select it programmatically.
try this python code. You can run it in the journal. Then you can typically select your object via myclass.somemethod(list_of_objects[0 to some integer])
I'm still not sure how to select a body or feature without using the journal identifier attribute
workPart = theSession.Parts.BaseWork
bodies = workPart.Bodies
#or features= workPart.Features
for body in bodies: theLw.Open() theLw.WriteLine("Body name is " + body.JournalIdentifier) list_of_objects.append(body.JournalIdentifier)
I guess I'm unclear what you mean by "select an object by code"
1) Have dialog come up & users selects something in your program?
2) You want to be able to find (without user interaction) an object of arbitrary type?
For (1) there are some selection objects for Block Styler dialogs, that you can (if appropriate) apply filters to to select objects of certain types.
For (2) you have to cycle thru all objects in the part (or cycle by type for cycle by .... - there are several options).
If you are going to do this alot, it helps if you use names or attributes to filter your selection. If other programs create these objects, you might want to have them name/attribute the objects they create, to make finding them later easier. Same for part families - e.g. name the faces/edges likely to be used for assembly contraints, then they'll be easier to find when you try to create a constraint.
Hope this helps...
Production: NX10.0.3.5 MP16/TC11.2
I'd rather be e-steamed than e-diseaseled
Instead of using the old UF wrappers for the cycling functions, you can also use the object collections, which avoid having to convert between tags and objects.
In addition using the object it is much easier to check if it has an attribute applied using the HasUserAttribute method with AttributeType.Any
Development: VB.NET, Tcl/Tk Testing: NX12.0 Preparing: NX12.0
Employees of the customers, together we are strong
How to Get the Most from Your Signature in the Community
NX Customization - Best Practice Guide