Announcements

Starting in December, we will archive content from the community that is 10 years and older. This FAQ provides more information.

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: 

Accessing values from Cross Section Analysis tool

4 REPLIES 4
Reply
Message 1 of 5
Anonymous
616 Views, 4 Replies

Accessing values from Cross Section Analysis tool

Hi,

 

The goal of the project I am working on is to have the cross-sectional area and area moments of inertia (Ix and Iy) values for a part automatically populate a title block once a view of that part is loaded.

 

My first step was to look at the Cross Section Analysis tool (Inspect -> Analysis -> Cross Section Analysis). I want to somehow access these values without copying and pasting them, or having to type them. I began by looking in the Object Browser in the VBA Editor and I came across something that looks like it might be helpful (see image below).

 

Does anyone have ideas for how I could access the values from the Cross Section Analysis tool? They must be stored AND accessible somehow, somewhere in Inventor.

 

object browser (3).PNG

 

Thanks.

4 REPLIES 4
Message 2 of 5
Anonymous
in reply to: Anonymous

Also, I just looked in API Help and found this. What do the values mean on the table on the right-hand side? Does that mean I can access more information somewhere?

 

I began using iLogic a little while ago, but the API, VBA Editor, and Object Browser are all new to me, so I'm trying to understand and learn what I need to as best I can.

 

API Help..PNG

Message 3 of 5
chandra.shekar.g
in reply to: Anonymous

@Anonymous,

 

Hoping that below VBA code may be helpful.

 

Public Sub GetPartMassProps()
    ' Set a reference to the part document.
    ' This assumes a part document is active.
    Dim oPartDoc As PartDocument
    Set oPartDoc = ThisApplication.ActiveDocument

    ' Set a reference to the mass properties object.
    Dim oMassProps As MassProperties
    Set oMassProps = oPartDoc.ComponentDefinition.MassProperties

    ' Set the accuracy to medium.
    oMassProps.Accuracy = k_Medium

    ' Display the mass properties of the part.
    Debug.Print "Area: " & oMassProps.Area

    Debug.Print "Center of Mass: " & _
                    oMassProps.CenterOfMass.X & ", " & _
                    oMassProps.CenterOfMass.Y & ", " & _
                    oMassProps.CenterOfMass.Z

    Debug.Print "Mass: " & oMassProps.Mass
    Dim adPrincipalMoments(1 To 3) As Double
    Call oMassProps.PrincipalMomentsOfInertia(adPrincipalMoments(1), _
                                                    adPrincipalMoments(2), _
                                                    adPrincipalMoments(3))
    Debug.Print "Principal Moments of Inertia: " & _
                    adPrincipalMoments(1) & ", " & _
                    adPrincipalMoments(2) & ", " & _
                    adPrincipalMoments(3)

    Dim adRadiusOfGyration(1 To 3) As Double
    Call oMassProps.RadiusOfGyration(adRadiusOfGyration(1), _
                                            adRadiusOfGyration(2), _
                                            adRadiusOfGyration(3))
    Debug.Print "Radius of Gyration: " & _
                    adRadiusOfGyration(1) & ", " & _
                    adRadiusOfGyration(2) & ", " & _
                    adRadiusOfGyration(3)

    Debug.Print "Volume: " & oMassProps.Volume

    Dim Ixx As Double
    Dim Iyy As Double
    Dim Izz As Double
    Dim Ixy As Double
    Dim Iyz As Double
    Dim Ixz As Double
    Call oMassProps.XYZMomentsOfInertia(Ixx, Iyy, Izz, Ixy, Iyz, Ixz)
    Debug.Print "Moments: "
    Debug.Print "   Ixx: " & Ixx
    Debug.Print "   Iyy: " & Iyy
    Debug.Print "   Izz: " & Izz
    Debug.Print "   Ixy: " & Ixy
    Debug.Print "   Iyz: " & Iyz
    Debug.Print "   Ixz: " & Ixz
End Sub

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



Message 4 of 5
Anonymous
in reply to: chandra.shekar.g

Thank you for the code, I appreciate your help.

 

I added the two lines below to my code, and displayed the values in a message box:

 

MsgBox ("Area: " & oMassProps.Area)

MsgBox ("Principal Moments of Inertia : " & adPrincipalMoments(1) & ", " & adPrincipalMoments(2) & ", " & adPrincipalMoments(3) & " ")

 

So, I think the "Area" is the surface area of the part (I checked with iProperties, and this is the case).

However, I'm not sure about the Principal Moments of Inertia. What are the units for this? Based on the shape of my part, the values do not make sense. The principal moments should be: Ix, 0.2; and Iy, 0.549. Instead, the values I get from your code are 11.9, 12.4, and 0.950. None of my values match the values I get with your code.

 

Thanks.

Message 5 of 5
chandra.shekar.g
in reply to: Anonymous

@Anonymous,

 

As per the below Inventor API documentation link, default unit for Length and Mass are "Centimeter" and "Kilogram(kg)" respectively.

 

http://help.autodesk.com/view/INVNTOR/2020/ENU/?guid=GUID-60CADB1E-DB85-4A7D-8380-7C4FFFE558D8

 

Unit of moment of inertia would be Kilogram square Centimeter [Kg*cm^2].

 

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
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