The iLogic functionality within Autodesk Inventor enables designers and engineers to create rules that drive model geometry, parameters, and behavior, all from a user-friendly interface utilizing VB.NET code.
iLogic rules are created and organized using built-in snippets and other code statements to run functionality within a part’s file, assembly, or drawing. The scope of what can be achieved with iLogic is immense: complete model configurations can be created using rules that define the shape, size, suppression or unsuppression of features, material type, and more. iLogic can also be used for drawing layouts and assembly nomenclature. iLogic rules can be run internally and manually inside a file, externally from the file, or configurations can be driven from iLogic forms or triggers in the file.
iLogic’s core purpose and functionality is to provide a level of automation and intelligence to digital CAD models, enabling engineers to readily generate configurations. It resides within the core Inventor product, out of the box, and does not require additional purchases or installation.
In terms of incorporating intelligence into designs, there is a progression of solutions in terms of levels of complexity:
In this chapter, we will focus on the third level, iLogic. You must have a good understanding of the functionalities outlined in levels 1 and 2 before proceeding with this chapter, as knowledge and experience in practical terms with these functionalities is essential for understanding and utilizing iLogic.
iLogic may seem a little intimidating to readers who have no experience in coding, but this need not be the case. The iLogic environment and use of snippets (ready-made pieces of code) make using iLogic out-of-the-box simple, and no previous coding experience is required.
In this chapter, we will cover the following topics:
To complete this chapter, you will need access to the practice files in the Chapter 10 folder within the Inventor Cookbook 2023 folder. It is important that you have a good understanding of equations, parameters, iFeatures, iParts, and iAssemblies before proceeding. You can find information on these topics in Chapter 3, Driving Automation and Parametric Modeling in Inventor.
In this recipe, you will learn how to operate and utilize an existing iLogic assembly of a ladder. You will become familiar with the iLogic browser and how you can access and edit rules to construct models. You will also make changes to the assembly using the predefined iLogic form.
iLogic itself is a large topic, but this chapter aims to introduce readers to the core functionalities. Here are some common areas where iLogic is utilized:
As with most features and functionality in Inventor, there is a recommended workflow. For iLogic, this is as follows:
As iLogic rules mainly run from existing equations and parameters defined during the creation of the model, it is very important that from the outset, the model has been properly defined at all stages, and there are no unresolved parts, mates, or missing geometry/undefined sketches. The base model must be solid before progressing with the implementation of iLogic rules.
It is also advisable to have set goals and objectives of what you want your end part or configuration to be. Mapping out the options prior to starting will make the process of applying iLogic code much easier.
Creating the rules is done in the iLogic environment of Inventor. A single rule or multiple rules can be defined, and there is no limit to the number of rules that can be applied. A single rule can in fact run multiple operations. Rules can be contained within the relevant file or externally, and at any point, rules can also be edited. Conditional statements such as the following form the basics of most iLogic rules:
If (Something) = True Then (Do Something) Else (Do Something Else) End If
What makes iLogic easy to configure is that Inventor already has a library of snippets – pre-defined VB.NET code statements that can be applied and edited to define the rules. You can of course create your own from scratch.
When editing the rules, the model may have to be flexed and tested with the rule to ensure that it is working to the desired outcome.
Within Inventor, there are two types of iLogic rules, internal and external. Both are created within the context of Inventor, inside the iLogic browser. Internal rules are rules that are created and stored within the context of a file. External rules are not stored within Inventor files, but in a local or networked directory.
Internal rules are accessible to users that have permission to access those files. External rules have an added level of security in that they are stored in a directory either locally on a user system or centrally on a server. It is up to you to decide which type of rule you wish to create, depending on the objective.
Navigate to Inventor Cookbook 2023 | Chapter 10|iLogic Access Ladder.
To start the recipe, we will open the model and observe the predefined form that appears:
Figure 10.1: Access Ladder assembly open with the iLogic form to the right
Upon opening the file in Inventor, you will see the model displayed in the default state at the Origin. You will also notice that an iLogic form is visible and open. This iLogic form has been created to control the two internal iLogic rules within the file so that you can configure the Access Ladder.iam file efficiently without editing the VB.NET code of the rules.
In this example, you can either adjust the HEIGHT or MOUNT POSITION of the access ladder.
Figure 10.2: SIDE MOUNT selected on the iLogic form
Once SIDE MOUNT is selected, the assembly updates automatically to display a side mounting plate.
Figure 10.3: Updated iLogic form and assembly
Figure 10.4: iLogic browser selected
Figure 10.5: Edit Rule menu open for CAT LADDER RULE #1
Figure 10.6: Edit Rule menu areas
This is what each menu area in Figure 10.6 means:
Look closely at the start of the code in Figure 10.7. We will now break down what the code means and how it is driving the model.
Figure 10.7: Close-up of the code we will examine
The first three lines of code define how certain parameters will work:
Parameter("CATL-SIDE PLATE #1:1", "CATH")=CATLL Parameter("CATL-SIDE PLATE #1:1", "AMOUNTR")=Ceil((Parameter("CATL-SIDE PLATE #1:1", "CATH")+32.5)/275) Parameter("CATL-SIDE PLATE #1:1", "SPACINGR")=Parameter("CATL-SIDE PLATE #1:1", "CATH")/Parameter("CATL-SIDE PLATE #1:1", "AMOUNTR")
These sections define how the ladder rungs are placed in terms of the number and spacing.
Next are End If/Else If statements, which define how these parameters should behave, depending on the critical CATLL value (which is the ladder’s height) entered in the iLogic form:
If (CATLL)<=1800 Then Component.Visible("Component Pattern 2:1")=False Component.Visible("Component Pattern 3:1")=False Component.Visible("CATL-ROUND CAGE #1:1")=False Component.Visible("CATL-ROUND CAGE #1:3")=False
This states that if the value of CATLL (the ladder height) is less than 1800mm, then the following features are to be suppressed, and this includes the round protective cage. This is what we demonstrated in step 3 when we defined LADDER HEIGHT as 1500mm in the iLogic form.
The next portion of the code states that if the value of LADDER HEIGHT is set to <2492.5, then create the cage but only with the values and spacings shown here:
ElseIf (CATLL)<=2492.5 Then AMOUNTC = 1 SPACINGC = (CATLL-2092.5) Component.Visible("Component Pattern 2:1")=True Component.Visible("Component Pattern 3:1")=True Component.Visible("CATL-ROUND CAGE #1:1")=True Component.Visible("CATL-ROUND CAGE #1:3")=True Parameter("CATL-CAGE BAR #1:1", "BARL")= (SPACINGC*AMOUNTC)+1092.5
The next parts of the preceding code starting with Component.Visible are to calculate the size of the round cage section as the height of the ladder increases.
This next section of code defines how the side or top mounting plates are visible; it relates to the drop-down menu in the iLogic form, defining which components are visible or suppressed:
If BASE1 = "TOP MOUNT " Then Component.Visible("CATL-CONN PLATE #1:1")= True Component.Visible("CATL-CONN PLATE #1:2")= True Component.Visible("CATL-CONN PLATE #2:1")= False Component.Visible("CATL-CONN PLATE #2:2")= False End If If BASE1 = "SIDE MOUNT" Then Component.Visible("CATL-CONN PLATE #1:1")=False Component.Visible("CATL-CONN PLATE #1:2")=False Component.Visible("CATL-CONN PLATE #2:1")=True Component.Visible("CATL-CONN PLATE #2:2")=True
The final section of code sets a limit to the configuration in that if a value for LADDER HEIGHT in the iLogic form is set to <18,000, then the model displays a working error message "TOO BIG, LOWER LADDER HEIGHT", "ERROR":
If (CATLL)>18000 Then MessageBox.Show("TOO BIG, LOWER LADDER HEIGHT", "ERROR") End If
This communicates to the user that a lower value must be entered to proceed and compute.
Figure 10.8: ERROR message displayed
The rule is executed as soon as the value is higher than 18,000, displaying the warning message.
Scroll down the code until you reach the section shown in Figure 10.9 and select where the arrow is pointing. This is where the cursor will then deploy, and we will write new functionality within the rule.
Figure 10.9: Section in the rule where we will write new code
Figure 10.10: If…Then…End If statement added to the code
Figure 10.11: Component.Color snippet added to the code
We now need to repeat this for all other components we want to follow this rule. Add additional lines of code as follows. You can view the components in the model in the Model and File Tree area of the Edit Rule menu, shown as section A in Figure 10.6.
Type the following code into the iLogic Rule, or use copy and paste from CAT LADDER #1 iLOGIC RULE COMPLETE.txt in the iLogic AccessLadder folder:
If (CATLL) >3092.5 Then Component.Color("CATL-SIDE PLATE #1:1") = "Cyan" Component.Color("CATL-SIDE PLATE #1:2") = "Cyan" Component.Color("CATL-ROUND BAR #1:1") = "Cyan" Component.Color("CATL-ROUND BAR #1:2") = "Cyan" Component.Color("Component Pattern 1:1") = "Cyan" Component.Color("CATL-ROUND BAR #1:1") = "Cyan" Component.Color("CATL-ROUND BAR #1:2") = "Cyan" Component.Color("CATL-ROUND CAGE #1:1") = "Cyan" Component.Color("CATL-ROUND CAGE #1:3") = "Cyan" Component.Color("Component Pattern 2:1") = "Cyan" Component.Color("Component Pattern 3:1") = "Cyan" Component.Color("CATL-CONN PLATE #1:1") = "Cyan" Component.Color("CATL-CONN PLATE #1:2") = "Cyan" Component.Color("CATL-CONN PLATE #1:3") = "Cyan" Component.Color("CATL-CONN PLATE #1:4") = "Cyan" Component.Color("CATL-CONN PLATE #2:1") = "Cyan" Component.Color("CATL-CONN PLATE #2:2") = "Cyan" End If
In the iLogic form, change CATLADDER HEIGHT to 2200 and hit Enter. The model updates correctly in terms of geometry, but the color for all components is left as cyan. Our rule stated that this should only occur if the value of CATLADDER HEIGHT is greater than 3092.5. This is because we are lacking an Else If statement in our code. We need to define all possible scenarios so that if the value is not greater than 3092.5, then the color should be Canary.
Else
Component.Color("CATL-SIDE PLATE #1:1") = "Canary"
Component.Color("CATL-SIDE PLATE #1:2") = "Canary"
Component.Color("CATL-ROUND BAR #1:1") = "Canary"
Component.Color("CATL-ROUND BAR #1:2") = "Canary"
Component.Color("Component Pattern 1:1") = "Canary"
Component.Color("CATL-ROUND BAR #1:1") = "Canary"
Component.Color("CATL-ROUND BAR #1:2") = "Canary"
Component.Color("CATL-ROUND CAGE #1:1") = "Canary"
Component.Color("CATL-ROUND CAGE #1:3") = "Canary"
Component.Color("Component Pattern 2:1") = "Canary"
Component.Color("Component Pattern 3:1") = "Canary"
Component.Color("CATL-CONN PLATE #1:1") = "Canary"
Component.Color("CATL-CONN PLATE #1:2") = "Canary"
Component.Color("CATL-CONN PLATE #1:3") = "Canary"
Component.Color("CATL-CONN PLATE #1:4") = "Canary"
Component.Color("CATL-CONN PLATE #2:1") = "Canary"
Component.Color("CATL-CONN PLATE #2:2") = "Canary"
End If
This informs Inventor that if the value is less than 3092.5 in the iLogic form, then the Component Color of all components must be set to Canary.
Once your code matches that of the preceding .txt file, select Save & Run. Close the Edit Rule menu. The assembly should update with all components canary in color. In the iLogic form, set CATLADDER HEIGHT to 3100 and hit Enter. The model geometry updates and the color is changed back to cyan.
You have configured an iLogic model using an iLogic form to drive an Inventor assembly with more than one iLogic rule. You have also edited one of the rules to add additional functionality using snippets, and If Then/End If conditional statements, to drive a global color change across all components in the assembly, depending on user input of one of the parameters through the iLogic form.
In this recipe, the objective is to take an existing support bracket design with existing parameters and equations defined and create a new iLogic rule with multiple functions that can generate three different design variants: Heavy, Regular, and Light. The rule will be run through a custom user-defined multi-value parameter.
To start the recipe, we will open the model and examine the existing equations and parameters that have been set. We will also establish the design criteria for the finished parts and what the final configurations will look like.
To begin this recipe, you will need to navigate to Inventor Cookbook 2023 | Chapter 10 | iLogic Support Bracket and open Support Bracket.ipt:
The bracket is displayed in its default regular arrangement. 3D annotations are visible in the Graphics window to illustrate the changes in dimensions. In Figure 10.12, you can see the three design variants (Light, Regular, and Heavy) that we will generate from the iLogic rule that we will create.
Figure 10.12: Final configurations of each support bracket generated by the iLogic Rule: Light, Regular, and Heavy
Looking at the existing equations, you can see that the height value is of great importance and is featured throughout many of the equations. It is this primary dimension that drives most of the parameters and thus the behavior in the model.
Figure 10.13: Parameters and equations in the model
Now we will create a user-defined parameter that will enable us to choose between Light, Regular, and Heavy variants of the bracket. This user-defined parameter is what we will reference in the iLogic rule that we will create.
Figure 10.14: User-defined parameter BracketType created and Make Multi-Value selected
The multi-value options defined in the preceding step are added to the user-defined custom parameter: BracketType.
Figure 10.15: Multi-value options for BracketType added
Figure 10.16: Add rule
Before starting the rule, we will outline our objective and design requirements as comments first. Comments are non-actionable pieces of code that enable you to communicate information in iLogic rules. It is good practice to do this because in the future, if further edits are required, you will be able to get a good understanding of the purpose of the rule without needing to read through the whole code. Comments are also helpful for structuring your iLogic code. Neat and tidy code is good code!
'An iLogic Rule To define 3 Variants of the Support
Bracket .ipt
'Light, Regular and Heavy BracketType
'Regular
'Light
'Heavy
'Regular =
'Height Of 60
'Rib Active
'Material Thickness Of 2 mm
'Additional Support Holes Inactive On rounded plate
'SB-001-Regualar Serial Number Stamped
'Light =
'Height Of 50
'Rib Inactive
'Material Thickness Of 1.5 mm
'Additional Support Holes Inactive On rounded plate
'SB-002-Light Serial Number Stamped
'Hole Height On back plate lowered 10mm
'Heavy =
'Height Of 70
'Rib Active
'Rib Fillet Active
'Rib Thickness 5mm
'Material Thickness Of 4 mm
'Additional Support Holes Active On rounded plate
'SB-003-Heavy Serial Number Stamped
'Hole Height On back plate lowered 10mm
Figure 10.17: Comment out the selected lines
'Regular Bracket Config
If BracketType = "Regular" Then
Height = 60
Thickness = 2
' Rib and Hole feature controls:
Feature.IsActive("Rib") = True
Feature.IsActive("Hole3") = False
Feature.IsActive("Mirror1") = False
Feature.IsActive("Hole2") = True
Feature.IsActive("Rectangular Pattern1") = True
Feature.IsActive("Rectangular Pattern2") = True
HoleHeight = 10
' Serial Number:
Feature.IsActive("SB001Regular")=True
Let’s break down the code. The following segment of code states that if the part is set to Regular, then the Height must be 60 and the Thickness of the material must be 2 mm:
If BracketType = "Regular" Then Height = 60 Thickness = 2
The following segment controls what features are to remain active or inactive at the selection of the Regular variant:
Rib and Hole feature controls: Feature.IsActive("Rib") = True Feature.IsActive("Hole3") = False Feature.IsActive("Mirror1") = False Feature.IsActive("Hole2") = True Feature.IsActive("Rectangular Pattern1") = True Feature.IsActive("Rectangular Pattern2") = True HoleHeight = 10
This mainly controls the size and positioning of the central rib and hole features.
The final section enables the correct serial number to be displayed on the bracket:
Serial Number: Feature.IsActive("SB001Regular")=True
Light Bracket Config:
Else If BracketType = "Light" Then
Height = 50
Thickness = 1.5
' Rib and Hole feature controls:
Feature.IsActive("Rib") = False
Feature.IsActive("Hole3") = False
Feature.IsActive("Mirror1") = False
Feature.IsActive("Hole2") = True
Feature.IsActive("Rectangular Pattern1") = True
Feature.IsActive("Rectangular Pattern2") = True
HoleHeight = 20
' Serial Number:
Feature.IsActive("SB001Regular") = False
Feature.IsActive("SB002Light")=True
'Heavy Bracket Config
Else If BracketType = "Heavy" Then
Height = 70
Thickness = 4
' Rib and Hole feature controls:
Feature.IsActive("Rib") = True
Feature.IsActive("Hole3") = True
Feature.IsActive("Mirror1") = True
Feature.IsActive("Hole2") = True
Feature.IsActive("Rectangular Pattern1") = True
Feature.IsActive("Rectangular Pattern2") = True
Feature.IsActive("RibFillet") = True
HoleHeight = 10
d39 = 5
' Rib Thickness change:
RibThickness = 5
' Serial Number:
Feature.IsActive("SB001Regular") = False
Feature.IsActive("SB002Light") = False
Feature.IsActive("SB003Heavy") = True
End If
We have now defined all the code required for the iLogic rule and created the custom user-defined parameter to create the three configurations of the bracket automatically. Check that the iLogic code you have written is identical to that found in the following document: support bracket.docx located in the iLogic Support Bracket folder.
You have successfully created a new iLogic rule with multiple functions that is driven by a user-defined, multi-value parameter within the model and creates three different design configurations of a support bracket.
iLogic rules can also be referenced in a top-level assembly or new rules can be created at this level. In this recipe, you will both reference existing part-level iLogic rules and create new iLogic rules in a top-level assembly to control the configurations of a lamp assembly.
The rule you will create will allow the user to automatically configure the lamp in Inventor in terms of the following aspects: lamp height, lamp length, sleeve color, base shape type, and part numbering.
An example of one of the configurations is shown in Figure 10.18, with labels that correlate to the features and references we will be using as part of the iLogic rule.
Figure 10.18: Lamp with references to things that will change in the rule to be created in the assembly
To begin this recipe, you will need to navigate to Inventor Cookbook 2023, then select the Chapter 10 folder, followed by the iLogic Lamp folder. Then open iLogic Lamp.iam.
To start the recipe, we will open the model and understand the iLogic rules that have been created and how these influence the model. You will also need to familiarize yourself with the table shown in Figure 10.19, as this details all the configurations of the lamp that our new iLogic rule will control, from the assembly.
Figure 10.19: Configurations of the lamp that the iLogic rule will generate
Now that we understand all the configuration requirements, we can now start to create the iLogic code to generate these by following these steps:
Figure 10.20: Three iLogic rules in lamp:1.ipt
Figure 10.21: Edit Rule window for the BaseType rule open, with User Parameters selected
Looking at the iLogic code, this rule controls the shape of the base of the lamp, by either activating or deactivating an extruded cut that is part of Extrusion5. A conditional If Then, End If statement controls this with a True or False option.
The SleeveType iLogic rule controls the color of the sleeve that partially covers the vertical stand of the lamp. If the parameter in the model is changed to Black, for example, then the color of the Sleeve is also set to black. There are three options within this rule: Black, Blue, and Cork.
Figure 10.22: Edit Rule for SleeveType open, with User Parameters selected
The LampHeight iLogic rule controls the height of the extrusion, which defines the lamp’s height (the dimension name that controls lamp height is d6) and sets the exact value this must be when either Long, Medium, or Small is selected.
Figure 10.23: Edit Rule window for LampHeight open, with User Parameters selected
The LampLength iLogic rule controls the length of the extrusion, which defines the lamp’s length (this is dimension d4) and sets the exact value this must be when either Long, Medium, or Small is selected.
Figure 10.24: Edit Rule window for LampLength open, with User Parameters selected
Figure 10.25: LampConfig user parameter created
Long Circle Black
Long Circle Blue
Long Circle Cork
Medium Circle Black
Medium Circle Blue
Medium Circle Cork
Small Circle Black
Small Circle Blue
Small Circle Cork
Long Square Black
Long Square Blue
Long Square Cork
Medium Square Black
Medium Square Blue
Medium Square Cork
Small Square Black
Small Square Blue
Small Square Cork
We now need to write a rule to reference this parameter.
We now have to write iLogic code for every configuration we wish to generate from the pre-defined user parameter list. We will reference the existing rules at the part level of this assembly.
If LampConfig = "Long Circle Black" Then
This identifies the rule in our assembly that if Long Circle Black is selected from the dropdown, then... do something.
Figure 10.26: Parameter(“lamp:1”, “LampHeight”) = “Long” added
This rule now states that if LampConfig is set to Long Circle Black, change LampHeight to the value stated in the LampHeight rule, that is, = Long.
Parameter("lamp:1", "SleeveType") = "Black"
Parameter("lamp:1", "BaseType") = "Circle"
Parameter("lamp_pt2:1", "LampLength") = "Long"
iProperties.Value("Project", "Part Number") =
"LongCircleBlack"
The result of this is displayed in Figure 10.27.
Figure 10.27: Completed code for LampConfig= Long Circle Black
The last line of code added changes Part Number in the iProperties of the assembly to the text shown automatically when the rule runs.
This code must now be duplicated and edited to reflect all the other possible configurations in the LampConfig dropdown.
Figure 10.28: Completed iLogic assembly; LampConfig options selected for ‘Medium Square Cork’
Using iLogic rules defined in the top level of an assembly, you have created a rule that references multiple existing iLogic rules at the part level to produce automatic configurations of a lamp that enable the user to define the base type, height, length, and color, and set automatic part numbers in the iProperties.
iLogic forms represent the simplest way for users to generate configurations of models, and they provide an easy-to-use interface to do so. In this recipe, you will create an iLogic form that opens upon the action of an iTrigger. The iLogic form will allow the user to customize a mounting plate, based on predefined iLogic rules and parameters in the model.
To begin this recipe, you will need to navigate to Inventor Cookbook 2023 folder, then select Chapter 10. Select the iLogic Form folder and then Mounting Plate.ipt.
The model has already been created, and there are already two iLogic rules, which are as follows:
You will now start the configuration of an iLogic form to make the configuration of material and plate sizing of this much easier:
Figure 10.29: iLogic Form Editor open
Figure 10.30: Label changed to Mounting Plate Configuration
Figure 10.31: Picture element dragged to Form Workspace
Figure 10.32: The iLogic Form Editor with the Image Browser command show.
Figure 10.33: Mounting Plate image now incorporated into the iLogic Form Preview
Figure 10.34: Tab Groups added and renamed
Figure 10.35: Parameters dragged into the correct Tab Group folder
The preview of the form will have updated, reflecting these changes.
Figure 10.36: PlateSizing renamed to Mounting Plate Type & Sizing in the iLogic form
Form Preview will automatically update to reflect the change.
Figure 10.37: OK Cancel Apply selected as additional buttons in the iLogic form
Figure 10.38: iLogic form launched and tested
Figure 10.39: iLogic iTrigger command
Figure 10.40: iTrigger0 added to User Parameters
Figure 10.41: Adding code for the iTrigger
Figure 10.42: Material Selection rule added to Material Change Event Trigger
You have created an iLogic form with multiple functions and rules that enables the configuration of a mounting plate part. iTriggers have been set to launch the form upon the document opening, and Event Triggers have been configured to maintain the correct material selection.
The model credits for this chapter are as follows:
3.134.78.106