Measure Area, Volume & Center of Mass with Python Script

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.

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!” 

Amar Patel
About Amar Patel 244 Articles
Hi, I am Amar Patel from India. Founder, Author and Administrator of mechnexus.com. I am a Simple Average Man who Loves life and Love living life. Professionally I am a Mechanical Engineer with Solid command over CAD software like FreeCAD, SolidWorks, Autodesk Inventor and AutoCAD Mechanical. I’m here to share my knowledge to help you accomplish your design and engineering tasks quicker and easier. I am Passionate about learning new things especially about Open-Source Software. I love teaching therefore I started my YouTube Channel on FreeCAD and I believe FreeCAD have lots of potential than traditional 3D software. contact me - [email protected]