how to get around running a rule twice if it involves a reference dimension?

how to get around running a rule twice if it involves a reference dimension?

chris
Advisor Advisor
756 Views
12 Replies
Message 1 of 13

how to get around running a rule twice if it involves a reference dimension?

chris
Advisor
Advisor

Just wondering if anyone has figured out a way to avoid running a rule twice that has a reference dimension in it's math, that changes based on a layout option?

 

0 Likes
757 Views
12 Replies
Replies (12)
Message 2 of 13

A.Acheson
Mentor
Mentor

Hi Chris,

If you remove the local parameter and put it in to the parameter function then it will update as the rule runs instead of at the end. See article here

Example 

 

Parameter.UpdateAfterChange = True
Parameter("D0")

 

 

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 13

chris
Advisor
Advisor

@A.Acheson what do you mean by "remove the local parameter and put it in the parameter function"? Are yiou saying to add this line of code before each function i want to make sure updates? 

chris_0-1694296722535.png

 

0 Likes
Message 4 of 13

A.Acheson
Mentor
Mentor

That update line is only required once in the rule. at the top. I didn't see earlier that your were using the parameter function. Does the update line make a difference? 

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 13

Curtis_Waguespack
Consultant
Consultant

@chris 

 

can you share the file?

 

My guess is that one of your other rules might be running when one of the parameters updates, and that could be causing it to set the value that it is "remembering".

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

EESignature

0 Likes
Message 6 of 13

chris
Advisor
Advisor

@Curtis_Waguespack Here's the file, I'm still not sure why I have to click the button to update it, but if you figure it out, can you please explain it, instead of just fixing it, I'd really like to understand what I did wrong.

0 Likes
Message 7 of 13

A.Acheson
Mentor
Mentor

I see alot of local parameters in the rule and would certainly check any parameters doing calculation. Which parameters have you identified as not updating? 

This is how I would run parameters to ensure proper update. 

Parameter.UpdateAfterChange = True
Parameter("D72") = Parameter("Height") + Parameter("D74")

 

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

Curtis_Waguespack
Consultant
Consultant

Hi @chris 

 

I'm not really sure the reason why you're seeing the results you're seeing. My guess that another rule was running was wrong though.

 

I removed the triggers and isolated things as best I could, but still saw the issue.

 

I've seen this before though, and in fact I had a customer who had a very similar issue just recently.

 

 In his case, and in yours we can fix it by just adding a loop for the part of the code that needs to run 2x.

 

It's not the most elegant solution, but it gets the job done.

 

I think you can remove the triggers if using this version of the rule.

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

 

 

 

iLogicVb.UpdateWhenDone = True

'Rise_Run
If Rise = "6.5" Then
	Parameter("Run") = 11
ElseIf Rise = "6.75" Then
	Parameter("Run") = 10.75
ElseIf Rise = "7" Then
	Parameter("Run") = 10.5
ElseIf Rise = "7.25" Then
	Parameter("Run") = 10.25
ElseIf Rise = "7.5" Then
	Parameter("Run") = 10
ElseIf Rise = "7.75" Then
	Parameter("Run") = 9.75
ElseIf Rise = "8" Then
	Parameter("Run") = 9.5
ElseIf Rise = "8.25" Then
	Parameter("Run") = 9.25
ElseIf Rise = "8.5" Then
	Parameter("Run") = 9
ElseIf Rise = "8.75" Then
	Parameter("Run") = 8.75
ElseIf Rise = "9" Then
	Parameter("Run") = 8.5
ElseIf Rise = "9.25" Then
	Parameter("Run") = 8.25
ElseIf Rise = "9.5" Then
	Parameter("Run") = 8
End If

For i = 1 To 2
	'Stair Type
	If Stair_Type = "Floor To Platform" Then
		Parameter("d67") = Parameter("TMSW")
		Parameter("d72") = Parameter("Height")
	ElseIf Stair_Type = "Platform To Platform" Then
		Parameter("d67") = Parameter("d68")
		Parameter("d72") = Parameter("Height") + Parameter("d74")
	End If
	InventorVb.DocumentUpdate()
Next

'Array Count
iCount = Ceil(Height / Rise)
TrdS = Height / iCount
TrdC = iCount

iCountFP = Floor(d99 / RRAL)
TrdSFP = d99 / iCountFP
TrdCFP = iCountFP

iCountPP = Floor(d78 / RRAL)
TrdSPP = d78 / iCountPP
TrdCPP = iCountPP

icountVert = Ceil(d260 / OSHA_VO)
VertS = (d260 - (RVO * 2)) / icountVert
VertC = icountVert


'NOTs = Math.Floor(d78 / RRAL)
'NOTsO = (NOTs * Rise) -d97
'If NOTsO <= 4 Then
'TrdCF = NOTs
'ElseIf NOTsO > 4 Then
'TrdCF = NOTs
'End If


If Run_TF = True Then
	isnot_Run = False
Else
	isnot_Run = True
End If

 

 

 

EESignature

0 Likes
Message 9 of 13

chris
Advisor
Advisor

@A.Acheson When I add the "update after change" nothing happens, When I format the lines to use the word "Parameter" with () around the parameter name, I get errors in the code for both lines 35 & 38...? When I remove the above example you gave the code has no errors, but I have to update and run the code twice again. weird... I believe iLogic does not like running equations with (reference dims)

0 Likes
Message 10 of 13

chris
Advisor
Advisor

@Curtis_Waguespack  what does this mean? 

chris_0-1694489054504.png

 

0 Likes
Message 11 of 13

Curtis_Waguespack
Consultant
Consultant

Hi @chris 

 

It's just telling it to loop through that code 2x, by setting i to 1 then running the code, then setting i to 2 and running the code again.

 

If we said "For i = 1 to 10" then it would loop 10 times.

 

And "i" is just a local variable, that is arbitrary. I generally think of i standing for index, so we're indexing though the loop some number of times.

 

This would work just as well though:

 

For bananas = 1 To 10
	MsgBox(bananas)
Next

 

 

EESignature

0 Likes
Message 12 of 13

J-Camper
Advisor
Advisor

@chris,

 

I changed the iLogic to feed equations instead of values.  I think this is always better unless you are trying to overcome a cyclic dependency.

 

I made the changes in Inventor 2023, so If you are in an older version I also added a text file with the iLogic code.  I had to add a Parameter "RVO" as it did not exist, but set it to 0 in so it should give the same result as you currently return.

 

Let me know if you have any questions.

 

Message 13 of 13

chris
Advisor
Advisor

Update, I was able to get the part working without update buttons. I took the time to set equations for each angle so that regardless of dimensional change, the formulas update, and there are no reference dimensions or projected geometry... sort of the long way around, but it works without issues, Thanks for the help everyone!

0 Likes