The iLogic Browser lists iLogic rules, forms, global forms and external rules.
In the iLogic Browser, rules are arranged under two tabs:
Forms are arranged under two tabs:
A rule is a small Visual Basic (VB.NET) program that can monitor and control other Inventor parameters, features, or components.
iLogic embeds rules as objects directly into part, assembly, and drawing documents. The rules determine and drive the design parameter and attribute values. By controlling these values, you can define the behavior of model attributes, features, and components.
Knowledge is saved and stored directly in the documents, like the way in which geometric design elements are stored.
You can use standard Inventor parameter names in rules as Visual Basic variables. When you run the rule, the value of the parameter is assigned to the variable. For a numeric parameter, the value is a real number expressed in the document units specified in Tools Document Settings. Text parameters become String variables in the rule. True/false parameters become Boolean variables.
Parameters can appear in two different ways:
When a rule starts running, iLogic reads the values for these parameters from the model into the rule. When the rule has finished running, iLogic saves the changed values back to the model.
To save the values before the rule has finished running, use the RuleParametersOutput function. This function is useful if you want to change the model immediately.
When you assign values using this method, the values are saved to the model immediately, before the next line in the rule runs. When you read a value using the Parameter function, it is immediately read from the Inventor model.
Before you use one of the following Autodesk Inventor entity names in a rule, change its name if it was assigned a default name when it was created:
Use a meaningful name. The name change makes it easier to see what the rule is doing.
Another reason to change default names is to make them more portable. In localized versions of Autodesk Inventor, default item names are translated to the language of that version. The names are automatically changed in the model browser, but not in an iLogic rule. Therefore, the rule may be unable to find items using the default name. If someone else uses the model in a different language version of Inventor, the default names must be changed. This recommendation applies only to items that are called out by name in the rule. For example, the Measure functions can use work feature names. If you have work features, but you do not use them in Measure functions, then you do not have to rename them.One exception to this recommendation is embedded Excel spreadsheets. Do not rename them.
On non-English versions of Autodesk Inventor, use an English name in the rule. For example:
"3rd Party:Embedding 1"
Rules usually run automatically in response to changes in parameter values, if the parameters are used directly as variables in the rule. You can also trigger rules by events.
A rule runs immediately after you edit it, unless it is suppressed. When rules run, changes in the parameters do not update the model until after the rule runs. If necessary, you can force parameter changes to take effect immediately using either:
When you create or edit a rule, the rule text is converted into valid VB.NET code and then compiled. Some Inventor parameter names are not valid as VB.NET variable names. To allow for the full range of Inventor parameter names, iLogic internally substitutes new variable names for the Inventor parameters.
Although you can use Visual Basic keywords as parameter names, it is not recommended for new documents. However, when you add rules to existing documents, you usually do not have to change any parameter names. If a name is the same as a keyword, and you require that keyword in the rule, you can:
Rule text is converted internally to valid VB.NET code, which is not visible and is stored with the rule. This type of storage eliminates the need for iLogic to generate the code whenever the rule is run. The code only changes when you edit the rule.
The VB compiler error messages actually refer to this intermediate code. In rare cases with some complex code, you can receive an error that does not correspond to the rule code. When this situation occurs, simplify your code. If necessary, verify that you have a Sub Main() and End Sub statement.
When iLogic converts the rule to valid VB.NET code for compilation, it replaces units with conversion factors.
You can use Inventor units in rules in the same manner as they are used in standard Inventor parameter equations.
In this example, a part file uses document units of inches:
d0 = 4.5 in d18 = 7.2 in sum = d0 + d18MessageBox.Show(sum,”Document Units - Inches”)
Unless otherwise specified, iLogic assumes the units of the numbers are defined as the document units. In this case, the sum equals 11.7. A message box displays the value and indicates that the document units are expressed in inches.
To assign a value of 7.2 mm to the parameter d18, instead of 7.2 in, specify that d18 is expressed in millimeters:
d0 = 4.5 in d18 = 7.2 mm sum = d0 + d18 MessageBox.Show(sum,”Document Units - Inches”)
In this case, the sum equals 4.78346456692913. A message box displays the value and indicates that the Document Units are expressed in inches
To perform the previous calculation for a part file with document units expressed in millimeters, include the inch unit for any parameter expressed in inches (such as d0 = 4.5 in).
Finally, if you omit the unit of length from a statement, iLogic uses the Document Units value.
In this example, a part file uses document units of inches. In the iLogic Parameter Editor:
A rule has been written as:
result = x + y MessageBox.Show(result,“Mixed Units Defined in Parameter Editor”)
When performing the addition, iLogic converts the value of parameter y from 12.5 mm to .4921 inches. A message box displays the value of 1.49212598425197 and indicates that mixed units are defined in the Parameter Editor.
Conversely, if the document units are defined as millimeters, then iLogic converts the value of parameter x from 1 in to 25.4 mm. A message box displays the value of 37.9 and indicates that mixed units are defined in the Parameter Editor.
The unit specification is applied before any other mathematical operation is performed and has precedence over all other operators. Unit names:
The following are examples of valid use of unit names:
12 in 144 in 144 in^2 125.2 mm 60 mi/hr
You can use compound unit specifications in rules. Compound unit specifications follow the Inventor format. To incorporate a complicated unit specification into a rule, create an equation for it in the Parameters dialog box. Then, use Capture Current State on that parameter in the Rule Editor.
External rules can be used as iLogic rules, or as small programs that you run manually (like VBA macros). They are stored in text or VB files, outside of any Inventor document (part, assembly, or drawing). You can run them manually or from other rules.
When you view the list of external rules in the iLogic Browser, the list is the same for whatever document you have open. It is not tied to each individual document.
You can also run external rules as event-driven rules.
iLogic provides several wizards you can use to create sophisticated rules for certain tasks. These wizards are available on the Wizards tab of the Edit Rule dialog box:
Create and connect a custom user interface to the parameters, properties, and rules of an Inventor part, assembly or drawing document.
Use drag and drop methods to design a user interface with no need for programming. Use the controls to drive changes to an existing design. Form definitions can be document specific and saved with a design document or stored for use across multiple documents.