Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.

how to update physical mass, area and volume...for an assembly by API

junGQMXK
Enthusiast

how to update physical mass, area and volume...for an assembly by API

junGQMXK
Enthusiast
Enthusiast

hi, everyone,

There were some API methods to update physical mass, area and volume...for an inventor .ipt part.

But it took me a lot of time to search an API method to do so for an assembly.

 

I programmed and tested for many times, now matter what I do, I could obtain the actual mass, for example, of an assembly in my rules, but whenever I opened the iproperties of the assembly, under the tab "Physical", the mass was always "N/A", unless I pressed the button "update".

 

please see the attached screenshot.

 

I would like to have some API commands to update the "Physical" mass, area, volume... for an assembly in my rules.

 

any idea?

 

Any suggestions will be appreciated.

0 Likes
Reply
Accepted solutions (1)
4,013 Views
15 Replies
Replies (15)

bradeneuropeArthur
Mentor
Mentor
Public Sub main()
Dim CmdMan As ControlDefinition
    Set CmdMan = ThisApplication.CommandManager.ControlDefinitions.Item("AppUpdateMassPropertiesCmd")
    
    CmdMan.Execute
        CmdMan.Execute2 (True)
'AppUpdateMassPropertiesCmd
End Sub

For I-logic:

Public Sub main()
Dim CmdMan As ControlDefinition
CmdMan = ThisApplication.CommandManager.ControlDefinitions.Item("AppUpdateMassPropertiesCmd")
    
    CmdMan.Execute
        CmdMan.Execute2 (True)

End Sub

 

Regards,

Arthur Knoors

Autodesk Affiliations:

Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:Drawing List!|Toggle Drawing Sheet!|Workplane Resize!|Drawing View Locker!|Multi Sheet to Mono Sheet!|Drawing Weld Symbols!|Drawing View Label Align!|Open From Balloon!|Model State Lock!
Posts and Ideas:Dimension Component!|Partlist Export!|Derive I-properties!|Vault Prompts Via API!|Vault Handbook/Manual!|Drawing Toggle Sheets!|Vault Defer Update!


! For administrative reasons, please mark a "Solution as solved" when the issue is solved !

0 Likes

junGQMXK
Enthusiast
Enthusiast
Hi, friend,
Thank you for your prompt reply.
I tried you program, it ran. And I could see the inventor process bar show up, that means that
The program really did something, but when I opened iproperties and under the tab "physical",
The mass was still "N/A".
[cid:image003.jpg@01D57CEE.F48EAF30]
By the way, I am using Inventor 2020 and windows 10.
Is there anything that I did not do correctly?

Thank you for your time.


0 Likes

junGQMXK
Enthusiast
Enthusiast

hi, 

 

I believe, your program can update the mass property internally, that is, if you use:

mass = iProperties.Mass

 

Then you can really get the updated mass value.

 

But after that, when you open the "Physical" tab of the iproperties of this assembly, you will see that the mass is still "N/A".

 

The only way to update is just clicking the "update" button?

 

I do not believe this. I think that there must be some API commands to be used to "click" the "update" button for us.

 

I have been trying to solve this problem for 10 days, because our Inventor models will be transferred to Revit models, it  better to have mass property updated and transferred to Revit.

 

any other idea?

0 Likes

JamieVJohnson2
Collaborator
Collaborator

Have you looked into InventorDocument.Update and .Update2?

jvj
0 Likes

bradeneuropeArthur
Mentor
Mentor

Hi,

Take a look at the application options:

Do have these options checked or unchecked?

MasspropAppOptions.PNG

Please check these options on save!

Regards,

Regards,

Arthur Knoors

Autodesk Affiliations:

Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:Drawing List!|Toggle Drawing Sheet!|Workplane Resize!|Drawing View Locker!|Multi Sheet to Mono Sheet!|Drawing Weld Symbols!|Drawing View Label Align!|Open From Balloon!|Model State Lock!
Posts and Ideas:Dimension Component!|Partlist Export!|Derive I-properties!|Vault Prompts Via API!|Vault Handbook/Manual!|Drawing Toggle Sheets!|Vault Defer Update!


! For administrative reasons, please mark a "Solution as solved" when the issue is solved !

0 Likes

junGQMXK
Enthusiast
Enthusiast

hi, friend,

 

thank you for your prompt reply. I tried these 2 commands of API, they did not work:

my test rule is like the following:

 

Dim doc As AssemblyDocument = ThisDoc.DocumentComponent.IsActive("Canal Isolé DP V9 size 2in Left:1") = False
Component.IsActive("Canal Isolé DP V9 size 2in Right:1") = False

Dim CmdMan As ControlDefinition
CmdMan = ThisApplication.CommandManager.ControlDefinitions.Item("AppUpdateMassPropertiesCmd")
CmdMan.Execute
CmdMan.Execute2(True) 'AppUpdateMassPropertiesCmd

MsgBox(iProperties.Mass)

mass = iProperties.Mass
doc.Update
doc.Update2

 

I made so many searches on this forum. The common thing that was done was to use "mass = iProperties.Mass" to get the updated mass and then create a customized parameter under "custom" of the assembly's ipropertes.

and then this updated mass can be quoted in drawings or in other part or assembly file.

 

But just I have said, my inventor models will have to be transfered to Revit models, and I would like to have an update "Physical" mass value in the assembly's iproperties.

 

any other suggestions?

 

0 Likes

junGQMXK
Enthusiast
Enthusiast

hi, friend,

Thank you for your advice.

yes, I have already checked these 2 options. still, it does not work. I still cannot get the updated "Physical" mass value.

 

 

any suggestions?

0 Likes

bradeneuropeArthur
Mentor
Mentor

Hi,

 

Is it a part file or an assembly file that does not update?

 

Could you share that file?

 

Regards,

Regards,

Arthur Knoors

Autodesk Affiliations:

Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:Drawing List!|Toggle Drawing Sheet!|Workplane Resize!|Drawing View Locker!|Multi Sheet to Mono Sheet!|Drawing Weld Symbols!|Drawing View Label Align!|Open From Balloon!|Model State Lock!
Posts and Ideas:Dimension Component!|Partlist Export!|Derive I-properties!|Vault Prompts Via API!|Vault Handbook/Manual!|Drawing Toggle Sheets!|Vault Defer Update!


! For administrative reasons, please mark a "Solution as solved" when the issue is solved !

0 Likes

junGQMXK
Enthusiast
Enthusiast

hi, friend,

 

it was the issue about assembly, not about part(for part, we can update the mass value on "Physical").

 

Now I send you my test assembly. It is very simple and contains only 2 identical parts. I suppressed one of the 2 parts and this created a new LOD.

 

whenever there is an man-made LOD in an assembly, then Inventor refuses to update the mass value under "Physical" tab of its "iproperties", unless you click the "update" button.

 

That was my test result.

 

Thank you for your time.

 

 

0 Likes

bradeneuropeArthur
Mentor
Mentor

Hi,

I am on 2018 so i cannot open the files right now!

Please take a look at the following "Prompt" in the application Options of inventor:

 

MasspropAppOptions2.PNG

This prompt should not be disabled, a question is needed for your LOD.

 

Regards,

Regards,

Arthur Knoors

Autodesk Affiliations:

Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:Drawing List!|Toggle Drawing Sheet!|Workplane Resize!|Drawing View Locker!|Multi Sheet to Mono Sheet!|Drawing Weld Symbols!|Drawing View Label Align!|Open From Balloon!|Model State Lock!
Posts and Ideas:Dimension Component!|Partlist Export!|Derive I-properties!|Vault Prompts Via API!|Vault Handbook/Manual!|Drawing Toggle Sheets!|Vault Defer Update!


! For administrative reasons, please mark a "Solution as solved" when the issue is solved !

0 Likes

junGQMXK
Enthusiast
Enthusiast

hi, friend,

 

Thank you for your time.

 

In fact, there is no need for me to give you any test assembly, you can create one in 1 minutes: just create a new assembly and put 2 parts into this new assembly. 

 

Then you suppress 1 of the 2 parts, then save this assembly. Then that means you have created a new LOD.

 

then you can use the following rule , or you can create any rule you want. 

 

Dim doc As AssemblyDocument = ThisDoc.Document

Dim CmdMan As ControlDefinition
CmdMan = ThisApplication.CommandManager.ControlDefinitions.Item("AppUpdateMassPropertiesCmd")
CmdMan.Execute
CmdMan.Execute2(True) 'AppUpdateMassPropertiesCmd

MsgBox(iProperties.Mass)

mass = iProperties.Mass
doc.Update
doc.Update2

 

you will find that Inventor refuses to update the mass value, unless you manually click the "update" button.

 

 

0 Likes

bradeneuropeArthur
Mentor
Mentor

Not with the correct prompt ("Do you want to....") I guess.

Or am I making a mistake here?

 

Regards,

Regards,

Arthur Knoors

Autodesk Affiliations:

Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:Drawing List!|Toggle Drawing Sheet!|Workplane Resize!|Drawing View Locker!|Multi Sheet to Mono Sheet!|Drawing Weld Symbols!|Drawing View Label Align!|Open From Balloon!|Model State Lock!
Posts and Ideas:Dimension Component!|Partlist Export!|Derive I-properties!|Vault Prompts Via API!|Vault Handbook/Manual!|Drawing Toggle Sheets!|Vault Defer Update!


! For administrative reasons, please mark a "Solution as solved" when the issue is solved !

0 Likes

junGQMXK
Enthusiast
Enthusiast

hi, friend,

 

I tried to turn on or off this "do you want to..." option. There was no effect.

 

The problem focus is just "when there are suppressed parts under a new LOD", when you try to calculate the new mass under this new LOD, then Inventor refuses to update the mass value, unless you manually click the "update" button.

0 Likes

chandra.shekar.g
Autodesk Support
Autodesk Support
Accepted solution

@junGQMXK,

 

When mass properties of assembly are retrieved through Inventor API, values are updated properly. If one part is suppressed, relative mass properties are retrieved through Inventor API. For demonstration, please go through screencast video link.

 

https://autode.sk/2AUjCyr

 

VBA code:

 

Public Sub update_mass_property()

    Dim oDoc As AssemblyDocument
    Set oDoc = ThisApplication.ActiveDocument
    
    Dim oDef As AssemblyComponentDefinition
    Set oDef = oDoc.ComponentDefinition
    
    Dim oMass As MassProperties
    Set oMass = oDef.MassProperties
    
    Debug.Print oMass.Mass
      
End Sub

But through UI, the values are unable to update if any occurrence is suppressed. Please log this wish list at idea station using below link.

 

https://forums.autodesk.com/t5/inventor-ideas/idb-p/v1232

 

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



junGQMXK
Enthusiast
Enthusiast

Hi,

 

Thank you very much for you reply. This is an answer I wanted to get.

 

your reply solved one of my puzzles, that is good and enough for me. I have accepted your answer as a solution.

 

Thank you again.

 

Regards,

 

 

0 Likes