what is the correct way to write this iLogic?

what is the correct way to write this iLogic?

chris
Advisor Advisor
971 Views
12 Replies
Message 1 of 13

what is the correct way to write this iLogic?

chris
Advisor
Advisor

I'm trying to write an iLogic rule for an angle constraint that has a slider in the Form, that says if "X" option is chosen then the angle  can only be between 20º and 179º, but if the option is "Y", then the angle can be any number between 181º and 340º (below is what I tried)

 

If Handrail_Style = "Straight" Then
Parameter("L2A") = 180
Parameter("L3A") = 180
Else If Handrail_Style = "L Shape" Then
Parameter("L2A") = <=20  And  >=179
Parameter("L3A") = 180
Else If Handrail_Style = "C Shape" Then
Parameter("L2A") = <=20  And  >=179
Parameter("L3A") = <= 20 And >= 179
Else If Handrail_Style = "S Shape" Then
Parameter("L2A") = <=20  And  >=179
Parameter("L3A") = <=181 And >=340
End If
iLogicVb.UpdateWhenDone = True
InventorVb.DocumentUpdate()
0 Likes
Accepted solutions (1)
972 Views
12 Replies
Replies (12)
Message 2 of 13

WCrihfield
Mentor
Mentor

Maybe like this?

If Handrail_Style = "Straight" Then
	Parameter("L2A") = 180
	Parameter("L3A") = 180
ElseIf Handrail_Style = "L Shape" Then
	If Parameter("L2A") < 20 Then
		Parameter("L2A") = 20
	ElseIf Parameter("L2A") > 179 Then
		Parameter("L2A") = 179
	End If
	Parameter("L3A") = 180
ElseIf Handrail_Style = "C Shape" Then
	If Parameter("L2A") < 20 Then
		Parameter("L2A") = 20
	ElseIf Parameter("L2A") > 179 Then
		Parameter("L2A") = 179
	End If
	If Parameter("L3A") < 20 Then
		Parameter("L3A") = 20
	ElseIf Parameter("L3A") > 179 Then
		Parameter("L3A") = 179
	End If
ElseIf Handrail_Style = "S Shape" Then
	If Parameter("L2A") < 20 Then
		Parameter("L2A") = 20
	ElseIf Parameter("L2A") > 179 Then
		Parameter("L2A") = 179
	End If
	If Parameter("L3A") < 181 Then
		Parameter("L3A") = 181
	ElseIf Parameter("L3A") > 340 Then
		Parameter("L3A") = 340
	End If
End If
iLogicVb.UpdateWhenDone = True
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

EESignature

(Not an Autodesk Employee)

0 Likes
Message 3 of 13

chris
Advisor
Advisor

@WCrihfield This sort of worked... let me simplify it, Osha says the maximum distance between vertical rails in a handrail is 72". I'm trying to write a rul that says something like this:

 

If the total handrail Length is less than or equal to the Osha Max imum vertical distance, then suppress the vertical rails, (as they are not needed), but if the handrail length is "greater than" the Osha maximum distance, then show the vertical rails.

 

Handrail Length = SL

Osha Max Vertical Distance = Osha_V_Off

Vertical Rail = SV

Vertical Rail Pattern = SV_Pat

 

below is what I tried... it suppresses the rails, but doesn't all ow them to show, even if the "SL" is a larger number than the "Osha_V_Off"

 

If SL = Osha_V_Off Then
	Feature.IsActive("SV") = False
	Feature.IsActive("Rectangular Pattern14") = False
	Else If SL > Osha_V_Off Then
	Feature.IsActive("SV") = False
	Feature.IsActive("Rectangular Pattern14") = False
Else If SL < Osha_V_Off Then
	Feature.IsActive("SV") = True
	Feature.IsActive("Rectangular Pattern14") = True
	End If
iLogicVb.UpdateWhenDone = True
InventorVb.DocumentUpdate()

 

 

btw, I'm having the hardest time understanding how the equal to / greater than/less than operators should be listed or written... I'm writing them the way i would say them, but nothing seems to work? 

0 Likes
Message 4 of 13

A.Acheson
Mentor
Mentor

The Else If vs ElseIf could be at play here. See stackoverflow description of Else If vs ElseIf

It should be written ElseIf. Also check if your parameters are what they should be with a message box. Updating of parameters during processing can be troublesome. 

 

If SL = Osha_V_Off Then
	Feature.IsActive("SV") = False
	Feature.IsActive("Rectangular Pattern14") = False
ElseIf SL > Osha_V_Off Then Feature.IsActive("SV") = False Feature.IsActive("Rectangular Pattern14") = False ElseIf SL < Osha_V_Off Then Feature.IsActive("SV") = True Feature.IsActive("Rectangular Pattern14") = True End If iLogicVb.UpdateWhenDone = True InventorVb.DocumentUpdate()

 

 

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

chris
Advisor
Advisor

@A.Acheson thanks for the try, it suppresses the feature and pattern, but it doesn't do anything on the "greater than" portion, so it's still not working. All the tutorials I've watched on this only show people making a=B and then having a message pop up that says Yes or no... but what I haven't seen is any tutorial where they use it to drive another dimension or as I'm trying to do, suppress a feature(s)

0 Likes
Message 6 of 13

A.Acheson
Mentor
Mentor

Hi @chris 

Does the logic itself work with a message box to say your in the elseif? If you are then it could be an issue with the feature control themselves. 

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 13

WCrihfield
Mentor
Mentor

Hi @chris.  They can be a little confusing at first if you have not yet used them that much in that many scenarios.  You can see the available options in the iLogic Rule editor dialog, under the 'Operators' drop-down.  When combining a single < or > with a =, the equal sign is always the second symbol (<= or >=).  When using the <= symbols together between two values, the statement will evaluate to True if the value on the left side of those 2 operators is less than or equal to the value on the right of those operators.  And when using the >= operators between two values, the statement will evaluate to True if the value to the left of those operators is greater than or equal to the value to the right of those operators.

Also keep in mind that when controlling suppression by code, they need to be done in propper order, or they may throw errors, or cause other problems.  For instance, you should suppress the component pattern before suppressing the component that the pattern is based uppon.  And you should unsuppress the component that the pattern us based upon, before unsuppressing the component pattern that is based on that component.  And just in general suppress the later created features that are dependant on earlier created features before suppressing the earlier created features that have other features dependant on them.  Then unsuppress the earlier features first, before unsuppressing the features that are depentant on the earlier features.  That means not simply using the same ordered list of stuff on both sides of an argument that is controlling suppression.

WCrihfield_0-1686137258998.png

 

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 8 of 13

Curtis_Waguespack
Consultant
Consultant
Accepted solution

Hi @chris 

 

I think you can reduce this all to two lines.

 

Feature.IsActive("SV") = (SL >= Osha_V_Off)
Feature.IsActive("Rectangular Pattern14") = (SL >= Osha_V_Off)

 

the Feature.IsActive function returns either true or false

 

the equation ( SL >= Osha_V_Off) also returns either true or false

 

so you can set these to together with an equal sign such as this:

 

Feature.IsActive("SV") = (SL >= Osha_V_Off)

 

so that the feature's active status is always whatever (SL >= Osha_V_Off) evaluates as.

 

so when Osha_V_Off is a constant of 72

 

if SL = 50, then (SL >= Osha_V_Off)  returns FALSE because 50 is not greater or equal to 72

if SL = 72, then (SL >= Osha_V_Off)  returns TRUE because 72 is equal to 72

if SL = 80, then (SL >= Osha_V_Off)  returns TRUE because 80 is greater than 72

 

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

EESignature

0 Likes
Message 9 of 13

chris
Advisor
Advisor

@Curtis_Waguespack That worked perfectly! Thank you, after seeing what you wrote, I have to say it differently in my head and consider writing things differently!

Message 10 of 13

chris
Advisor
Advisor

@Curtis_Waguespack On a side note, I have another part of this handrail design that I can control with the "limits" within the form setting a min and max angle, but is there a way to set the limits of a dimension within a range but also leaving a specific number out?

 

Example: I have a dimension "L2A" which controls the handrail angle, I have the limits set to be between 20º and 340º, but I want to "exclude" 180º. It would be nice if the limits wizard in iLogic would allow for "exclusions", but it only offers min/max

0 Likes
Message 11 of 13

Curtis_Waguespack
Consultant
Consultant

Hi @chris,

 

I can't think of better way than this, but I think this should work.

 

If L2A < 20 Then
	L2A = 20
ElseIf L2A > 340 Then
	L2A = 340
ElseIf L2A = 180 Then
	L2A = 179
End If

 

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

 

EESignature

Message 12 of 13

WCrihfield
Mentor
Mentor

That's a tough one.  I'm thinking another rule a bit similar to the first one may be needed to help control something like that.  Below is a simple example that could likely be used if you want it to work silently in the background.

oVal = Parameter("L2A")
If oVal < 20 Then
	oVal = 20
ElseIf oVal > 340 Then
	oVal = 340
ElseIf oVal = 180 Then
	oVal = 179 'or 181
End If
If Parameter("L2A") <> oVal Then Parameter("L2A") = oVal

or you could just use something like a warning message, that doesn't actually try to control its value, like this.

oVal = Parameter("L2A")
If oVal < 20 Or oVal = 180 Or oVal > 340 Then
	MessageBox.Show("The Value of 'L2A' must be between 20 & 340, but not 180", "Parameter Out Of Limits", _
	MessageBoxButtons.OK, MessageBoxIcon.Warning)
End If

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 13 of 13

chris
Advisor
Advisor

@WCrihfield @Curtis_Waguespack Okay, I will try each of these... believe it or not, it would appear that a simple (well not so simple), handrail design has broken Inventor, lol 😞