An Introduction to Autodesk Inventor iLogic - Part Three
Create the Port_A_Rule
There will be quite a bit going on with Port A when we change the
port size. We will need to change the port size, update its iPart
number, change the screw size if required, screw location, and screw
kit part number.
- Let’s add a rule to do this.
- Make sure the manifold block assembly is active, and
click the Add Rule icon.
Name this rule “port_a_rule”.
The first part of this rule will adjust the screw pattern
spacing, based on information stored in the union part’s iPart
table. We can look up the row in use based on the port_a_size
parameter, and then assign values to two different assembly
parameters from two other columns.
i = iPart.FindRow("port_a_union", "port_size", "=",
port_a_size)
port_a_y_dist_between_screws =
iPart.CurrentRowValue("y_dist_betwn_screw")
port_a_x_dist_between_screws =
iPart.CurrentRowValue("x_dist_betwn_screw")
The iPart-related statements used above can be found on
the iParts category under the Rule Syntax tab.
The next part of the rule will select the appropriate
iPart row inside the screw part based on the selected port size.
In this section, we use a series of “if” statements to set the
appropriate iPart member (“Screw-01”, etc.), according to the
current value of the “port_a_size” parameter.
If
port_a_size = .50
Then
iPart.ChangeRow("port_a_union_screw",
"Screw-01")
ElseIf
port_a_size = 0.75
Then
iPart.ChangeRow("port_a_union_screw", "Screw-02")
ElseIf
port_a_size = 1.00
Then
iPart.ChangeRow("port_a_union_screw",
"Screw-02")
ElseIf
port_a_size = 1.25
Then
iPart.ChangeRow("port_a_union_screw", "Screw-03")
ElseIf
port_a_size = 1.50
Then
iPart.ChangeRow("port_a_union_screw",
"Screw-04")
ElseIf
port_a_size = 2.00
Then
iPart.ChangeRow("port_a_union_screw", "Screw-04")
ElseIf
port_a_size = 2.50
Then
iPart.ChangeRow("port_a_union_screw",
"Screw-05")
ElseIf
port_a_size = 3.00
Then
iPart.ChangeRow("port_a_union_screw", "Screw-06")
End If
The last part of this rule for Port A will get the part
number for the flare flange and store it in an assembly
parameter, where we will use it in another rule later on.
port_a_union_part_number = iProperties.Value("port_a_union",
"Project", "Part Number")
Before you continue, save the file.