Measure Area, Volume & Center of Mass with Python Script

Header image freecad

Hello friends welcome to FreeCAD tutorial in this tutorial we will learn how to Measure Area, Volume & Center of Mass with Python Script. In my previous blog post I have talk about FCinfo Macro to measure Mass Properties, Weight, Volume and Area etc. in FreeCAD. If you are good in Python then you have no need to depends on Macro or addon for small task.

Related Posts-:

First command which we run is

target_object = App.ActiveDocument.getObjectsByLabel("Body")[0]

In above code preplace “Body” with your label name you can easily find you body name easily all you have to click on body and go to data tab and see in Label section As shown in below image.

Measure Area, Volume & Center Of Mass With Python Script 01

First Activate the Python console if it is not active As shown in below image.

Measure Area, Volume & Center Of Mass With Python Script 03

I have Run command in Python Console successfully As you can see in Below image.

Measure Area, Volume & Center Of Mass With Python Script 02

now we will run the script to measure Area volume and center of mass. find the area run the following script

target_object.Shape.Area

As you can see the result as shown in below image.

Measure Area, Volume & Center Of Mass With Python Script 04

To find the Volume run the following script.

target_object.Shape.Volume

I have run the script As shown in below image.

Measure Area, Volume & Center Of Mass With Python Script 05

To find the Center of Mass run the following script.

target_object.Shape.CenterOfMass

I have run the script As shown in below image.

Measure Area, Volume & Center Of Mass With Python Script 06

“Thank you for reading! If you found this article insightful and valuable, consider sharing it with your friends and followers on social media. Your share can help others discover this content too. Let’s spread knowledge together. Your support is greatly appreciated!”

Videos