VBA macro: mass and center of gravity extraction of a part => Excel

Hi all

I am trying to extract from excel the mass and the center of gravity of a part and if possible of all the parts of an assembly.

I already use macros between SW and Excel, but I don't know where to find the naming of these values (mass and center of gravity) to be able to code them.

Do you know them?

In absolute terms, is there a list of codes to use to fetch the characteristics of a part via VBA?

Thank you in advance!!

Have a good end of the day.

 

1 Like

Hello

For the center of gravity: http://help.solidworks.com/2015/english/api/sldworksapi/SolidWorks.Interop.sldworks~SolidWorks.Interop.sldworks.IMassProperty~CenterOfMass.html

For the ground: http://help.solidworks.com/2015/english/api/sldworksapi/SolidWorks.Interop.sldworks~SolidWorks.Interop.sldworks.IMassProperty~Mass.html

To go further, here is the list of IMassProperty Interface members: http://help.solidworks.com/2015/english/api/sldworksapi/solidworks.interop.sldworks~solidworks.interop.sldworks.imassproperty_members.html

Hoping to have helped you.

Have a good code and have a good day  :-)

4 Likes

For a list of VBA codes, when you are in your VBA window, go to the small "object explorer" icon.

And then you just have to browse and find what you're looking for!

 

Obviously, it only works if you type your code from the solidworks VBA window;)

3 Likes

Thank you for your answers, I'll be able to move forward on that! 

Have a good day to you! 

1 Like

Post the code once you're done.

The objective remains sharing....

3 Likes

As soon as it turns around, no worries!

1 Like