Inventor iLogic: Dislay Mass from Different LOD on Drawing

By Xiaodong Liang

This is from a forum post in which one customer wanted to get mass of each LOD and display them on the drawing of top assembly. 

The advocate Rossano Praderi shared a solution which is nice to me. He provided the dataset only. I think it will be helpful for more customers with the workflow and codes out of the dataset. So I wrote this blog. Thanks Rossano Praderi!

  1. In the attached dataset, there is a top assembly with several components. Three LOD (First, Second, Third) are created.

  2. The corresponding drawing of the top assembly is also created.

clip_image001

  1. An iLogic rule is attached with this assembly. It activates each LOD one by one, and updates the value of corresponding custom property with the Mass value. If such custom property does not exist, it will be created automatically.

‘get RepresentationsManager

Dim repMgr As RepresentationsManager = ThisApplication.ActiveDocument.ComponentDefinition.RepresentationsManager

 

‘record current LevelOfDetailRepresentation

Dim oCurrentRepName As String  = repMgr.ActiveLevelOfDetailRepresentation.Name

 

Dim oRep As LevelOfDetailRepresentation

Dim oRepName 

Dim oMass

 

For Each oRep In repMgr.LevelOfDetailRepresentations

    oRepName = oRep.Name

    ‘activate this LOD

    repMgr.LevelOfDetailRepresentations.Item(oRepName).Activate

    ‘get mass

     oMass = iProperties.Mass

     ‘update value of custom property

     iProperties.Value("Custom", oRepName) = iProperties.Mass

Next

 

‘restore

repMgr.LevelOfDetailRepresentations.Item(oCurrentRepName).Activate

image

  1. In the drawing document, define some Property Text (from model) in the sheet. e.g. if we need the information of First/Second/Thrid LOD. The values will be displayed in the sheet.

 

image

image


Comments

3 responses to “Inventor iLogic: Dislay Mass from Different LOD on Drawing”

  1. Lars Boijens Avatar
    Lars Boijens

    Hi Xiaodong Liang,
    I am an inventor user who loves using several LOD’s, so this ilogic rule is very useful to me, thank you! I do have one question.
    When creating the custom property, the mass displayed as a custom property has 6 decimals. Looking closely at your screenshot, yours does too.
    Do you know how to add the lod mass custom property with, for example only one (1) decimal?
    Kind regards!
    Lars

  2. mymass = Round(iProperties.Mass, 2)
    , x is your number of decimal places.

  3. How could we simplify this to get a specific LOD instead of grabbing all of them?

Leave a Reply to Chris BullionCancel reply

Discover more from Autodesk Developer Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading