Updating Body Properties from assembly or part occurrance

Updating Body Properties from assembly or part occurrance

melsabbahy
Explorer Explorer
641 Views
6 Replies
Message 1 of 7

Updating Body Properties from assembly or part occurrance

melsabbahy
Explorer
Explorer

How could this button be accessed, I am using Visual Studio and vb.net?

I am trying to update the body properties using a loop for each body before extracting data

melsabbahy_0-1682409317623.png

 

0 Likes
642 Views
6 Replies
Replies (6)
Message 2 of 7

WCrihfield
Mentor
Mentor

Hi @melsabbahy.  There is a command (ControlDefinition) that gets executed when you click that button.  The name of that command is "AppUpdateMassPropertiesCmd".  You can simulate clicking that button by executing that command.  However, when you execute this command, it doesn't know which document it is supposed to work on, so it will likely just work on whichever document is currently visibly open on your screen at the time.

ThisApplication.CommandManager.ControlDefinitions.Item("AppUpdateMassPropertiesCmd").Execute2(True)

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 3 of 7

melsabbahy
Explorer
Explorer

Hi @WCrihfield . thanks a lot.

I wonder if there is there another method. I need to address a certain body by name, then apply this update to it.

as you can see all the values are N/A, so it always causes an error and interrupts the routine being executed.

0 Likes
Message 4 of 7

WCrihfield
Mentor
Mentor

Hi @melsabbahy.  Individual SurfaceBody Type objects do not have their own MassProperties that we can access by code.  They do have a Property named Volume though, which you might be able to use to multiply by the part's current Material mass per unit of volume value, to get the mass of that body.  I can select a specific SurfaceBody object by code and launch that user interface dialog using the "PartBodyPropertiesCtxCmd" command by code, but I can not click that [Update] button within that dialog by code, and I can not retrieve a per body mass value, because it does not exist in Inventor's API yet.  When you launch that dialog with this command, your code is paused until that dialog is closed, similarly to launching an iLogic Form as Modal by code.  The active MaterialAsset itself usually does not contain this 'mass per unit of volume' either, but its physical properties asset does contain an AssetValue relating to its Density.  But even that density value may not be accurate if it is a custom material that you have not specifically supplied this value for.

 

Edit:  Actually, I am wrong.  In Inventor 2023 they introduced the MassProperties Property to the SurfaceBody object, which returns a SurfaceBodyMassProperties object in Inventor's API, but unfortunately I'm still using 2022.4.1 at work, so I did not see that in my tests.  So if you have 2023 version, you could use that to get the mass of the body, but I still do not see a method included for ensuring that those mass properties are updated.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 5 of 7

WCrihfield
Mentor
Mentor

This VBA Sample code hosted within Inventor's online help area suggest checking if the MassProperties values are accurate to the needed level first, and if that test returns False, you can then set it to the needed accuracy then query the Mass to get an updated value that meets that accuracy specification.

https://help.autodesk.com/view/INVNTOR/2024/ENU/?guid=MassProperties_CacheResultsOnCompute_Sample 

 

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 6 of 7

melsabbahy
Explorer
Explorer
Thank you!
I am using 2024 Version (educational one) as offer by my university. that's why I found the SurfaceBodyMassProperties Object. In anyways, I'll try the workaround method described below.

Is there a method to submit request for improvement to Autodesk to add such method to the next versions?
0 Likes
Message 7 of 7

WCrihfield
Mentor
Mentor

Hi @melsabbahy.  Yes.  Autodesk has an entire forum dedicated specifically to allowing us users to suggest updates or changes to their Inventor product.  It is called "Inventor Ideas", and is located at the following web address:

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

I did a quick search and found a similar sounding 'idea' that someone else posted back in late 2021.  The link to that post is below, but you can also create your own 'idea' post too if you want.

https://forums.autodesk.com/t5/inventor-ideas/physical-iproperties-mass-automatically-updated/idi-p/... 

We usually strongly encourage folks to spend some time searching existing ideas for similar ideas first though, before creating a new post.  And if similar existing ideas are found, and you agree with them, click on [VOTE] button at the bottom of the post to give it your vote, to help it gain popularity and get the attention of the folks at Autodesk to review the requests for future consideration.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes