iLogic code to check dimensions

iLogic code to check dimensions

jfenter
Enthusiast Enthusiast
785 Views
3 Replies
Message 1 of 4

iLogic code to check dimensions

jfenter
Enthusiast
Enthusiast

I'm trying to write a code to check reference dimensions in an ipt.  These dimensions should only be checked if specific features are active.  The dimensions would be checked against a minimum limit.  An over-simplified code would be something like this:

 

checkDim = 230

If Feature.IsActive("Feature1") = True And Feature.IsActive("Feature2") = False Then
	'Check Left Dimension
	If d01 < checkDim Then
		MessageBox.Show("Dimension too small", "Error")
		
	'Check Right Dimension
	ElseIf d02 < checkDim Then
		MessageBox.Show("Dimension too small", "Error")
	End If
	
ElseIf Feature.IsActive("Feature1") = True And Feature.IsActive("Feature2") = True Then
	'Check Left Dimension
	If d01 < checkDim Then
		MessageBox.Show("Dimension too small", "Error")
	End If
	
	'Check Right Dimension
	If d03 < checkDim Then
		MessageBox.Show("Dimension too small", "Error")
	End If
	
	'Check Center Dimension
	If d04 < checkDim Then
		MessageBox.Show("Dimension too small", "Error")
	End If
	
End If 

Writing the code this way seems to cause the rule to run multiple times and the message box pops up 4 times every time the rule runs.  I'm sure there's an easier way, but I can't figure it out.  Any help would be appreciated!

0 Likes
786 Views
3 Replies
Replies (3)
Message 2 of 4

Sergio.D.Suárez
Mentor
Mentor

Hi, I am not very clear about what you are trying to do, I have modified your code so that when any action is carried out, the dialog box only appears once, not four times.

 

Sub main ()
checkDim = 230

If Feature.IsActive("Feature1") = True And Feature.IsActive("Feature2") = False Then
	'Check Left Dimension
	If d01 < checkDim Then
		MessageBox.Show("Dimension too small", "Error")
		Exit Sub
	'Check Right Dimension
	ElseIf d02 < checkDim Then
		MessageBox.Show("Dimension too small", "Error")
		Exit Sub
	End If
	
ElseIf Feature.IsActive("Feature1") = True And Feature.IsActive("Feature2") = True Then
	'Check Left Dimension
	If d01 < checkDim Then
		MessageBox.Show("Dimension too small", "Error")
		Exit Sub
	End If
	
	'Check Right Dimension
	If d03 < checkDim Then
		MessageBox.Show("Dimension too small", "Error")
		Exit sub
	End If
	
	'Check Center Dimension
	If d04 < checkDim Then
		MessageBox.Show("Dimension too small", "Error")
Exit sub End If End If End Sub

 I hope it is useful for you


Please accept as solution and give likes if applicable.

I am attaching my Upwork profile for specific queries.

Sergio Daniel Suarez
Mechanical Designer

| Upwork Profile | LinkedIn

0 Likes
Message 3 of 4

jfenter
Enthusiast
Enthusiast

Unfortunately that didn't work.


The part I am working on is a fairly complicated part that is being configured in different ways.  There are two internal components that are activated through another iLogic rule.  These extrusions are named InnerRail1 and InnerRail2.  These rails can vary in width from 44mm to 100mm and have a placement limit of 325mm on center due to machine limitations.  However, there is also a limit of 230mm in the void between the rails in a subsequent operation.  I have these dimensioned as reference dimensions hc_01, hc_01a, hc_02 and hc_03.

In the picture below,

hc_01 = 264mm on the left

hc_02 = 264mm on the right

hc_03 = 506mm in the center

hc_01a = 814mm on the upper right

lwp1.PNG

 

If the inner rail features increase in width to 80mm or more, the open area dimensioned by hc_01 and hc_02 on the left and right will be less than 230mm even though the position of those features still meets the limit of their placement at 325mm.

Furthermore, if the overall length of the part decreases to a point that the open area between the two inner features becomes less than 230mm (dimensioned as hc_03), this also causes an error in production.

 

My intention with the iLogic code is to check each of those reference dimensions (hc_01, hc_01a, hc_02 and hc_03) against the open area limit of 230mm.  The features are toggled on and off as the final part is configured, so innerRail1 and innerRail2 may or may not be active.  When the features are not active, the dimensions don't need to be checked.

 

So, when Feature.IsActive("innerRail1"), the only dimensions that need checked against the checkValue of 230 are hc_01 and hc_01a.

 

When Feature.IsActive("innerRail1) AND Feature.IsActive("innerRail2"), dimensions needing checked are hc_01, hc_02 and hc_03.

 

I'm not sure if what I'm trying to do is even possible, but it seems that it should be.

 

 

 

0 Likes
Message 4 of 4

Sergio.D.Suárez
Mentor
Mentor

Hi, I do not know if you interpret well, I understood that you want to activate the rule if feature1 or feature2 are active either, or both.
that you have 3 main dimensions to check hc_01, hc_02, hc_03 and that you do not want to be less than 230.
if any of them when the rule is activated is less than 230, you want the poster to come out only once.
A possible solution (surely there can be some better one)
Add three strings in "nothing" so that if you find an error try to capture all the errors in a complete cache.
Then apply the rule to whether one operation or the other is active.
if it finds an error it will create the dialog box and show it only once, then it will exit the subroutine.

Sub main()
Dim checkDim As Double = 230
Dim Check1 As String = ""
Dim Check2 As String = ""
Dim Check3 As String = ""

If Feature.IsActive("Feature1") = True Or Feature.IsActive("Feature2") = True Then
	If hc_01 < checkDim Then Check1 = "*Dimension hc_01 too small" 'Check Left Dimension
	If hc_02 < checkDim Then Check2 = "*Dimension hc_02 too small" 'Check Right Dimension	
	If hc_03 < checkDim Then Check3 = "*Dimension hc_03 too small" 'Check Center Dimension
		
	If hc_01 < checkDim Then 
		MessageBox.Show(Check1 & vbCrLf & Check2 & vbCrLf & Check3, "Error") 
		Exit Sub
	End If
	If hc_02 < checkDim Then 
		MessageBox.Show(Check1 & vbCrLf & Check2 & vbCrLf & Check3, "Error") 
		Exit Sub
	End If
	If hc_03 < checkDim Then 
		MessageBox.Show(Check1 & vbCrLf & Check2 & vbCrLf & Check3, "Error") 
		Exit Sub
	End If	
End If 

End sub

 I hope it will be useful and you can solve your problem, regards


Please accept as solution and give likes if applicable.

I am attaching my Upwork profile for specific queries.

Sergio Daniel Suarez
Mechanical Designer

| Upwork Profile | LinkedIn

0 Likes