Using Outlist Recursive

Need help, or want to share a macro? Post here!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
User avatar
JoshM
Posts: 456
Joined: Thu Oct 05, 2017 5:34 pm
Location: New Hampshire

Using Outlist Recursive

Post by JoshM »

I have a question about matching a selected face to a parent primitive shape, using Python. In this case, I was testing a Cone object using the python console--but my question is more general for Cone, Plane, Cylinder, Sphere, BSpline,Toroid, etc...

Code: Select all

OperationSelectedGeometry=Gui.Selection.getSelectionEx()[0].Object
>>> myOpSel=Gui.Selection.getSelectionEx()[0].SubObjects
>>> sel = myOpSel[0]
>>> sel.TypeId
'Part::TopoShape'
>>> OperationSelectedGeometry.TypeId
'Part::Cone'
>>> OperationSelectedGeometry=Gui.Selection.getSelectionEx()[0].Object
>>> myOpSel=Gui.Selection.getSelectionEx()[0].SubObjects
>>> sel = myOpSel[0]
>>> OperationSelectedGeometry.TypeId
'Part::MultiFuse'
>>> OperationSelectedGeometry.OutListRecursive
[<Part::PartFeature>, <Part::PartFeature>, <Part::PartFeature>, <Part::PartFeature>, <Part::PartFeature>, <Part::PartFeature>, <Part::PartFeature>, <Part::PartFeature>]
>>> 
I can then use a for loop to iterate through the parent geometry to find the cone that was used to build a fusion, cut, etc...

How do I distinguish the cone parent to the selected face? Is there a way to directly link a Face back to the primitive used in its creation?

Thanks,
Josh


OS: Windows 10
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.17.13488 (Git)
Build type: Release
Branch: master
Hash: 2891173923bcecaace64e0544f5773facbdef436
Python version: 2.7.14
Qt version: 4.8.7
Coin version: 4.0.0a
OCC version: 7.1.0
Locale: English/UnitedStates (en_US)
User avatar
DeepSOIC
Veteran
Posts: 7896
Joined: Fri Aug 29, 2014 12:45 am
Location: used to be Saint-Petersburg, Russia

Re: Using Outlist Recursive

Post by DeepSOIC »

JoshM wrote: Mon Apr 09, 2018 8:15 pm Is there a way to directly link a Face back to the primitive used in its creation?
There is no interface for that, sorry. There is an experimental implementation, realthunder's topological naming. I haven't looked into it very much, but I think it must be possible to extract this face-to-face relations.
User avatar
JoshM
Posts: 456
Joined: Thu Oct 05, 2017 5:34 pm
Location: New Hampshire

Re: Using Outlist Recursive

Post by JoshM »

Thanks for your response DeepSOIC.
-Josh
Post Reply