FreeCAD: How to calculate a volume, surface area and gravity center of a shape?

FreeCAD 0.19
  1. Select [View]-[Panels]-[Python console] from the menu to display the "Python console". We will enter commands into this "Python console".

  2. First, we need to get the object we want to measure. You can use the following command to get it by the name displayed in the model tree (= label).

    target_object=App.ActiveDocument.getObjectsByLabel("The object label")[0]

    Fig. The object label
    The object label
  3. Then execute the following commands to display the each values in the "Python console".

    • If you want to get the surface area:


    • If you want to get the volume:


    • If you want to get the center of mass:


  4. Note: if the ShapeType of the shape is "Compound", the center of mass cannot be gotten in this way. To check the ShapeType of a shape, execute the following command.


    In the case of "Compound", you can use Shape.Solids to get the center of mass of the shape's component solids.


Fig. Python console
Python console