Calculate Part Numbers

We must determine the part numbers to use for the union screws and elbows. To do this, we create additional rules in our assembly.

The first part of this rule calculates a part number to use for the Port A screw, based on the value of the port_a_size parameter. In this rule, we use a new statement Select Case to execute one of a group of statements. The statements executed depend on the value of an expression.

  1. Add a new rule named screw_part_number_rule.
  2. Create the first section of the rule. This section computes a variable portion of the part number, based on the port_a_size parameter value. The value is held in a temporary variable named Screw_num1. Once the value is determined, the rule constructs the entire part number string. Use the Keywords drop-down menu on the toolbar above the text area to help you fill in this rule.

    Copy Code Block

    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 the rule we have created, if port_a_size = 0.50, the part number is created as -

    UNBRAKO-050-SCREW

    We save this value in a parameter for later reference.

  3. Copy and paste the rule text you created, and then replace port_a_size with port_b_size. Set the parameter to port_b_screw_part_number.

    Copy Code Block

    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_b_screw_part_number = "UNBRAKO-" & Screw_num1 & "-SCREW"
  4. Create another copy of the rule text, and then replace port_a_size with port_c_size. Set the parameter to port_c_screw_part_number.

    Copy Code Block

    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_c_screw_part_number = "UNBRAKO-" & Screw_num1 & "-SCREW"
  5. Click OK to save the rule and close the dialog box.
  6. Save your assembly file.

Previous | Next