I am trying to generate a Sketch from a body or a part. If I record a macro of my work, FreeCAD gives me this:
### Begin command PartDesign_NewSketch
Gui.getDocument('my_doc_name').ActiveView.setActiveObject('pdbody',App.getDocument('my_doc_name').getObject('my_part_name'),'my_body_name.')
### End command PartDesign_NewSketch
# Gui.Selection.clearSelection()
# Gui.Selection.addSelection('my_doc_name','my_part_name','my_body_name.Origin008.XZ_Plane008.')
App.getDocument('my_doc_name').getObject('my_body_name').newObject('Sketcher::SketchObject','Sketch')
App.getDocument('my_doc_name').getObject('my_sketch_name').Support = (App.getDocument('my_doc_name').getObject('XZ_Plane008'),[''])
App.getDocument('my_doc_name').getObject('my_sketch_name').MapMode = 'FlatFace'
App.ActiveDocument.recompute()
My goal is to reproduce the following above commands in my Python script. The issue is that when I created my Body or Part, I didn't (yet) knew what will be the names of the Origin, Axis or Planes. Here in my example, we can see that it is Origin008 and one of the plane is XZ_Plane008
So my question is, how can I have a getListOfPlanes method like, or something like:
for plane in self.freecad_document.getObject(body_name).getListOfPlanes():
print(plane.name)
Output would be like:
XY_Plane008
XZ_Plane008
YZ_Plane008
Notice that when I generate my 3D structure, I could need either the XY, XZ or YZ plane. This is why I would require the list of planes available and select the best one that fits my needs.
I also try to do some reverse engineering with some dir and __dict__ but I didn't find any attribute value that have a *008* name. The wikidoc documentation did not help me either.
Any idea?
Using
- FreeCAD 0.20.2 (2022/12/07)
- Python 3.11.5 (2023/08/24)

I wrote the answer here: https://forum.freecad.org/viewtopic.php?p=710380#p710380
In short:
Be careful:
Using
__dict__to debug or search for a value does NOT work. For instance:Produces the following output:
As you can see, the
__dict__do NOT print the real value of Label, andNameattribute is not even shown. So do not use__dict__for debug.