Parameter changes don't fire until rule is done

Parameter changes don't fire until rule is done

Electrik
Advocate Advocate
606 Views
6 Replies
Message 1 of 7

Parameter changes don't fire until rule is done

Electrik
Advocate
Advocate

I have a Multi-value parameter, choosing Chain Size.

There's a case statement in a rule, that changes other parameters, based on that Chain Size.

With the parameters box open, if I change that Chain Size value, the rule will fire (as it should). I placed a message box in the rule (after the case statement) to notify me. What happens, sequentially:

I change the value.

The rule fires.

I see the message box, that the rule has gotten to that point.

However, the other parameters don't actually change until the rule is complete.

How can I update those parameters, before continuing with the rule? ...like an "interrupt, for update"?

 

I have tried:

iLogicVb.UpdateWhenDone = True
RuleParametersOutput(), then InventorVb.DocumentUpdate()
Inventor Professional 2021
Vault Professional 2021
0 Likes
Accepted solutions (1)
607 Views
6 Replies
Replies (6)
Message 2 of 7

A.Acheson
Mentor
Mentor

 

According to the help document here maybe try Parameter.UpdateAfterChange = True

 

  • Parameter.UpdateAfterChange = True

    True will cause the model (document) to Update after a parameter value is changed by the Parameter function. This only takes effect when you change parameters using the Parameter function. For example:

  • Parameter.UpdateAfterChange = True
  • Parameter("d0") = 2.5

    This will update the model.

    Note: ("d0") = 2.5 will NOT update the model.
To update the model in the middle of the rule (after changing some parameters) use these two statements together:
    • RuleParametersOutput()
      Note: - This will assign the current values of the parameter local variables to the model.
    • InventorVb.DocumentUpdate()

If you do not need to update the model in the middle of the rule, you can tell the system to update when it has finished running the rule. Use this statement: iLogicVb.UpdateWhenDone = True.

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes
Message 3 of 7

Electrik
Advocate
Advocate

Thanks for the idea, but that wasn't working, either.

I suspect it's related to this: The one Parameter in question is Pitch. It's not used in the model, only calculations. Therefore, the model operations don't seem to affect it...like the one you mentioned.

However, it made me think to remove it from the parameters, and treat it only as a temp variable within the rule. That got me closer, but there's other related issues: I have to split my rules up, to fire some calculations ANY time the model changes - I found that trigger.

Inventor Professional 2021
Vault Professional 2021
0 Likes
Message 4 of 7

A.Acheson
Mentor
Mentor

Can you supply a trimmed down part file with the parameters that shows the update problem? Unfortunately these issues can be hard to diagnose without the data set or more information on the code. Can you share the full code and  even a screenshot of the parameters box? 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes
Message 5 of 7

Electrik
Advocate
Advocate

I've attached my file. The intent is to select the ChainSize through parameters, which changes other parameters, including Pitch. However, When the rule (OriginalFull) fires, it seems to complete the rule, THEN update the parameters. I need the parameters updated first, for the calculations (Property settings) that follow. The ideas above didn't work. (Because Pitch isn't actually used in the model?)

Therefore, I split the rules base up into two. Part1 is just the Case Statement for ChainSize. Then, I'm firing Part2 with a Trigger, after any model update. This works better, to account for changes to other values (chain path as a whole) that aren't in the rule. It still just doesn't seem right. I'll get back to it this morning, myself.

(I have a bunch of message boxes that I've "commented out" that I use for diagnostics.)

Thanks for your time!

Inventor Professional 2021
Vault Professional 2021
0 Likes
Message 6 of 7

A.Acheson
Mentor
Mentor
Accepted solution

I had a quick look at this. It seems when your looking to display the parameter value using the local document parameter ( blue in the editor) the value is not completely up to date. It seems to be one case statement behind at times. Only running the rule twice will get this to display the correct pitch per chainSize

MessageBox.Show(ChainSize & vbLf & Pitch, "after case statement")

This test is backed up by the help document information stating

  • Parameter.UpdateAfterChange = True

    True will cause the model (document) to Update after a parameter value is changed by the Parameter function. This only takes effect when you change parameters using the Parameter function. For example:

 

Replacing the local parameter with the parameter function of " Parameter("Pitch")" will give you the updated value each time. 

MessageBox.Show(ChainSize & vbLf & Parameter("Pitch"), "after case statement")

 This is working

'set value to update model after parameter change
Parameter.UpdateAfterChange = True
Select Case ChainSize 'drop down in Parameters Case "40" Parameter("Pitch") = .500 Parameter("RollerD") = .312 Parameter("RollerW") = .312 Parameter("PinD") = .156 Parameter("PinW") = .642 Parameter("PlateT") = .058 Parameter("PlateH") = .475 Case "50" Parameter("Pitch")= .625 Parameter("RollerD") = .400 Parameter("RollerW") = .375 Parameter("PinD") = .200 Parameter("PinW") = .794 Parameter("PlateT") = .079 Parameter("PlateH") = .594 Case "60" Parameter("Pitch") = .750 Parameter("RollerD") = .469 Parameter("RollerW") = .500 Parameter("PinD") = .234 Parameter("PinW") = .994 Parameter("PlateT") = .093 Parameter("PlateH") = .712 Case "80" Parameter("Pitch") = 1.000 Parameter("RollerD") = .625 Parameter("RollerW") = .625 Parameter("PinD") = .312 Parameter("PinW") = 1.290 Parameter("PlateT") = .125 Parameter("PlateH") = .950 End Select MessageBox.Show(ChainSize & vbLf & Parameter("Pitch"), "after case statement")

 

Or if you keep using the local parameter value without the function like this

'set value to update model after parameter change
Parameter.UpdateAfterChange = True

Select Case ChainSize 'drop down in Parameters
	Case "40"
		Pitch = .500
		Parameter("RollerD") = .312
		Parameter("RollerW") = .312
		Parameter("PinD") = .156
		Parameter("PinW") = .642
		Parameter("PlateT") = .058
		Parameter("PlateH") = .475
	Case "50"
		Pitch = .625
		Parameter("RollerD") = .400
		Parameter("RollerW") = .375
		Parameter("PinD") = .200
		Parameter("PinW") = .794
		Parameter("PlateT") = .079
		Parameter("PlateH") = .594
	Case "60"
		Pitch = .750
		Parameter("RollerD") = .469
		Parameter("RollerW") = .500
		Parameter("PinD") = .234
		Parameter("PinW") = .994
		Parameter("PlateT") = .093
		Parameter("PlateH") = .712
	Case "80"
		Pitch = 1.000
		Parameter("RollerD") = .625
		Parameter("RollerW") = .625
		Parameter("PinD") = .312
		Parameter("PinW") = 1.290
		Parameter("PlateT") = .125
		Parameter("PlateH") = .950
End Select

MessageBox.Show(ChainSize & vbLf & Pitch, "after case statement")

'immediately update model with the above parameters
RuleParametersOutput()
InventorVb.DocumentUpdate()

 

It seems the mixing of the local parameter and parameter functions methods is what causes the issues. If you use one or the other it works. 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes
Message 7 of 7

Electrik
Advocate
Advocate

Ah, I understand. Thank you so much! That seems to fix it. All those little details!

Inventor Professional 2021
Vault Professional 2021
0 Likes