Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

iLogic mass properties update

12 REPLIES 12
SOLVED
Reply
Message 1 of 13
richardclifford1666
18026 Views, 12 Replies

iLogic mass properties update

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.

12 REPLIES 12
Message 2 of 13

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

and exporting that value

 

mymass = iProperties.Mass

Inventor 2010 Certified Professional
Message 3 of 13

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

Message 4 of 13

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.

 

 

Message 5 of 13

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

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

Message 7 of 13

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

Message 8 of 13
afredrik
in reply to: afredrik

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

Message 9 of 13
CAD-One
in reply to: Curtis_Waguespack

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
Message 10 of 13
J.Tofts
in reply to: WHassan

Thanks It Worked!

Message 11 of 13

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
Message 12 of 13

maybe to use

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

Message 13 of 13

 

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.

Post to forums  

Autodesk Design & Make Report