AnsweredAssumed Answered

API Mass Property Issue

Question asked by Paul Ryan on Apr 26, 2013
Latest reply on Apr 29, 2013 by Paul Ryan

I am able to traverse a tree of SolidWorks and get the mass properties of all the assemblies.  When I get down to the part files I cannot seem to get it to work.  I get the correct mass, moments of inertia and products of inertia but the CG is way off. 

 

The macro section is this:

 

 

Dim swModel                     As SldWorks.ModelDoc2

Dim swModelExt                  As SldWorks.ModelDocExtension

Dim swComp                      As SldWorks.Component2

Dim swMass                      As SldWorks.MassProperty

 

   If swModel.GetType = 2 Then

      compbody = swComp.GetBodies3(swAllBodies, bodyInfo)

   ElseIf swModel.GetType = 1 Then

      compbody = swComp.Name2

   End If

   Set swMass = swModelExt.CreateMassProperty

   boolstatus = swMass.AddBodies(compbody)

   params = swMass.CenterOfMass

 

I get what apears to be arbitrary cg if its a part.  swModel.GetType = 2 is an swAssemblyDoc and swModel.GetType = 2 is an swPartDoc.   If i use the same condition for the Parts that I do for the Assemblies I get zero mass properties.  Any help would be greatly appreciated.

 

Thanks.

Outcomes