I have a parameter that changes by form selection on push parameters, I'm trying to make a rule that when that Parameter changes on a specific part that this attached rule runs and changes a Parameter that drives a sketch
Solved! Go to Solution.
Solved by bbrumfield. Go to Solution.
Hi @bbrumfield. It looks like that code should be formatted a bit more like this:
That first line would only be valid if this code was used in an internal iLogic rule (not in an external rule), and would cause this rule to run automatically whenever the value of that parameter changed.
oTrigger = Slope_Angle
If Parameter("Slope_Angle") = 5 deg Then
Parameter("Driven_Angle") = 95 deg
ElseIf Parameter("Slope_Angle") = 10 deg Then
Parameter("Driven_Angle") = 100 deg
ElseIf Parameter("Slope_Angle") = 15 deg Then
Parameter("Driven_Angle") = 105 deg
ElseIf Parameter("Slope_Angle") = 90 deg Then
Parameter("Driven_Angle") = 90 deg
End If
InventorVb.DocumentUpdate
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
(Not an Autodesk Employee)
Interestingly this works for 5, 10 & 90 deg. A 15 deg slope angle returns a value of 100 deg. rather than 105 deg.
Thank you for your help! I ended up having to use <>
If Parameter("Slope_Angle") >= 4.999 And Parameter("Slope_Angle") <= 5.001 Then
Parameter("Driven_Angle") = 95 deg
ElseIf Parameter("Slope_Angle") >= 9.999 And Parameter("Slope_Angle") <= 10.001 Then
Parameter("Driven_Angle") = 100 deg
ElseIf Parameter("Slope_Angle") >= 14.999 And Parameter("Slope_Angle") <= 15.001 Then
Parameter("Driven_Angle") = 105 deg
ElseIf Parameter("Slope_Angle") >= 89.999 And Parameter("Slope_Angle") <= 90.001 Then
Parameter("Driven_Angle") = 90 deg
End If
Thanks,
Brent
Hi @bbrumfield. I also sometimes encounter odd situations like that when comparing 'expected' parameter values. I believe it has to do with the 'Double' data type. Its value can go all the way out to around 15 decimal places, so if for some odd reason the real value is 1/100,000,000 'th (or smaller) of a unit off, the values will not compare as equal. What I have been doing for a long time now in my own work related codes in situations like that is using the built-in EqualWithinTolerance(a As Double, b As Double, tolerance As Double) As Boolean
That function can be typed directly into an iLogic rule, and it will be recognized, because it is defined within the Autodesk.iLogic.RunTime Namespace, under the LmiMath Class. Those resources are imported/included for us automatically in our iLogic rules. The first 2 'inputs' are the two Double values you want to compare to each other, then the third Double value is a tolerance representing the maximum that the two values can be different from each other. I just use something simple like 0.001 as the tolerance. And since this is a Function, it returns a Boolean value, which indicates whether they were considered equal within the specified tolerance.
Wesley Crihfield
(Not an Autodesk Employee)
Hi @WCrihfield,
Thank you for this I will try writing the next bit of code the way you recommended I often have projects where parameter changes can cause collisions (we make HVAC enclosures) I think I can utilize the below to maintain
pass/fail clearances.
Thank You!
Brent Brumfield
Can't find what you're looking for? Ask the community or share your knowledge.