Is there any way to force an update of mass property values of a component from within an iLogic routine?
I am trying to produce a calibration chart showing the volumes of an irregular shaped object by taking incremental slices off the component and accessing the "volume" of the remaining portion, then writing the the results to an external file - All from within a "For - Next" loop.
The main routine works O.K. but the resultant chart only shows the original starting volume for each slice instead of the required reducing volumes.
I am a novice with iLogic and can only assume that I must somehow "update" the mass properties of the sliced object before reading its new volume on each pass - Any advice on how to achieve this would be appreciated.
Solved! Go to Solution.
Solved by Curtis_Waguespack. Go to Solution.
you might want to try setting the mass iproperty to a user parameter or temporary variable
and exporting that value
mymass = iProperties.Mass
This is not the problem, I already have the code ........ splitvolume = iProperties.Volume........as part of the routine.
The problem is that next time through the loop with a different split height the "iProperties.Volume" value has not been updated to the new volume, and so the "new" value of "splitvolume" remains the same
What I think I need is some iLogic code that will force an update of the mass property values, similar in operation to pressing the update button on the iProperties dialog screen in inventor.
I have tried adding - ILogicVb.UpdateWhenDone=True, and - InventorVb.DocumentUpdate()
both of which do not seem to have the desired effect.
I found this link. It wouldn't do what you wanted to accomplish through an iLogic routine,
but I think you can have workarounds for it.
http://autodeskmfg.blogspot.ca/2009/08/updating-part-assembly-mass-properties.html
(if you don't want to go to the link, there is an option in 'General' tab in Inventor settings labeled as "Update Physical Properties on Save")
Hope it helps
Hi richardclifford1666,
You can use the CommandManager to do this, as in this example:
ThisApplication.CommandManager.ControlDefinitions.Item("AppUpdateMassPropertiesCmd").Execute myMass = iProperties.Mass MessageBox.Show("Mass = " & myMass, "iLogic")
I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com
I found out this doesn't work after deletion of features. When I delete features the mass is shown as N/A. Also in the iPoperties. How do I update this with code. When updating or adding features it works fine, but not for deletion.
Regards,
Antwan
Sorry, it works. The mass shown in the message box is the new updated mass, also when a feature is deleted. But the physical iProperty 'Mass' is shown as N/A after feature deletion. How can I get this updated with code triggered by 'Part Geometry Change' without having to save the document first . Because we used the Physical iProperty 'Mass' already in thousands of documents.
Best regards,
Antwan
Curtis,
Do you think if this code could be saved inside a idw template; so tha the all idws can have a updated mass.
Thanks
Mohan
I figured best to blow the dust off this old topic than to start a new one of the same topic...
I was having issues storing the current mass properties to a custom iProperty and with Version 2016 with part files; the solution I found was to place this line of text just before my iLogic command to ping the current mass properties value.
InventorVb.DocumentUpdate(False) 'required to get current mass properties
maybe to use
Dim oModelDoc As Document
Set oModelDoc = ThisApplication.ActiveEditDocument
oModelDoc.ComponentDefinition.MassProperties.MassOverridden = False
InventorVb.DocumentUpdate(False)
This works, even in Model State.
My code:
Dim NewMass As Double Dim OldMass As Double NewMass = Round(iProperties.Mass, 2) Try OldMass = iProperties.Value("Custom", "Mass") If OldMass <> NewMass Then InventorVb.DocumentUpdate(False) iProperties.Value("Custom", "Mass") = NewMass End If Catch ThisDoc.Document.PropertySets.Item("Inventor User Defined Properties").Add(NewMass, "Mass") End Try
Can't find what you're looking for? Ask the community or share your knowledge.