Calculate mass

Calculate mass

bernd.schreck
Contributor Contributor
1,638 Views
2 Replies
Message 1 of 3

Calculate mass

bernd.schreck
Contributor
Contributor

Hello,

hope I´m in the right forum.

I want to update the mass of a part (or assembly) from an Inventor Addin.

Using Inventor 2020 and VB.net

 

Problem is that I want to update/calculate the mass which was changed by the user (so a "custom" mass) based on the selected material.

 

Already looked in the forums but the following solutions does not working:

 

'updating mass by instancing

Dim dMass As Double
dMass = oDoc.ComponentDefinition.MassProperties.Mass

 

'updating mass by using controls

Dim CmdMan As ControlDefinition
CmdMan = invApp.CommandManager.ControlDefinitions.Item("AppUpdateMassPropertiesCmd")

'CmdMan.Execute()
CmdMan.Execute2(True)

 

The mass stays always at the custom one which the user first has defined. 

In Inventor I could press the update button after removing the mass, but how to solve this by API?

THX

Bernd

0 Likes
Accepted solutions (1)
1,639 Views
2 Replies
Replies (2)
Message 2 of 3

dutt.thakar
Collaborator
Collaborator
Accepted solution

@bernd.schreck 

Are you looking for something like this? This will check if the mass is overridden, if it is, it will remove it and update the iProperties. I tested it and it is working as expected.

Dim oDoc As PartDocument = invApp.ActiveDocument
Dim oDef As PartComponentDefinition = oDoc.ComponentDefinition

If oDef.MassProperties.MassOverridden = True
	oDef.MassProperties.MassOverridden = False
End If
invApp.CommandManager.ControlDefinitions.Item("AppUpdateMassPropertiesCmd").Execute

 Hope this will help.

If this answer has solved your problem please ACCEPT SOLUTION and hit like if you found it helpful..!


Regards,
Dutt Thakar
LinkedIn
0 Likes
Message 3 of 3

bernd.schreck
Contributor
Contributor
Exactly what I have looked for.
Thank you so much @Anonymous.hakar 🙂
0 Likes