This time I have a scripting question. I doubt I am the first one doing this, but a I could not find a good search tag to get a reasonable number of results here. So I just go to ask straight.
For a script I want to determine from the available objects in my document, the 3d objects or anything that has faces, really. My focus is on Part and PartDesign objects, but I would rather include anything that is suitable by this criterium.
First I get all possible objects by doing
Code: Select all
doc_obj_list = App.ActiveDocument.Objects
Code: Select all
doc_obj_list = [<Part::PartFeature>, <PartDesign::Pad>, <PartDesign::Pocket>]
Code: Select all
part0 = doc_obj_list[0]
type(part0)
>>> <class 'Part.Feature'>
isinstance(part0, Part.Feature)
>>> True
Code: Select all
obp = App.ActiveDocument.Pad
isinstance(obp, PartDesign.Feature)
Traceback (most recent call last):
File "<input>", line 1, in <module>
AttributeError: module 'PartDesign' has no attribute 'Feature'
Code: Select all
suitable_features = ['PartDesign::Pad', 'PartDesign::Pocket', 'Part::PartFeature']
feat_name_list = [item.Label for item in doc_object_list if '{}'.format(item.TypeId) in suitable_features]
What is a consistent general approach on filtering these objects to my needs? Maybe I am doing a stupid thing at some point?
Happy for any help!