Define a Model Rule to Control Port Visibility

In the iLogic Basics tutorial, you learned that you can use parameter names from a model as variables in a rule. Also, you can select from lists of available parameters, as well as features and other model entities, for inclusion in a rule.

Now, we define a set of rules that drive the geometry of our model based on the values of the key parameters we defined previously. In this lesson, we construct each rule in segments. The entire text of all the rules can be found at the end of this tutorial.

The first rule makes model changes to the Port B features, based on whether the elbow or tee block is selected. To make this change, suppress or enable the Port B features based on the type of block.

  1. On the ribbon, click Manage tab iLogic panel Add Rule .
  2. Name the rule block_shape_rule, and click OK to display the Edit Rule dialog box.
  3. In the text area, create the first part of your new rule, which defines what happens if the block is a tee-style block.

    Copy Code Block

    If block = “tee” Then
  4. Because all three ports are active in the tee-style block, add the steps to ensure that Port B is enabled. Activate two features in the part.

    Copy Code Block

    Feature.IsActive("Port_B") = True
    Feature.IsActive("Port_B_Threads") = True
    Note: The Feature.IsActive function is available for selection in the Snippets area of the Edit Rule dialog box. Click the System tab, then expand the Features node.

    We have now defined the behavior of our model for a tee block.

  5. To define the model behavior for an elbow block, begin with an ElseIf statement.

    Copy Code Block

    ElseIf block = "elbow" Then
  6. To suppress the Port B features when creating an elbow block, use the features we created for the tee block, but with opposite values.

    Copy Code Block

    Feature.IsActive("Port_B") = False
    Feature.IsActive("Port_B_Threads") = False

    A simple way to add these lines is to copy and paste the text for the tee block behavior. Then change True to False in the new lines.

  7. Complete the If block of your rule with an End If statement.

    That’s it! All the instructions necessary to enable or disable the Port B features based on the type of block being used are included.

  8. Click OK to save the completed rule.

Previous | Next