If Parameter("WALLTHICKNESS") <6 And Parameter("FORMED") = "COLD" Parameter("CORNERRAD") =2*Parameter("WALLTHICKNESS") ElseIf Parameter("WALLTHICKNESS") <6 And Parameter("FORMED")= "HOT" Then Parameter("CORNERRAD") =1.2*Parameter("WALLTHICKNESS") End If If Parameter("WALLTHICKNESS")<=10 And Parameter("FORMED")= "COLD" Then Parameter("CORNERRAD")=2.5*Parameter("WALLTHICKNESS") ElseIf Parameter("WALLTHICKNESS")<=10 And Parameter("FORMED")= "HOT" Then Parameter("CORNERRAD")=1.5*Parameter("WALLTHICKNESS") End If If Parameter("WALLTHICKNESS")>10 And Parameter("FORMED")= "COLD" Then Parameter("CORNERRAD")=3*Parameter("WALLTHICKNESS") ElseIf Parameter("WALLTHICKNESS")>10 And Parameter("FORMED")= "HOT" Then Parameter("CORNERRAD")=2*Parameter("WALLTHICKNESS") End If
Can anybody please take alook at this piece of code and tell me why this does not work properly. It's basically driving the corner rads on box section profiles based on the wall thickness. It does change on an update but then reverts back to the original afetr another update!
Parameter Formed is a multi value user parameter with two options, HOT or COLD. the box section is controlled via a form.
Anybody's help will be greatly appreciated thanks.
Solved! Go to Solution.
Soemtimes you can't see the wood for the trees but it doesn't solve the original problem I'm afraid.
It still changes the rads based on the FORMED parameter but only after an update then always needs another update which then changes them back!
There is an issue with your logic. If the value is less then 6 CORNERRAD will be set to the (2.5 or 1.5) * WALLTHICKNESS. Because WALLTHICKNESS is less than 6 AND 10. Anything less then 6 will still have the less then or equal to 10 value applied since <= 10 is the last comparison that was true.
Here's an alternative logic structure so it only selects one set of values to set.
w = Parameter("WALLTHICKNESS") f = Parameter("FORMED") If f = "COLD" Then If w > 10 Then Parameter("CORNERRAD") = 3 * w Else If >= 6 Then Parameter("CORNERRAD") = 2.5 * w Else Parameter("CORNERRAD") = 2 * w End Else If f = "HOT" Then 'This could just be Else If w > 10 Then Parameter("CORNERRAD") = 2 * w Else If >= 6 Then Parameter("CORNERRAD") = 1.5 * w Else Parameter("CORNERRAD") = 1.2 * w End End If
Also is the code that runs this rule called from another rule. If using the Parameter("") syntax forms, and any rules that may just use the parameter name you have to be careful of when rules are run and the order they run in. Some will execute automatically and other won't. Just using the parameter name will get the value at the beginning but may not apply the value until the rule finishes. The Parameter("") form applies the value immediately to the parameter but you need to explicitly run the rule.
Ok thanks to both of you but I have found a way around this and it works fine.
Appreciate you taking the time to help though.
If WALLTHICKNESS <=6 And FORMED = "COLD" Then CORNERRAD =2* WALLTHICKNESS ElseIf WALLTHICKNESS<=10 And FORMED = "COLD" Then CORNERRAD =2.5* WALLTHICKNESS ElseIf WALLTHICKNESS >10 And FORMED = "COLD" Then CORNERRAD=3* WALLTHICKNESS End If If FORMED = "HOT" Then CORNERRAD=1.5* WALLTHICKNESS
Anybody looking in is probably horrified at my lack of knowledge but it does just what I'm after.
Can't find what you're looking for? Ask the community or share your knowledge.