Volume, center of mass and matrix of inertia
For all solids you can get:- volume - add
Shape.Volume
attribute to object, - center of mass - add
Shape.CenterOfMass
attribute, - matrix of inertia - add
Shape.MatrixOfInertia
attribute.
Cone (height = 40 mm, radius = 30 mm) named "Revolution"
>>> App.ActiveDocument.getObject("Revolution").Shape.MatrixOfInertia
Matrix ((7.35133e+06,-6.48484e-11,2.72874e-09,0),(-6.48484e-11,7.35133e+06,4.02739e-10,0),(2.72874e-09,4.02739e-10,1.01788e+07,0),(0,0,0,1))
>>> App.ActiveDocument.getObject("Revolution").Shape.CenterOfMass
Vector (6.11835e-15, 6.99401e-16, 30)
>>> App.ActiveDocument.getObject("Revolution").Shape.Volume
37699.11184307751
MatrixOfInertia attribute output needs some explanation:
http://free-cad.svn.sourceforge.net/viewvc/free-cad/trunk/src/Mod/Part/App/TopoShapeSolidPy.xml?view=markup&pathrev=5337
Returns the matrix of inertia. It is a symmetrical matrix.So, we have 3 moments of inertia:
The coefficients of the matrix are the quadratic moments of inertia.
| Ixx Ixy Ixz 0 |
| Ixy Iyy Iyz 0 |
| Ixz Iyz Izz 0 |
| 0 0 0 1 |
The moments of inertia are denoted by Ixx, Iyy, Izz.
The products of inertia are denoted by Ixy, Ixz, Iyz.
The matrix of inertia is returned in the central coordinate system (G, Gx, Gy, Gz) where G is the centre of mass of the system and Gx, Gy, Gz the directions parallel to the X(1,0,0) Y(0,1,0) Z(0,0,1) directions of the absolute cartesian coordinate system.
Ixx=7.35133e+06
Iyy=7.35133e+06
Izz=1.01788e+07
Further explanation - FreeCAD forum.
Area of face
You can measure area of face, simply addArea
attribute. If you need area of a sketch, convert one to a face:>>> face = Part.Face(App.ActiveDocument.getObject("Sketch").Shape)
>>> face.Area
1469.9597436001611
Update:
If you have a solid (eg. a Pad), select face or faces on the solid object, and use this script:
area = 0.0
for o in Gui.Selection.getSelectionEx() :
for s in o.SubObjects:
area = s.Area
print "Area of selected face:" ,area
I have a simple extruded box. When I go over a face: test.Pad.Face5 but I can't seem to find the command how to get the Area of that face.
ReplyDeletePost has been updated - check last script.
ReplyDelete>>> App.ActiveDocument.getObject("Cylinder").Shape.MatrixOfInertia
ReplyDeleteTraceback (most recent call last):
File "", line 1, in
AttributeError: 'Part.TopoShape' object has no attribute 'MatrixOfInertia'
After call matrixofinertia I get the Error and I don't know what to do. Please help me
hi jaro , we are facing the same problem. do you have a solution ?
ReplyDeletethanks !
Please install the latest FreeCAD. The issue is fixed now.
ReplyDeleteTested for version: 0.13.1766 (Git)
Check also https://sourceforge.net/apps/phpbb/free-cad/viewtopic.php?f=3&t=3407#p26524
ReplyDeleteHello!
ReplyDeleteHow can I get the volume (or mass) und the overall face of an imported STEP-file?
Form volume, select object and:
ReplyDeleteobj = FreeCADGui.Selection.getSelection()
obj[0].Shape.Volume
For area:
area = 0.0
for f in obj[0].Shape.Faces:
area = f.Area + area
print area
hello, now from this example how can get the Mass moment of inertia ???
ReplyDeleteplease help