How to take precedence in my rule and form?

How to take precedence in my rule and form?

ikilic1461
Enthusiast Enthusiast
362 Views
3 Replies
Message 1 of 4

How to take precedence in my rule and form?

ikilic1461
Enthusiast
Enthusiast

Hi all;

I have a lifting bollard with standart capacities , most of dimensions change according to capacity , including "Q , D, F"  inputs from the rule. 

But I want to put a private option here , if I click private "Yes"  , I want take precedence "Q , D, F" inputs from the form. If I do private selection "No" it will take dimensions from as in the Rule's if statements. 

You will see my whole rule below, I tried to add case options but I am not so much experienced with that , probably I need to do something better or professional. 

 

I also added my model here , I am working Inventor 2021 . 

 

If you help me in this issue I would be grateful, thanks in advance . 

 

@Sergio.D.Suárez 

 

ikilic1461_2-1723035328710.png

 

 

	
Dim oDoc As AssemblyDocument

    oDoc = ThisApplication.ActiveDocument

    Dim oDef As AssemblyComponentDefinition

    oDef = oDoc.ComponentDefinition

    ' Get the top level occurrence of an assembly

    Dim oOcc1 As ComponentOccurrence
    oOcc1 = oDef.Occurrences.Item(1)  'Master component occurrence
    Dim oOccA As String
    oOccA = oOcc1.Name  'Name Master component
	
	    Dim oOcc4 As ComponentOccurrence
    oOcc4 = oDef.Occurrences.Item(4)  'Back plate
    Dim oOccD As String
    oOccD = oOcc4.Name  'Back plate
	

	
	MultiValue.SetList("Capacity", "010T", "020T", "035T", "050T", "065T", "075T", "090T", "100T", "110T", "125T")
	MultiValue.SetList("Private", "No", "Yes")
	
Parameter(oOccA, "A_")=A_
Parameter(oOccA, "B_")=B_
Parameter(oOccA, "C_")=C_
Parameter(oOccA, "D_")=D_
Parameter(oOccA, "E_")=E_
Parameter(oOccA, "F_")=F_
Parameter(oOccA, "G_")=G_
Parameter(oOccA, "H_")=H_
Parameter(oOccA, "J_")=J_
Parameter(oOccA, "K_")=K_
Parameter(oOccA, "L_")=L_
Parameter(oOccA, "N_")=N_
Parameter(oOccA, "M_")=M_
Parameter(oOccA, "Q_")=Q_
Parameter(oOccA, "Lk")=Lk
Parameter(oOccA, "Flange_Depth")=Flange_Depth
Parameter(oOccA, "Flange_Thk")=Flange_Thk
Parameter(oOccA, "Wall_Thk") = Wall_Thk
Parameter(oOccA, "Gap") = Gap
Parameter(oOccA, "d16") = Z

	Select Case Private 
		
	Case "Yes"
		Q_ = Q_
		D_ = D_
		F_ = F_
		
	Case "No"
		Dim Q_ As String
		Dim D_ As String
		Dim F_ As String
		
	End Select


If Capacity = "010T" Then
A_ = 114.3 
B_ = 10 
C_ = 75
D_ = 8
E_ = 0.01
F_ = 300
G_ = 140
H_ = 180
J_ = 260
K_ = 0.01
L_ = 130
N_ = 10
M_ = 0.01
Q_ = 140
Component.Visible(oOccD) = False
End If

If Capacity = "020T" Then
A_ = 168.3 
B_ = 12.5 
C_ = 80
D_ = 8
E_ = 0.01
F_ = 300
G_ = 200
H_ = 260
J_ = 290
K_ = 0.01
L_ = 130
N_ = 10
M_ = 0.01
Q_ = 140
Component.Visible(oOccD) = False
End If

If Capacity = "035T" Then
A_ = 219.1
B_ = 16 
C_ = 90
D_ = 12
E_ = 0.01
F_ = 300
G_ = 240
H_ = 310
J_ = 310
K_ = 0.01
L_ = 130
N_ = 16
M_ = 0.01
Q_ = 170
Component.Visible(oOccD) = False
End If

If Capacity = "050T" Then
A_ = 229
B_ = 25 
C_ = 100
D_ = 20
E_ = 0.01
F_ = 340
G_ = 250
H_ = 370
J_ = 320
K_ = 0.01
L_ = 130
N_ = 16
M_ = 0.01
Q_ = 170
Component.Visible(oOccD) = False
End If

If Capacity = "065T" Then
A_ = 244.5
B_ = 30 
C_ = 105
D_ = 20
E_ = 20
F_ = 400
G_ = 270
H_ = 380
J_ = 340
K_ = 330
L_ = 140
N_ = 16
M_ = 1340
Q_ = 170
Component.Visible(oOccD) = True
End If
	
If Capacity = "075T" Then
A_ = 273
B_ = 30 
C_ = 115
D_ = 20
E_ = 20
F_ = 420
G_ = 300
H_ = 410
J_ = 350
K_ = 350
L_ = 140
N_ = 16
M_ = 1350
Q_ = 200
Component.Visible(oOccD) = True
End If

If Capacity = "090T" Then
A_ = 323.9
B_ = 30 
C_ = 115
D_ = 20
E_ = 20
F_ = 500
G_ = 360
H_ = 470
J_ = 380
K_ = 430
L_ = 140
N_ = 20
M_ = 1380
Q_ = 210
Component.Visible(oOccD) = True
End If

If Capacity = "100T" Then
A_ = 355.6
B_ = 30 
C_ = 130
D_ = 20
E_ = 20
F_ = 530
G_ = 380
H_ = 500
J_ = 400
K_ = 460
L_ = 140
N_ = 20
M_ = 1600
Q_ = 220
Component.Visible(oOccD) = True
End If

If Capacity = "110T" Then
A_ = 368
B_ = 30 
C_ = 130
D_ = 20
E_ = 20
F_ = 550
G_ = 400
H_ = 540
J_ = 400
K_ = 480
L_ = 140
N_ = 20
M_ = 1600
Q_ = 240
Component.Visible(oOccD) = True
End If

If Capacity = "125T" Then
A_ = 457
B_ = 30 
C_ = 130
D_ = 25
E_ = 25
F_ = 600
G_ = 480
H_ = 620
J_ = 450
K_ = 520
L_ = 140
N_ = 20
M_ = 1600
Q_ = 230
Component.Visible(oOccD) = True
End If



If (Q_ - 2 * D_) < (Flange_Depth - Gap - Wall_Thk - 10)
   Z = (Flange_Depth - Gap - Wall_Thk) -(Q_ - 2 * D_)
Else
	Z = 10
End If



If U_Beam_Width < 100
  U_Beam_Width = 100
  MessageBox.Show("The minimum value allowed for this parameter is:  " & U_Beam_Width & vbCr & "The value will be automatically corrected to the minimum.", "Minimum Value Rule", MessageBoxButtons.OK, MessageBoxIcon.Error)
ElseIf U_Beam_Width > 500 Then
  U_Beam_Width = 500
  MessageBox.Show("The maximum value allowed for this parameter is: " & U_Beam_Width & vbCr & "The value will be automatically corrected to the maximum.", "Maximum Value Rule", MessageBoxButtons.OK, MessageBoxIcon.Error)
End If


If U_Beam_Depth < 100
  U_Beam_Depth = 100
  MessageBox.Show("The minimum value allowed for this parameter is:  " & U_Beam_Depth & vbCr & "The value will be automatically corrected to the minimum.", "Minimum Value Rule", MessageBoxButtons.OK, MessageBoxIcon.Error)
ElseIf U_Beam_Depth > 400 Then
  U_Beam_Depth = 400
  MessageBox.Show("The maximum value allowed for this parameter is: " & U_Beam_Depth & vbCr & "The value will be automatically corrected to the maximum.", "Maximum Value Rule", MessageBoxButtons.OK, MessageBoxIcon.Error)
End If

If Lk < 1000
  Lk = 1000
  MessageBox.Show("The minimum value allowed for this parameter is:  " & Lk & vbCr & "The value will be automatically corrected to the minimum.", "Minimum Value Rule", MessageBoxButtons.OK, MessageBoxIcon.Error)
ElseIf Lk > 5000 Then
  Lk = 5000
  MessageBox.Show("The maximum value allowed for this parameter is: " & Lk & vbCr & "The value will be automatically corrected to the maximum.", "Maximum Value Rule", MessageBoxButtons.OK, MessageBoxIcon.Error)
End If

RuleParametersOutput()
iLogicVb.RunRule("U-Beam")
InventorVb.DocumentUpdate(True)

 

 

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

J_Pfeifer_
Advocate
Advocate

Try something like the following out: 

 

	
	
		
			
			
	
	
Case select Capacity
	
	Case "010T"
	
		A_ = 114.3 
		B_ = 10 
		C_ = 75
		D_ = 8
		E_ = 0.01
		F_ = 300
		G_ = 140
		H_ = 180
		J_ = 260
		K_ = 0.01
		L_ = 130
		N_ = 10
		M_ = 0.01
		Q_ = 140
		
	Case "020T"
	
		A_ = 168.3 
		B_ = 12.5 
		C_ = 80
		D_ = 8
		E_ = 0.01
		F_ = 300
		G_ = 200
		H_ = 260
		J_ = 290
		K_ = 0.01
		L_ = 130
		N_ = 10
		M_ = 0.01
		Q_ = 140
		
	Case "035T"
	
		A_ = 219.1
		B_ = 16 
		C_ = 90
		D_ = 12
		E_ = 0.01
		F_ = 300
		G_ = 240
		H_ = 310
		J_ = 310
		K_ = 0.01
		L_ = 130
		N_ = 16
		M_ = 0.01
		Q_ = 170
		
	Case "050T"
	
		A_ = 229
		B_ = 25 
		C_ = 100
		D_ = 20
		E_ = 0.01
		F_ = 340
		G_ = 250
		H_ = 370
		J_ = 320
		K_ = 0.01
		L_ = 130
		N_ = 16
		M_ = 0.01
		Q_ = 170
		
	Case "065T"
	
		A_ = 244.5
		B_ = 30 
		C_ = 105
		D_ = 20
		E_ = 20
		F_ = 400
		G_ = 270
		H_ = 380
		J_ = 340
		K_ = 330
		L_ = 140
		N_ = 16
		M_ = 1340
		Q_ = 170
		
	Case "075T"
	
		A_ = 273
		B_ = 30 
		C_ = 115
		D_ = 20
		E_ = 20
		F_ = 420
		G_ = 300
		H_ = 410
		J_ = 350
		K_ = 350
		L_ = 140
		N_ = 16
		M_ = 1350
		Q_ = 200
		
	Case "090T"
	
		A_ = 323.9
		B_ = 30 
		C_ = 115
		D_ = 20
		E_ = 20
		F_ = 500
		G_ = 360
		H_ = 470
		J_ = 380
		K_ = 430
		L_ = 140
		N_ = 20
		M_ = 1380
		Q_ = 210
		
	Case "100T"
	
		A_ = 355.6
		B_ = 30 
		C_ = 130
		D_ = 20
		E_ = 20
		F_ = 530
		G_ = 380
		H_ = 500
		J_ = 400
		K_ = 460
		L_ = 140
		N_ = 20
		M_ = 1600
		Q_ = 220
		
	Case "110T"
	
		A_ = 368
		B_ = 30 
		C_ = 130
		D_ = 20
		E_ = 20
		F_ = 550
		G_ = 400
		H_ = 540
		J_ = 400
		K_ = 480
		L_ = 140
		N_ = 20
		M_ = 1600
		Q_ = 240
		
	Case "125T"
	
		A_ = 457
		B_ = 30 
		C_ = 130
		D_ = 25
		E_ = 25
		F_ = 600
		G_ = 480
		H_ = 620
		J_ = 450
		K_ = 520
		L_ = 140
		N_ = 20
		M_ = 1600
		Q_ = 230
	Case else 
		Messagebox.show("No selection that matches capacity found, please check the value and try again.")
End select
	
	
	Component.Visible(oOccD) = True 'This could be placed into the if statement if its something turned off and on depending on the Private need. Otherwise we only need it to run once, not each time a case selection is made.  
	
	
	'Putting the if statement after this case will set the Q_, D_, and F_ values before it hits this point. Once here if false, if can then set them to different values. 
	'Placing the If before adds complexity. Here we know the variables are loaded correctly, unless we need to make a change to them. 
	If Private = true then 
	
		Q_ = Q_
		D_ = D_
		F_ = F_
	
	Else if Private = false
	
				'The below items are just showing options you have for selection. 
		Dim Q_ As String = Inputbox("")
		Dim D_ As String = Something_Inside_FX parameters 
		Dim F_ As String = variable or set "string value"
	
	End if 
	
	
	
	
	
	
	

 

 

Note, I changed the private to a Boolean. This could be maintained as a string with true/false as well. When changing parameters I place those parameters into the case statement. Then finally, you want to make a selection option after the fact to whether or not you plan to use the loaded values or not. The program runs top to bottom, you can load then over write values in a variable. With this being the case, set them first then attempt to change them based off an if statement. 

0 Likes
Message 3 of 4

ikilic1461
Enthusiast
Enthusiast

Hi  @J_Pfeifer_ , thanks for your  feedback .

I  copied the codes which you wrote. It seems something wrong , I got error in rule. 

By the way , I only need to make some changes in the given capacity ,

for example in standard 50T Q=170 , F=340 , D=20 , if I click private "yes" , I can change any of these 3 inputs 

i.e,  Q=190 , F=360 , D=20 

ikilic1461_0-1723100964532.png

 

 

0 Likes
Message 4 of 4

ikilic1461
Enthusiast
Enthusiast
Accepted solution

So , I solved the problem .

We needed to write if Private = "Yes" Then  , instead of  if Private=  True 

Many thanks again.

 

0 Likes