# iLogic Tutorial From Autodesk – 16

## Calculating Part Numbers

Two final pieces of information we need to determine for our model is the part numbers to use for the union screws and elbows. To do this, we’ll need to create some additional rules in our assembly.

## Screw Part Number Rule

The first part of this rule will calculate a part number to be used for the Port A screw, based on the value of the port_a_size parameter. In this rule, we introduce a new statement – Select Case – which can be used to execute one of a group of statements, depending on the value of an expression.

Create a new rule named “screw_part_number_rule”. You can use the Keywords box on the Rule Syntax tab to assist you in filling in this rule.

Select Case port_a_size
Case .50
Screw_num1 = 050
Case .75
Screw_num1 = 075
Case 1.00
Screw_num1 = 100
Case 1.25
Screw_num1 = 125
Case 1.50
Screw_num1 = 150
Case 2.00
Screw_num1 = 200
Case 2.50
Screw_num1 = 250
Case 3.00
Screw_num1 = 300
End Select
port_a_screw_part_number = “UNBRAKO-“ & Screw_num1 & “-SCREW”

In this rule, we first compute a variable portion of the part number, based on the port_a_size parameter value. We hold this in a temporary placeholder variable named “Screw_num1”. After that, we construct the entire part number string, which will look (for example) like this (for port_a_size = 0.50):

UNBRAKO-050-SCREW

We save this value in a parameter for later reference.

We need to do something similar for the Port B and C screws. To do this, copy and paste the rule text created above, and then replace “port_a_size” with “port_b_size” and “port_c_size”, respectively, and set the parameters “port_b_screw_part_number” and “port_c_screw_part_number”. This will result in the following additional rule text.

Select Case port_b_size
Case .50
Screw_num1 = 050
Case .75
Screw_num1 = 075
Case 1.00
Screw_num1 = 100
Case 1.25
Screw_num1 = 125
Case 1.50
Screw_num1 = 150
Case 2.00
Screw_num1 = 200
Case 2.50
Screw_num1 = 250
Case 3.00
Screw_num1 = 300
End Select
port_a_screw_part_number = “UNBRAKO-“ & Screw_num1 & “-SCREW”

Select Case port_c_size
Case .50
Screw_num1 = 050
Case .75
Screw_num1 = 075
Case 1.00
Screw_num1 = 100
Case 1.25
Screw_num1 = 125
Case 1.50
Screw_num1 = 150
Case 2.00
Screw_num1 = 200
Case 2.50
Screw_num1 = 250
Case 3.00
Screw_num1 = 300
End Select
port_a_screw_part_number = “UNBRAKO-“ & Screw_num1 & “-SCREW”

That’s it — click OK to end the rule.