Skip to main content
1-Visitor
December 20, 2019
Question

Access feature ID

  • December 20, 2019
  • 2 replies
  • 1417 views

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!!

2 replies

17-Peridot
December 20, 2019

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! 

17-Peridot
December 20, 2019

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:

  • file - name of model
  • seq_path - bom structure path
  • path [array of component ids]

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