With the necessary parameters in place, we can now add logic to the model using rules. Rules can be defined for various actions, including setting the values of parameters and activating or suppressing features. Our first rule suppresses a feature on a part.
The Edit Rule dialog box is the heart of the iLogic functionality. You use this dialog box to create and edit iLogic rules.
To see other sets of parameters, you can click the User Parameters node in the model tree to display only the manually created parameters.
You write rules in the rule text area, which is located in the bottom panel of the Edit Rule dialog box. You can enter Rule keywords by typing them directly into the text entry field. Or, you can select generic statements from the toolbar above the field and then edit the statements.
This tutorial describes entering the statements manually, unless otherwise indicated.
The bracket model includes two holes: one in the base, and one on the flange.
(1) flange hole (2) base hole
Our new rule turns on (or off) the base hole, the flange hole, or both. In a previous lesson, we created a multi-value parameter named holes. We assigned three values to this parameter labeled base, flange and none. The rule turns on the flange hole when flange value is selected. Choosing base turns on the base hole, and a value of none turns off both holes
Now we can create the rule. We begin with the flange setting of the holes parameter.
Notice that the text of the If keyword turns bold and red. The red color indicates a recognized language element (in this case a keyword).
Notice that the different colors are applied automatically to the different language elements of the expression defined so far. This color coding makes rules much easier to read, and it helps you quickly comprehend their meaning, and identify any information entered incorrectly.
We can make the flange hole active by using an iLogic function.
(1) Highlight generic text. (2) Double-click name to replace highlighted text.
The Feature.IsActive function sets the activity state (suppression state) of a feature specified in quotation marks inside the parentheses.
Assigning a value of True indicates that the flange hole is active (unsuppressed). When the flange option is chosen for the holes parameter, we want only the flange hole active. We must include a command that deactivates the base hole.
These two lines turn on the flange hole and turn off the base hole. Your rule now consists of three lines.
If holes = "flange" Then Feature.IsActive("flange_hole") = True Feature.IsActive("base_hole") = False
For instances in which the base hole must be activated, a similar strategy is employed. We must activate the base hole and deactivate the flange hole.
To create the next part of the rule, you copy and paste the reusable portion of the previous statements. Then change the pasted text as required.
If holes= ”flange” Then Feature.IsActive(“flange_hole”) = True Feature.IsActive(“base_hole") = False ElseIf holes = “base” Then Feature.IsActive(“flange_hole”) = False Feature.IsActive(“base_hole”) = True
The rule is complete.
If holes = "flange" Then Feature.IsActive("flange_hole") = True Feature.IsActive("base_hole") = False ElseIf holes = "base" Then Feature.IsActive("flange_hole") = False Feature.IsActive("base_hole") = True ElseIf holes = "none" Then Feature.IsActive("flange_hole") = False Feature.IsActive("base_hole") = False End If
If there are no mistakes, the dialog box closes without an error message. An icon representing the new rule appears in the Rule Browser.
The Rule Browser provides a way for you to see the rules in the current model. We explore the Rule Browser further later in this tutorial.
The rule we created requires a more descriptive name.