Hide Table of Contents
IGetMassProperties Method (IBody2)

Gets the mass properties of this body.

.NET Syntax

Visual Basic (Declaration) 
Function IGetMassProperties( _
   ByVal Density As System.Double _
) As System.Double
Visual Basic (Usage) 
Dim instance As IBody2
Dim Density As System.Double
Dim value As System.Double
value = instance.IGetMassProperties(Density)
System.double IGetMassProperties( 
   System.double Density
System.double IGetMassProperties( 
&   System.double Density



Density to use for the mass property calculations on this body

Return Value

  • in-process, unmanaged C++: Pointer to an array of doubles (see Remarks)
  • VBA, VB.NET, C#, and C++/CLI: Not supported

See In-process Methods for details about this type of method.


This method is intended for obtaining the mass properties of temporary objects but may also be used with the SOLIDWORKS IBody2 object that is created by the user. To get the mass properties of the SOLIDWORKS IBody2 object created by the user, you can also use IModelDocExtension::IGetMassProperties, which uses the density currently set for the body's material.

The return value is an array of doubles as follows:

Solid body

[ CenterOfMassX, CenterOfMassY, CenterOfMassZ, Volume, Area, Mass(Volume*density), MomXX, MomYY, MomZZ, MomXY, MomZX, MomYZ ]

Sheet body

[ CenterOfMassX, CenterOfMassY, CenterOfMassZ, Area, Circumference, Mass(Area*density), MomXX, MomYY, MomZZ, MomXY, MomZX, MomYZ ]

Wire body

[ CenterOfMassX, CenterOfMassY, CenterOfMassZ, Length, 0, Mass(Length*density), MomXX, MomYY, MomZZ, MomXY, MomZX, MomYZ ]

You can use ISldWorks::GetUserPreferenceDoubleValue to get the density used by the SOLIDWORKS part. Consistent with all other SOLIDWORKS API functions, units are metric unless otherwise specified.

SOLIDWORKS returns information (such as the center of mass) in relation to where the body was created. For example, if you create a block in a part file that is centered at (0,0,0), then SOLIDWORKS returns the center of mass as (0,0,0). If you then use this part at some random location within an assembly, and the body is obtained from the assembly component object using IComponent2::IGetBody, then SOLIDWORKS still returns the center of mass as (0,0,0). If you need to determine the body's center of mass in relation to the assembly coordinate system, you need to multiply the component transform and the center of mass coordinates (see IComponent2::Transform2).


See Also

Provide feedback on this topic

SOLIDWORKS welcomes your feedback concerning the presentation, accuracy, and thoroughness of the documentation. Use the form below to send your comments and suggestions about this topic directly to our documentation team. The documentation team cannot answer technical support questions. Click here for information about technical support.

* Required

Subject:   Feedback on Help Topics
Page:   IGetMassProperties Method (IBody2)
*   I acknowledge I have read and I hereby accept the privacy policy under which my Personal Data will be used by Dassault Systèmes

Print Topic

Select the scope of content to print:


We have detected you are using a browser version older than Internet Explorer 7. For optimized display, we suggest upgrading your browser to Internet Explorer 7 or newer.

 Never show this message again

Web Help Content Version: API Help (English only) 2015 SP05

To disable Web help from within SOLIDWORKS and use local help instead, click Help > Use SOLIDWORKS Web Help.

To report problems encountered with the Web help interface and search, contact your local support representative. To provide feedback on individual help topics, use the “Feedback on this topic” link on the individual topic page.