Inventor 2023 : Update Part mass into a for each loop with iLogic.

Inventor 2023 : Update Part mass into a for each loop with iLogic.

vpeuvion
Advocate Advocate
130 Views
2 Replies
Message 1 of 3

Inventor 2023 : Update Part mass into a for each loop with iLogic.

vpeuvion
Advocate
Advocate

Hello, I'm having an update issue when I try to vary a parameter by a step.
I'm trying to retrieve the part's masses by varying a parameter.
For example, I have a rectangular Sheet Metal part with a length of "Length." If I create a rule and add this code:

Length += 200
iLogicVb.UpdateWhenDone = True
MessageBox.Show(iProperties.Mass)

Each time I run the rule, the part changes visually and the mass changes.
However, if I insert this code into a for Each loop, it no longer works.

For Length = 200 To 1000 Step 200
	iLogicVb.UpdateWhenDone = True
	MessageBox.Show(iProperties.Mass)
Next

I tried:
ThisApplication.CommandManager.ControlDefinitions.Item("PartRebuildAllCmd").Execute
ThisApplication.CommandManager.ControlDefinitions.Item("AppUpdateMassPropertiesCmd").Execute
But without success. I'm out of ideas.
Does anyone have any suggestions?
My goal is to get all the part's masses for each configuration.
Thanks.

Vincent.

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

WCrihfield
Mentor
Mentor
Accepted solution

Try that last block of code like this instead:

iLogicVb.UpdateWhenDone = True
For i As Integer = 200 To 1000 Step 200
	Length = i
	RuleParametersOutput()
	InventorVb.DocumentUpdate()
	MessageBox.Show(iProperties.Mass.ToString())
Next

If this solved your problem, or answered your question, please click ACCEPT SOLUTION .
Or, if this helped you, please click (LIKE or KUDOS) 👍.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 3 of 3

vpeuvion
Advocate
Advocate

Hello @WCrihfield .

I forgot about RuleParametersOutput().😉
Thank you very much.

0 Likes