Hello guys,
I'm trying to build a VBA code in inventor 2010 to export the Center of gravity coordinates (X,Y,Z) from an inventor assembly to an excel sheet.
But I'm not able to get the iproperties for the COG from my assembly.
Is there somebody can help me ?
Thanks
Solved! Go to Solution.
Solved by wayne.brill. Go to Solution.
Hello,
You could get the COG from the assembly document. Here is a VBA example I tried. It prints the same values I see in the iProperties dialog to the VBA Immediate window.
Public Sub GetCOG()
Dim oDoc As Inventor.Document
Set oDoc = ThisApplication.ActiveDocument
Dim UoM As UnitsOfMeasure
Set UoM = oDoc.UnitsOfMeasure
Dim oCenOfMassX As Double
oCenOfMassX = oDoc.ComponentDefinition.MassProperties.CenterOfMass.X
oCenOfMassY = oDoc.ComponentDefinition.MassProperties.CenterOfMass.Y
oCenOfMassZ = oDoc.ComponentDefinition.MassProperties.CenterOfMass.Z
Debug.Print UoM.ConvertUnits(oCenOfMassX, kDatabaseLengthUnits, kDefaultDisplayLengthUnits)
Debug.Print UoM.ConvertUnits(oCenOfMassY, kDatabaseLengthUnits, kDefaultDisplayLengthUnits)
Debug.Print UoM.ConvertUnits(oCenOfMassZ, kDatabaseLengthUnits, kDefaultDisplayLengthUnits)
End Sub
Wayne Brill
Autodesk Developer Network