Community Tip - New to the community? Learn how to post a question and get help from PTC and industry experts! X
Hey everybody,
is there a way to access the feature ID from a part or assembly programmatically? I know that it is possible to get the feature ID via the selection option but can I archive the same without user input? Is it possible to generate a list of all parts of an assembly which contain said ID?
Any help is greatly appreciated!!
Hello!
Try it like this:
Session session = pfcSession.GetCurrentSession ();
Model model = session.GetCurrentModel ();
Solid solid = (Solid)model;
Features Feats = solid.ListFeaturesByType(Boolean.TRUE, FeatureType.FEATTYPE_COMPONENT);
Feats.get(component number in your part or assembly).GetId()
Regards!
Many ways to get there - depends on the language you are using.
In CREOSON - you can simply request (from any programming/scripting language):
-->> bom : get_paths (paths = true)
This will return all the children of your assembly and will include:
from then it is just a matter of filtering the results for what you are looking for and what you want to do with the information. (a simple filter function or for loop would do the trick)
Hope that helps/inspires.
Dave