IiLogic Select Case with greater than and less than combined

IiLogic Select Case with greater than and less than combined

mark_h_ellis
Participant Participant
695 Views
2 Replies
Message 1 of 3

IiLogic Select Case with greater than and less than combined

mark_h_ellis
Participant
Participant

Hi Everyone

I'm trying to get a Select Case statement to run without producing unexpected results. I already have it to run with multiple IF THEN statements but thought I'd try to use a SELECT CASE statement.

Now as I see it the results are short circuiting so if it sees one side of the case as true it ignores the rest.

I have tried replacing '&' with AND and i end up with an error "Operator 'And' is not defined for types 'Autodesk.iLogic.Interfaces.DoubleForEquals' and 'Boolean'."

I also tried replacing the '&' for a comma to no avail.

CHUTE_TWIST_ANGLE & MITREANGLE1 & MITREANGLE2 are numeric degree parameters in the sketch.

Thought this would be an easy thing to achieve.

Here is the code.

Select CHUTE_TWIST_ANGLE
	Case Is <= MITREANGLE1 
		Parameter("LCP_CHAMFER_A") = 10
		Parameter("LCP_CHAMFER_B") = 10
		Parameter("LCP_CLEAR_C") = 50
		Parameter("LCP_CLEAR_E") = 50
	Case Is > MITREANGLE1 & CHUTE_TWIST_ANGLE <= (90 - MITREANGLE2)
		Parameter("LCP_CHAMFER_A") = 10
		Parameter("LCP_CHAMFER_B") = 10
		Parameter("LCP_CLEAR_C") = Parameter("LCP_CLEAR_C") + 1000
		Parameter("LCP_CLEAR_C") = Parameter("LCP_CLEAR_C") - Parameter("LCP_CLEAR_D") + 50
		Parameter("LCP_CLEAR_E") = 50
	Case Is > (90 - MITREANGLE2)& CHUTE_TWIST_ANGLE <=90 	
		Parameter("LCP_CHAMFER_A") = 10
		Parameter("LCP_CHAMFER_B") = 10
		Parameter("LCP_CLEAR_C") = Parameter("LCP_CLEAR_C") + 1000
		Parameter("LCP_CLEAR_C") = Parameter("LCP_CLEAR_C") - Parameter("LCP_CLEAR_D") + 50
		Parameter("LCP_CLEAR_E") = Parameter("LCP_CLEAR_E") + 1000
		Parameter("LCP_CLEAR_E") = Parameter("LCP_CLEAR_E") - Parameter("LCP_CLEAR_F") + 50	
	Case Is >90 
		MessageBox.Show("The maximum value for 'CHUTE TWIST ANGLE' is 90: " & vbCr & "The value will be automatically corrected.", "Maximum Value Rule", MessageBoxButtons.OK, MessageBoxIcon.Error)
		Parameter("CHUTE_TWIST_ANGLE") = 90	
End Select

 

It will only ever run Case 1 & 2 

0 Likes
Accepted solutions (1)
696 Views
2 Replies
Replies (2)
Message 2 of 3

nmunro
Collaborator
Collaborator
Accepted solution

The & symbol is not valid in VB.Net and thus iLogic. You would need to use the AndAlso statement. Having said that your comparisons need not be so complicated. Here are If Then Else and Select Case examples that are a bit easier to follow and accomplish your goals.

 

If CHUTE_TWIST_ANGLE <= MITREANGLE1 Then
	Parameter("LCP_CHAMFER_A") = 10
	Parameter("LCP_CHAMFER_B") = 10
	Parameter("LCP_CLEAR_C") = 50
	Parameter("LCP_CLEAR_E") = 50
ElseIf CHUTE_TWIST_ANGLE <= (90 - MITREANGLE2) Then  'no need to check > MITTEANGLE1 as it must be to get this far
	Parameter("LCP_CHAMFER_A") = 10
	Parameter("LCP_CHAMFER_B") = 10
	Parameter("LCP_CLEAR_C") = Parameter("LCP_CLEAR_C") + 1000
	Parameter("LCP_CLEAR_C") = Parameter("LCP_CLEAR_C") - Parameter("LCP_CLEAR_D") + 50
	Parameter("LCP_CLEAR_E") = 50
ElseIf CHUTE_TWIST_ANGLE <= 90 Then  'must already be > (90 - MITREANGLE2)
	Parameter("LCP_CHAMFER_A") = 10
	Parameter("LCP_CHAMFER_B") = 10
	Parameter("LCP_CLEAR_C") = Parameter("LCP_CLEAR_C") + 1000
	Parameter("LCP_CLEAR_C") = Parameter("LCP_CLEAR_C") - Parameter("LCP_CLEAR_D") + 50
	Parameter("LCP_CLEAR_E") = Parameter("LCP_CLEAR_E") + 1000
	Parameter("LCP_CLEAR_E") = Parameter("LCP_CLEAR_E") - Parameter("LCP_CLEAR_F") + 50	
Else ' must be > 90
	MessageBox.Show("The maximum value for 'CHUTE TWIST ANGLE' is 90: " & vbCr & "The value will be automatically corrected.", "Maximum Value Rule", MessageBoxButtons.OK, MessageBoxIcon.Error)
	Parameter("CHUTE_TWIST_ANGLE") = 90
End If	


Select CHUTE_TWIST_ANGLE
	Case Is <= MITREANGLE1 
		Parameter("LCP_CHAMFER_A") = 10
		Parameter("LCP_CHAMFER_B") = 10
		Parameter("LCP_CLEAR_C") = 50
		Parameter("LCP_CLEAR_E") = 50
	Case Is <= (90 - MITREANGLE2)
		Parameter("LCP_CHAMFER_A") = 10
		Parameter("LCP_CHAMFER_B") = 10
		Parameter("LCP_CLEAR_C") = Parameter("LCP_CLEAR_C") + 1000
		Parameter("LCP_CLEAR_C") = Parameter("LCP_CLEAR_C") - Parameter("LCP_CLEAR_D") + 50
		Parameter("LCP_CLEAR_E") = 50
	Case Is <=90 	
		Parameter("LCP_CHAMFER_A") = 10
		Parameter("LCP_CHAMFER_B") = 10
		Parameter("LCP_CLEAR_C") = Parameter("LCP_CLEAR_C") + 1000
		Parameter("LCP_CLEAR_C") = Parameter("LCP_CLEAR_C") - Parameter("LCP_CLEAR_D") + 50
		Parameter("LCP_CLEAR_E") = Parameter("LCP_CLEAR_E") + 1000
		Parameter("LCP_CLEAR_E") = Parameter("LCP_CLEAR_E") - Parameter("LCP_CLEAR_F") + 50	
	Case Else 
		MessageBox.Show("The maximum value for 'CHUTE TWIST ANGLE' is 90: " & vbCr & "The value will be automatically corrected.", "Maximum Value Rule", MessageBoxButtons.OK, MessageBoxIcon.Error)
		Parameter("CHUTE_TWIST_ANGLE") = 90	
End Select

        


https://c3mcad.com

0 Likes
Message 3 of 3

mark_h_ellis
Participant
Participant

Thankyou for that that makes easy and understandable sense for me.

0 Likes