API: Re-Attaching to entities created programatically.

A question on methods for doing this. The situation.

You create a program or macro to help in some of the more cumbersome detailing tasks say unconventional or custom ballooning. Is there a way to flag items added by a program so they can be found the next time the program is run. I have used Naming in the past but feel it is lacking. I know that with AutoCAD you can add Extended data to an object that allows you to attach your program name and custom properties. What have you found to be the best way? If you do use naming conventions as I have what logic do you use in the name of the object.


Reply to
Loading thread data ...

Seems to me that in the API part of Support there is some discussion of saving user data with parts and features.

Reply to

This is the type of situation that Persistent References is intended to address. While the SelectByID is name-based, it is really finicky about case-sensitivity and changes to the instance #. I've noticed that SW2004 and later sometimes re-numbers the instances when some of the instances are deleted or suppressed. This messes up the SelectByID call. The API Help file includes an example of getting Persistent Refs and then using them to gain access to those objects in a later SW Session. One limitation of the Persistent Refs is that they seem to change if a document is copied and re-named.

On another tact, you can programatically define and add "Attributes" to individual entities and features. They can then be traversed and read programatically. This is probably closest to what you were describing as "Extended data" that you can customize for individual features. One caveat to using Attributes is that SW has a policy of controlling the

3-letter pre-fix used in the Attribute name. Anyone can use "pub" (for public) as a prefix, but if you distribute your program to others, you should request your own unique prefix from SW. The reason for this is to avoid the nasty situation of 3rd party products over-writing each other's attributes. This could be a very confusing situation to troubleshoot since attributes are often stored invisible to the user.

Hope this gives you a few more alternatives to consider.

Best regards, Brenda CustomSolids

CS wrote:

Reply to

PolyTech Forum website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.