iLogic mass properties update

iLogic mass properties update

Anonymous
Not applicable
20,993 Views
12 Replies
Message 1 of 13

iLogic mass properties update

Anonymous
Not applicable

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.

0 Likes
Accepted solutions (1)
20,994 Views
12 Replies
Replies (12)
Message 2 of 13

Anonymous
Not applicable

you might want to try setting the mass iproperty to a user parameter or temporary variable

and exporting that value

 

mymass = iProperties.Mass

0 Likes
Message 3 of 13

Anonymous
Not applicable

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

0 Likes
Message 4 of 13

Anonymous
Not applicable

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.

 

 

0 Likes
Message 5 of 13

Anonymous
Not applicable

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

 

 

Message 6 of 13

Curtis_Waguespack
Consultant
Consultant
Accepted solution

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

EESignature

Message 7 of 13

Anonymous
Not applicable

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

0 Likes
Message 8 of 13

Anonymous
Not applicable

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

0 Likes
Message 9 of 13

CAD-One
Collaborator
Collaborator

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

C1
Inventor Professional 2020
Vault Professional 2020
AutoCAD 2020
0 Likes
Message 10 of 13

Anonymous
Not applicable

Thanks It Worked!

0 Likes
Message 11 of 13

llorden4
Collaborator
Collaborator

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

 

Autodesk Inventor Certified Professional
0 Likes
Message 12 of 13

engilic
Advocate
Advocate

maybe to use

Dim oModelDoc As Document
Set oModelDoc = ThisApplication.ActiveEditDocument
oModelDoc.ComponentDefinition.MassProperties.MassOverridden = False

Message 13 of 13

Frederick_Law
Mentor
Mentor

 

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
0 Likes