Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Trying to build a VBA code in inventor 2010...help needed

1 REPLY 1
SOLVED
Reply
Message 1 of 2
Anonymous
879 Views, 1 Reply

Trying to build a VBA code in inventor 2010...help needed

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

1 REPLY 1
Message 2 of 2
wayne.brill
in reply to: Anonymous

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



Wayne Brill
Developer Technical Services
Autodesk Developer Network

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report