In the next several lessons, you create a series of rules to manage the contents of the assembly.
This model includes a part named manifold_block:1, which has iLogic rules in it. We must pass the assembly level parameter to the part.
This rule sets parameters in the part based on the corresponding values of the control parameters in the assembly. Our Parameter function specifies the component name as well as the parameter name.
Parameter("manifold_block:1", "block") = block Parameter("manifold_block:1", "component_type") = component_type Parameter("manifold_block:1", "port_a_size") = port_a_size Parameter("manifold_block:1", "port_b_size") = port_b_size Parameter("manifold_block:1", "port_c_size") = port_c_size
In the Manifold Block Part tutorial, we added a rule to the manifold block part that controls the tee and elbow styles. We must also add it at the assembly level. Rather than rewrite the existing rule, we copy the original.
If component_type = "standard" Then port_b_size = port_a_size port_c_size = port_a_size End If
When we change the port size of Port A, we must perform several tasks:
We add a rule to do it:
The first part of this rule adjusts the screw pattern spacing, based on information stored iPart table of the union part.
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 next part of the rule selects the appropriate iPart row inside the screw part based on the selected port size.
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
port_a_union_part_number = iProperties.Value("port_a_union", "Project", "Part Number")
Port B is different from Port A and Port C, because it does not exist in an elbow manifold block. If the manifold block is an elbow style block, we must suppress the union cap and the union screws used for this port. We must also suppress the mate constraints associated with the union cap.
Because we are suppressing components, we set a level of detail before we write the rule. Rules affecting items related to the level of detail in an assembly require that a custom level of detail be defined and saved before writing the rules. If the custom level of detail is not defined, iLogic generates an error message.
Set a Level of Detail
A new level of detail is added.
Write the Rule
Now, we can write the rule.
If block = "elbow" Then isTee = False ElseisTee = True End If
We use this variable later to set other parameters.
Constraint.IsActive("port_b_cap_center") = isTee Constraint.IsActive("port_b_cap_hole") = isTee Constraint.IsActive("port_b_cap_face") = isTee Constraint.IsActive("port_b_cap_screw") = isTee
Note that we can use the isTee variable to turn these constraints on or off according to the value of the block parameter.
Component.IsActive("port_b_union") = isTee Component.IsActive("port_b_screw_pattern") = isTee
These lines use the isTee variable. When the screw pattern is suppressed, the screw component is also suppressed.
if isTee Then i = iPart.FindRow("port_b_union", "port_size", "=", port_b_size) port_b_y_dist_between_screws = iPart.CurrentRowValue("y_dist_betwn_screw") port_b_x_dist_between_screws = iPart.CurrentRowValue("x_dist_betwn_screw") port_b_union_part_number = iProperties.Value("port_b_union", "Project", "Part Number") End If
We enclosed this entire block in an If isTee statement, so that these lines are only processed for a tee-style manifold block. The statement If isTee Then is equivalent to If isTee = True Then, but it provides a more concise expression format.
We first choose the appropriate row in the s iPart table of the union part, corresponding to the value of the port_b_size parameter, and then extract the values to use for the x and y pattern offsets. Then, we extract the Part Number from the union part, and store its value in another parameter for later reference.
If port_b_size = .50 then iPart.ChangeRow("port_b_union_screw", "Screw-01") elseif port_b_size = .75 then iPart.ChangeRow("port_b_union_screw", "Screw-02") elseif port_b_size = 1.00 then iPart.ChangeRow("port_b_union_screw", "Screw-02") elseif port_b_size = 1.25 then iPart.ChangeRow("port_b_union_screw", "Screw-03") elseif port_b_size = 1.50 then iPart.ChangeRow("port_b_union_screw", "Screw-04") elseif port_b_size = 2.00 then iPart.ChangeRow("port_b_union_screw", "Screw-04") elseif port_b_size = 2.50 then iPart.ChangeRow("port_b_union_screw", "Screw-05") elseif port_b_size = 3.00 then iPart.ChangeRow("port_b_union_screw", "Screw-06") End If
The rule for Port C is almost the same as for Port A, except that everything referencing Port A must reference Port C instead.
i = iPart.FindRow("port_c_union", "port_size", "=", port_c_size) port_c_y_dist_between_screws = iPart.CurrentRowValue("y_dist_betwn_screw") port_c_x_dist_between_screws = iPart.CurrentRowValue("x_dist_betwn_screw") If port_c_size = .50 then iPart.ChangeRow("port_c_union_screw", "Screw-01") elseif port_c_size = .75 then iPart.ChangeRow("port_c_union_screw", "Screw-02") elseif port_c_size = 1.00 then iPart.ChangeRow("port_c_union_screw", "Screw-02") elseif port_c_size = 1.25 then iPart.ChangeRow("port_c_union_screw", "Screw-03") elseif port_c_size = 1.50 then iPart.ChangeRow("port_c_union_screw", "Screw-04") elseif port_c_size = 2.00 then iPart.ChangeRow("port_c_union_screw" "Screw-04") elseif port_c_size = 2.50 then iPart.ChangeRow("port_c_union_screw", "Screw-05") elseif port_c_size = 3.00 then iPart.ChangeRow("port_c_union_screw", "Screw-06") End If port_c_union_part_number = iProperties.Value("port_c_union", "Project", "Part Number")