Accessing Inertial Properties using iLogic

Accessing Inertial Properties using iLogic

Anonymous
Not applicable
4,944 Views
9 Replies
Message 1 of 10

Accessing Inertial Properties using iLogic

Anonymous
Not applicable

Hi All,

 

iLogic has the capabilities to access the physical properties of part files such as mass / area / volume etc. Does anyone know the ilogic syntax to read the inertial properties of the part file such as Global Ixx / Iyy / Izz??

 

I can find it in the API help, but i don't really want to write it as separate code, just want to simply access it through iLogic interface.

 

Any assistance is greatly appreciated!

0 Likes
Accepted solutions (1)
4,945 Views
9 Replies
Replies (9)
Message 2 of 10

MjDeck
Autodesk
Autodesk
Accepted solution

There are no dedicated iLogic functions to get the moment of inertia, but you can use API functions in a rule.  Here's sample code:

RuleParametersOutput()
InventorVb.DocumentUpdate()

Dim massProps as MassProperties
Dim partDoc as PartDocument = TryCast(ThisDoc.Document, PartDocument)
If (partDoc IsNot Nothing) Then massProps = partDoc.ComponentDefinition.MassProperties
Dim assemDoc as AssemblyDocument = TryCast(ThisDoc.Document, AssemblyDocument)
If (assemDoc IsNot Nothing) Then massProps = assemDoc.ComponentDefinition.MassProperties

Dim moments(5) As Double
massProps.XYZMomentsOfInertia(moments(0), moments(1), moments(2), moments(3), moments(4), moments(5))

For i = 0 To 5
 moments(i) = ThisDoc.Document.UnitsOfMeasure.ConvertUnits(moments(i), "kg cm^2", "kg mm^2")
Next

Ixx = moments(0)
Iyy = moments(1)
Izz = moments(2)

 Here Ixx, Iyy and Izz are Inventor parameters, with units of  kg mm^2

The moment components are returned from the XYZMomentsOfInertia function in units of kg cm^2

If you need different units, you can provide a different units string to the third argument of the ConvertUnits function.

 The RuleParametersOutput() statement is only required if this code is part of a larger rule in which you modify some parameters.


Mike Deck
Software Developer
Autodesk, Inc.

Message 3 of 10

Anonymous
Not applicable

Is is possible to obtain "area" moments (vs. mass moments) like the ones from "Region Properties"?

If yes, please provide example code.

 


MjDeck wrote:

There are no dedicated iLogic functions to get the moment of inertia, but you can use API functions in a rule.  Here's sample code:

 

[snip]

 

 Here Ixx, Iyy and Izz are Inventor parameters, with units of  kg mm^2

The moment components are returned from the XYZMomentsOfInertia function in units of kg cm^2

If you need different units, you can provide a different units string to the third argument of the ConvertUnits function.

 The RuleParametersOutput() statement is only required if this code is part of a larger rule in which you modify some parameters.


 

0 Likes
Message 4 of 10

MjDeck
Autodesk
Autodesk

Here's a sample rule to get the region properties of a sketch.  It uses the Profiles.AddForSolid function to get the profile. There are options available for this function to give you the exact profile you want.  Alternatively, instead of getting the profile from the sketch, you can start from an extrusion (or other feature) and get the profile directly from that.

 The rule uses Trace.WriteLine to show the properties.  You can use DebugView from

http://technet.microsoft.com/en-us/sysinternals/bb896647

to view the properties.  Or you can assign them to parameters or use them in calculations.

 


Mike Deck
Software Developer
Autodesk, Inc.

Message 5 of 10

Anonymous
Not applicable

Hey all. Great forum, it's an excellent resource, and I hope to contribute with some solutions myself sometime 🙂

 

I have a question relating to this topic:

 

Would it be possible, in ilogic to extracts the Ixx, Iyy, COG points etc. for seperate parts within the assembly?

I am familiar with the basics of programming, but new to object oriented. (such as API/VBA in inventor).

 

To me it seems like a small modification of the code above should be enough, but I'm not sure what to write to adress specific parts instead of the whole assembly.

 

Any ideas or hints would be appreciated!

 

0 Likes
Message 6 of 10

Anonymous
Not applicable

hi MJDeck,

can you tel me if the properties of the region area are still the same as when this post was made.

We like to use your code in 2018  but we cannot find the term Inertia Tensor  in your code which we need.

 

Thanks,

Danny

0 Likes
Message 7 of 10

Anonymous
Not applicable

I'm using Inventor 2019. I'm not able to access Global Mass Moment of Inertia from "MassProperties.XYZMomentsOfInertia" method/function, because it takes reference of COG as observed and mentioned in Help Documentation.

 

I couldn't find any other method from MassProperties that take reference to Global Co-ordinates (as you know COG and global reference axes need not be the same).

 

Manually I could get the information from Part/Assembly Properties tab, but could you direct me through a VBA function?

 

aswanabdulrazak_1-1623425578387.png

 

0 Likes
Message 8 of 10

MjDeck
Autodesk
Autodesk

@Anonymous , here's a sample rule that uses the parallel axis theorem to calculate the global moments of inertia. This is in iLogic. It should be possible to convert it to VBA if you need it.
Please add your vote to this Ideas initiative to expose this method in the API.

That post also has a link to another code example.

 


Mike Deck
Software Developer
Autodesk, Inc.

Message 9 of 10

Anonymous
Not applicable

@MjDeck , Thank you. I learned something new from this code. Your method of using TransientGeometry is unique.

0 Likes
Message 10 of 10

MjDeck
Autodesk
Autodesk

Thanks. I was hoping to use the Matrix object for some of the calculation, but it doesn't support addition of matrices.

 

I just noticed an error in the code. But it doesn't affect Ixx, Iyy, or Izz. It just affects Ixz. That's why I didn't notice it before. I attached a corrected version of the rule. 


Mike Deck
Software Developer
Autodesk, Inc.