The other day I ran across an error with the massProperties and submit it to GoEngineer and got a SR Number 1-1366886371
and a SPR # 521659 , the sent me some code for a work around,
I haved never used CreateMassProperty before so I did some testing
and found this
download bug.zip and extract files then open Assem1
check the mass of Assem1 then check the Mass of Assem2
then check mass of part1
open Assem2
and run code
--code --
Sub test()
Debug.Print ("----------start------------------------------")
Dim swApp As SldWorks.SldWorks
Dim swModeldoc As SldWorks.ModelDoc2
Set swApp = CreateObject("SldWorks.Application")
Set swModeldoc = swApp.ActiveDoc
Dim vMassProp As Variant
vMassProp = swModeldoc.GetMassProperties
Mass = vMassProp(5) * 2.20462262
Debug.Print ("GetMassProperties Mass: " & Mass)
Dim MassProp As SldWorks.MassProperty
Set MassProp = swModeldoc.Extension.CreateMassProperty
Mass = MassProp.Mass * 2.20462262
Debug.Print ("CreateMassProperty Mass: " & Mass)
Debug.Print ("----------end--------------------------------")
End Sub
----------start------------------------------
GetMassProperties Mass: 13.2058611510285
CreateMassProperty Mass: 0.164532147827838
----------end--------------------------------
then unsuppress part2 re-run code
----------start------------------------------
GetMassProperties Mass: 13.2058611510285
CreateMassProperty Mass: 13.2058611510285
----------end--------------------------------
the resurpress part2 then run re-code
----------start------------------------------
GetMassProperties Mass: 0.164532147827838
CreateMassProperty Mass: 0.164532147827838
----------end--------------------------------
the CreateMassProperty is aways right
CreateMassProperty is also better to get the properties from
CreateMassProperty Mass = MassProp.Mass * 2.20462262 [ this is SldWorks.MassProperty]
GetMassProperties Mass = vMassProp(5) * 2.20462262 [ this is a Object]
I will only use CreateMassProperty for now on
SolidworksApi macros