Hello.
I want to have a track of the numbers of surfaces by using python scripting.
For example, if I have a cube then I will have 6 surfaces or if I have a cylinder then I will have 3 surfaces.
Do you have any idea of how I can calculate the number of surfaces in a model ?
Thank you.
tracking number of surface in python scripting.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Be nice to others! Respect the FreeCAD code of conduct!
-
- Posts: 23
- Joined: Thu Nov 18, 2021 2:41 pm
Re: tracking number of surface in python scripting.
You can copy / paste this in the python console :
Code: Select all
total = 0
for obj in App.activeDocument().Objects:
if hasattr(obj, "Shape"):
print(f"Object {obj.Label} has {len(obj.Shape.Faces)} faces")
total += len(obj.Shape.Faces)
print(f"Document has a total of {total} faces")