Solved! Go to Solution.
Tags of objects are not guaranteed to have the same values from session to session. In other words, you cannot depend on the tag value to point to the same object once you close and reopen the part.
You could give the objects custom names or attributes, then look for the names/attributes on subsequent runs of the code. Alternately, you could use the object ID rather than the tag value; but searching through all the objects for a particular ID may be a bit tricky...
- There are "handles" (which supposedly persist across sessions, but I've never used them)
- As already mentioned - use a unique naming/attributing scheme
- Use "user defined objects" (UDOs) - you can store links to other objects (pass in a tag?) but those links are "persistant" (they will last across sessions). In addition you can specify behavior (e.g. "what happens to the UDO if the other object is deleted?")
Note the UDO can store store more than 1 tag, it can store other data (strings/integers/floating point numbers, etc.) It can show up as a feature in the Part Navigator (or not) depending on what you need. It can also trigger your own "edit" dialog (I believe only if a feature)
Production: NX10.0.3.5 MP16/TC11.2
I'd rather be e-steamed than e-diseaseled
If have used the handles mentioned by Ken to externally store and restore references to objects in a xml file across sessions (UF_TAG_ask_handle_from_tag, UF_TAG_ask_tag_of_handle) without any problems.
Those handles are simple strings so you can store them in an attribute just as well.