iLogic Overview

Introduction

Autodesk® Inventor® iLogic (iLogic) enables Rules Driven Design (RDD), giving manufacturers a simple way to capture and reuse their engineering knowledge to standardize and automate design processes and/or configure their virtual products.

By using RDD, manufacturers can introduce new ways to capture design intent that reaches beyond what can be achieved with existing parametric design technology.

iLogic provides a more effective means of creating, capturing and reusing product knowledge by allowing designers and engineers to capture and reuse design knowledge using iLogic rules in a simple and cost effective manner.

iLogic Capabilities Summary

iLogic embeds rules as objects directly into Inventor Part and Assembly documents. Rules determine and drive the parameter and attribute values of the design. iLogic rules provide a means of driving and defining the logical behavior of the parameters, attributes, features and components of design models directly, simply, and intuitively. Knowledge is saved and stored directly in the part and assembly documents, much in the same way geometric design elements are (e.g. sketch, extrude, chamfer.)

iLogic enables the creation and inclusion of custom parameter types; string, boolean (true / false), and multi-value (combo box lists of valid sizes or equations) directly into Inventor part and assembly models. The addition of these parameter types expands Inventor’s capabilities in order to write rules that involve more than just numeric input values.

iLogic provides an enhanced parameters list editor interface to accommodate iLogic rules and custom parameter types. It also provides advanced filtering functions to assist in parameter input definition, management and editing.

iLogic provides an extensive dictionary of automation functions that deliver the power of Inventor's API to designers and engineers via the use of simple, single-line automation functions. These powerful automation functions are made available thru a simple user interface that has been designed and optimized for use by designers and engineers having little or no programming experience.

A few of iLogic’s automation function capabilities are:

  • Supports Message Box and Input Box functions for providing feedback, options and information to the designer as rules are running.

  • Read and write to Excel spreadsheet document(s) regardless of the format.

  • Automatically search for and change iPart or iAssembly configurations based on conditional statements defined in assembly level rules.

  • Drive the activation of parts and assembly features, or the components and constraints of assemblies, from rules using conditional arguments.

  • Automatically update and drive thread specifications when a hole or rod size changes.

  • Read, write and/or react to the material or color properties of the design document, mass or volume of a part and design parameters.

  • Keep Bill of Materials information up to date when rules morphs a model into a new configuration.

  • Restrict or auto-correct user input values to ensure resulting configurations are valid and comply with design specifications/standards.

iLogic rules can be used to connect custom designed forms directly to the Inventor part or assembly design parameters to provide a user interface for the rules driven design template created.

Beginners with little or no programming experience can learn the basics of iLogic quickly while designers and engineers with programming experience will realize that iLogic’s only limitation is the range of their own imaginations.

Possible applications using VB.NET directly in rules include:

  • Read and write to html, text files, word documents and other windows based applications.

  • Automated publishing for DWF or other file formats.

  • Launching external applications and existing VBA macros.

  • Connecting to external database applications such as Microsoft® Access or SQL Server.

  • Use Inventor API functions directly.

Download Visual Basic 2008 Express


What's New in This Release ?

The following sections highlight enhancements and significant modifications available in the Autodesk Inventor iLogic 2010 release. Where possible, links are provided to the details of the new or modified functionality.

Note: many changes were made in the iLogic 2009 release.

Rule Editor

The tree views of the Inventor model in the rule editor have been changed. The view previously known as Components is now called Parameters. It looks like the Modeling View of an Inventor assembly. This view makes it easier to work with the Parameter functions using component names instead of file names.

The view previously known as Parameters is now called File Tree. It provides quick access to parameters by file name.

If you have one of these two tabs shown when you close the rule editor, it will become the default tab the next time you open the dialog.

You can click on Constraints and Component Patterns in the Parameters tree to get their names or capture their current state.

Note: in future releases, the Rule Syntax tab may be taken out of the Rule Editor. We recommend you use the newer Snippets interface.

Parameter Editor

When you select a value from the drop-down list in the Multivalue column, the parameter value will change immediately. In previous versions, you had to leave the cell before the change would take effect. For a Boolean parameter, you also get an immediate change from the True/False drop-down.

You can now access the context menu for the Multivalue list by right-clicking in the Multivalue cell.

The parameter editor dialog no longer allows you to start another Inventor command or switch to another document while it is running. Doing things like that will cause the dialog to close. You can still manipulate the view and navigate the tree while the dialog is up.

Place iLogic Component

This will not copy files that are outside of the directory of the main component being placed.

Support for placing components with a custom level of detail has been improved.

Parameter Functions

New Functions:

  • Parameter.UpdateAfterChange

  • MultiValue.UpdateAfterChange

String Functions

New Functions:

  • RoundToFraction

Dialog Box in a Rule

You can now create dialog boxes using the .NET Framework 3.5 version, in Visual Basic 2008.

Ribbon UI

The top-level user interface in iLogic now uses the ribbon introduced in Inventor 2010.


iLogic Parameters

iLogic allows you to create and edit String and Boolean parameters in an Inventor model. String parameters hold text. Boolean parameters can be either True or False. These parameters can be used in rules to drive Inventor parameters and anything else that can be driven by a rule. In a rule, they have the standard VB.NET types: String and Boolean.

In VB.NET, you write put String values in double quotes. Example:

string1 = "Left Side"

Many iLogic functions have arguments that are strings, and are put in quotes. Examples include names of components and features in the Inventor model.

Boolean parameters can be True or False. Example:

boolean1 = True

boolean2 = False

True and False are not put in quotes.

String parameters can be assigned to Inventor iProperties of type Text.

Boolean parameters can be assigned to Inventor iProperties of type "Yes or No".

Example rule syntax:

iProperties.Value("Project","Description") = string1

iProperties.Value("Custom","Passed") = boolean1

You can also do the reverse: set iLogic parameters from iProperty values:

string1 = iProperties.Value("Project","Description")

boolean1 = iProperties.Value("Custom","Passed")

iLogic parameters (as well as regular Inventor parameters) can be MultiValue parameters.


Parameters in Rules

Parameters appear in rules in two ways:

1 - VB.NET variables that are linked to standard Inventor parameters or String or Boolean parameters. These are highlighted in blue. Example:

d1 = 1.25 in

d2 = 12 mm

When a rule starts running, the iLogic system reads the values for the parameters that are used as variables from the model into the rule. When the rule is done, the iLogic system saves the changed values in the model.

(You can save the values before the rule is done by using the RuleParametersOutput function.)

2 - Parameters accessed using the Parameter function. Example:

Parameter("Pin:1", "d1") = 2.4 in

Parameter("Pin1:1", "d2") = 34.3 mm

When you assign values in this way, the values are saved to the model right away (before the system continues to the next line in the rule).


 Rule Running

Rules are usually run automatically, in response to changes in parameter values.
Rules can be triggered by events.
You can also run a rule manually, by clicking the right mouse button on a rule in the tree and selecting Run Rule. A rule is also run immediately after you edit it (unless it is suppressed).

You can use the iLogicVb.RunRule function in a rule to run another rule explicitly.

When rules run, changes in the parameters are not applied to the model until after the rule has finished running. If required, you can make parameter changes take effect immediately using either:

a) the Parameter interface
or
b) the RuleParametersOutput() function in the rule


 Rule Processing

Inventor Parameter Names
When a rule is created or edited, upon clicking OK, the rule text is converted into legal VB.NET code and compiled. Some Inventor parameter names can be used directly as VB.NET variable names, but not all. To allow for the full range of Inventor parameter names, iLogic internally substitutes variable names for the Inventor and iLogic parameters. Because of this, you can use Visual Basic keywords as parameter names. This is not recommended for new documents, but if you have an existing part then you usually won't have to change any parameter names. The variable names are substituted before VB.NET sees the rule. If the name is the same as a keyword and you need to use that keyword in the rule, then you can either:

a) change the Inventor parameter name (recommended if it is possible)
or
b) use the keyword in the rule with different capitalization (for instance "Class", if the Inventor parameter is called "class")

This takes advantage of the fact that Inventor parameters are case-sensitive but VB is not. "class" would be replaced with another name before VB sees the code, but "Class" would be left as is.

Rule Internals
As mentioned above, the rule text is converted internally to legal VB.NET code. You don't see this intermediate code, but it is stored internally with the rule, so iLogic doesn't have to re-generate it the next time the rule is run. It 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 might get an error that doesn't correspond to the rule code. The best thing to do in this case is to simplify your code. If required , make sure you have a Sub Main() and End Sub.

While converting the rule to VB.NET code for compilation, iLogic replaces units with conversion factors.


 Units in Rules

Inventor units can be used in rules in the same way as they are used in standard Inventor parameter equations.

Units are not required in rules. If a number is assigned to a parameter (and the parameter is not unitless) and no units are specified in the expression, then the number will be assumed to be in the document units (set in Tools -> Document Settings -> Units in Inventor) which would suit the parameter. This also applies to compound unit specifications (e.g. mi/hr).

Units can have a prefix.
There cannot a space between the prefix and the unit. (see the Inventor help file "Units - Functions, Prefixes, and Algebraic Operators")

Examples:

In a part file with document units of inches:

In a part file with document units of inches:

The units of the numbers were assumed by iLogic to be the same as the document units.

If the designer's intent was to assign a value of 7.2 mm to the parameter d18 (in a part file with inch units), it is necessary to explicitly specify that d18 is in millimeters, as follows:

If the previous calculation was carried out in a part file with millimeter units, it would be necessary to explicitly define the d0 parameter as d0 = 4.5 in. Failing to include the inch unit [ i.e. stating d0 = 4.5 ] would result in iLogic interpreting the statement as d0 = 4.5 mm.

In an inch part, the following statement:

d0 = 4.5
is equivalent to
d0 = 4.5 in
If, in the same document you have a parameter d18 with mm units and the value 7.2 mm, it must be expressed as
d18 = 7.2 mm
If the parameter is written as d18 = 7.2, it would be assigned a value of 7.2 inches (equivalent to 188.88 mm).

Consider an inch part file with the following parameters:

When performing the addition, iLogic converts the parameter "y" from 12.5 mm to .4921 inches.

Consider a millimeter part file with the following parameters:

With the document units as millimeters, the x parameter is converted, by iLogic, to millimeters prior to its addition to the y parameter.

Unit names can only be used directly after numbers in the rule text. They cannot be used after parameters or variables or expressions.

Examples:

12 in
144 in in
144 in^2
125.2 mm
60 mi/hr

There must be a space between the number and the units.

The unit specification is applied before any other math is done (it has precedence over all other operators).

You can use compound unit specifications in rules. These follow the same format as in Inventor. If you have a complicated unit spec, the best way to get it into a rule is to create an equation for it in Inventor, and then use Capture Current State on that parameter in the Rule Editor (to bring the Inventor equation into the rule).

Note: the unit expression "/s" will not work in a rule. This is equivalent to Hertz (Hz). When you create a parameter in Hz, and don't specify units, Inventor will give it units of "/s". You can change this in the Inventor parameter editor and then the parameter will capture correctly into the rule. Or you can edit it in the rule. Any unit that starts with a "/" will not work. You can substitute "ul/..." to get around this limitation.


If Then Else

If, Else and Select Statements in iLogic

iLogic uses Visual Basic.Net as a programming language natively but it extends the language as necessary to support special syntax required for Autodesk Inventor. (e.g. units). Therefore, the if ,then and select conditional statements in VB.Net are applicable in iLogic Rules.

The selection control structure allows one set of statements to be executed if a condition is true and another set of actions to be executed if a condition is false. A selection structure, also called an "If-Then-Else" structure, is flowcharted as follows:

After either the true set of actions or the false set of actions is taken, program control resumes with the next statement (the statement that would be placed below the connector in the flowchart above).

In iLogic, the following form is preferred for implementing the If-Then-Else structure (this is the "block", or "multi-line" form of the If statement):

If <conditional expression> Then

<one or more statements to be executed if condition is true>

Else

<one or more statements to be executed if condition is false>

End If

If the conditional expression is true, the statements between the keywords Then and Else will be executed (and the statements between the keywords Else and End If will be bypassed). If the conditional expression is false, the statements between the keywords Else and End If will be executed (and the statements between the keywords Then and Else will be bypassed). In any case, program control will resume with the statement following End If.

Example:

If size = "small" Then

length = 6.0

Else

length =12

End If

The If-Then-Else statement is a "two-alternative" decision - actions are taken on both the "If" side and the "Else" side. Sometimes, however, you may only want to perform an action or set of actions if a condition is true, but do nothing special if the condition is false. This could be flowcharted as follows:

To implement this in iLogic, omit the "Else" portion of the block If structure. For example:

If size = "small" Then

length = 6.0

End If

For a more compact method of implementing this logic, the "single-line" If statement is available. The format is:

If <conditional expression> Then <true statement> [Else <false statement>]

Examples:

If length < 20 Then MessageBox.Show("Length is Too Short", "Title")

If mass < 1000 Then length =20 Else length =40

Note that in the single-line format of the If statement, the keywords End If are not used.

Style-wise, the block form of the If statement is preferred over the single-line form in that the block form enhances readability.

Although not used frequently, in the block form of the If statement, "null" or "empty" sets of actions are permitted (i.e., "if a condition is true, do nothing - else, do something"). For example:

If length > 20 Then

Else MessageBox.Show(" Invalid Size.Length must be at least 20 in. ", "Title")

End If

When using an empty set of actions, it improves readability to place a comment (remark) where the true statements would normally go:

If length > 20 Then

'do nothing

Else MessageBox.Show(" Invalid Size.Length must be at least 20 in ", "Title")

End if

Similarly, an empty set of actions could follow an Else:

If length < 20 Then

Else MessageBox.Show(" Invalid Size.Length must be at least 20 in ", "Title")

'do nothing

End If

Using Boolean Variables as Conditional Expressions

A Boolean variable, which can hold the value True or False, can be used anywhere a relational expression can be used.

Example:

If Feature.IsActive("Fillet1") Then . . .

can be coded instead of:

If Feature.IsActive("Fillet1") = true Then . . .

In other words, the "= True" part is implied.

Also, to test if a Boolean variable is false, you can use:

If Not Feature.IsActive("Fillet1") Then . . .

instead of:

If Feature.IsActive("Fillet1") = false Then . . .

The Case Structure

When the situation arises where you need to choose between more than two alternatives, an extended form of the selection structure, called the case structure, must be used. A flowcharted example follows:

In iLogic, the case structure can be implemented in one of two ways: with an extended block If structure, or with the Select Case statement structure.

Extended Block If Statement (If/Then/ElseIf)

Format

If <conditional expression 1> Then

<one or more statements to be executed if condition 1 is true>

ElseIf <conditional expression 2> Then

<one or more statements to be executed if condition 2 is true>

. . .

ElseIf <conditional expression n> Then

<one or more statements to be executed if condition n is true>

Else

<one or more statements to be executed if none of the above conditions is true>

End If

Note that one or more ElseIf clauses are "sandwiched" between the first "If" clause and the last "Else" clause. Note also the keyword ElseIf is one word. Using the format above, this extended If structure is to be understood as follows: if "conditional expression 1" is true, perform the statements associated with that condition, then exit to the statement following the End If; if "conditional expression 1" is false, then check "conditional expression 2" - if "conditional expression 2" is true, perform the statements associated with that condition, then exit to the statement following the End If, and so on. VB will execute the statements associated with the first true conditional expression it finds and then exit to the statement following the End If. The final Else statement is often useful to trap errors that may occur when unexpected conditions arise, none of which matches the conditions in the previous If or ElseIf clauses.

Example:

If material ="steel" Then

density = 0.284

ElseIf material ="copper" Then

density = 0.323

ElseIf material =" aluminum" Then

density = 0.098

EndIf

Note that the use of "ElseIf" saves the coding of multiple "End If" statements in a nested If structure. As a comparison, the above example could have been written as follows:

If material ="steel" Then

density = 0.284

Else

If material ="copper" Then

density = 0.323

Else

If material =" aluminum" Then

density = 0.098

End If

End If

End If

The Select Case Statement

VB's Select Case is a powerful statement with several options. The format is:

Select Case <test expression>

Case <expression list 1>

<statement list 1>

Case <expression list 2>

<statement list 2>

Case Else

<statement list n>

End Select

The format above is to be understood as follows: The Select Case statement specifies an expression to be tested. Each subsequent Case clause specifies an expression(s) that the test expression will be compared to. The first Case clause that contains an expression that matches the test expression will have its associated actions executed, then program control will branch to the statement following End Select. The final Case Else clause is often useful to trap errors that may occur when an unexpected value of the test expression is present, none of which matches the expression list specified in any of the above Case clauses.

Example:

Select Case material

Case "steel"

density = 0.284

Case "copper"

density = 0.323

Case "aluminum"

density = 0.098

Case Else

density = 0

MessageBox.Show("not a valid material" , "Warning")

End Select

The test expression following "Select Case" can be a more complex expression, such as:

Select Case radius +1

Select Case MinOfMany(x,y,z)

The expression list in a "Case" clause can have any of the following formats:

Example:

Select Case width

Case 1,2,3,4,5

MessageBox.Show("Small Plate", "Size")

Case 6 to 15

MessageBox.Show("Medium Plate", "Size")

Case Is > 15

MessageBox.Show("Large Plate", "Size")

End Select

The Select Case statement does not need to be "tied" to one particular variable or expression; it can be used to evaluate any number of conditions, using the following format:

Select Case True

Case length >= 10

width = length - 1

thickness = length/5

Case length<10

width = length - .75

thickness = length/6

End Select


Parameter Editor

 iLogic Parameter Editor

iLogic enables the creation and inclusion of custom parameters: String, Boolean (true/false) and multi-value (combo box list of valid sizes or equations) into a design. It provides an enhanced parameters list editor interface for accommodating rules and custom parameters. The iLogic Parameter editor also provides an advanced filtering function to assist in parameter input definition, management and editing. These parameters can be used in rules to drive Inventor Parameters, iProperties, iParts, mates, and features.

The iLogic parameter editor is similar to the Inventor parameter editor.
You can use it to add new parameters to the model, change the values or names of existing parameters or delete them.
Rules can create parameters, but only with advanced programming. Usually, all parameters to be used in rules must be created by Inventor modeling operations, the Inventor parameter editor or the iLogic parameter editor.

To create a new parameter, type a name in the last row of the table (the one with a *). Pick a Type and Units (if applicable) and enter a value or equation in the Equation column. iLogic parameters do not support equations in the parameter editor.

Right click in the Nominal Value column to convert a parameter into a multivalue parameter, or to edit its multivalue list.

Columns in the editor table

Name
You can add or change the name of a parameter.

Type
When you create a new parameter, this will give you a choice of User, String or Boolean. User means a standard Inventor User (not Model) parameter. Choosing String or Boolean results in the creation of an iLogic Parameter.

Unit
For a User parameter, you have a choice of units. Only the most frequently used units are provided in the drop-down list. You can enter other unit names manually, and they will be added to the list.

Equation
For an Inventor parameter, this is the same equation that shows up in the Inventor parameter editor. The equation is checked for valid syntax. (Note: for very complex equations, the Inventor parameter editor is recommended). For an iLogic string parameter, the value of the parameter will be shown in the Equation column.

Driving Rule
If the value of the parameter is set by a rule, this column will display the name of the rule. You can double-click on this cell to edit the rule. (Note that if the Parameter function is used in a rule to set the parameter value, the rule will not appear as a driving rule.)

Multivalue
If the parameter is a multivalue parameter , this cell will show a list of possible values using a drop-down menu. Choosing one of the values will set the value or equation of the parameter. You must right click in another column to edit this list.

Nominal Value
This is the same value that is shown in the Inventor parameter editor.

Key Parameter
This is an optional flag you can add to a parameter, to help you view a "short list" of important parameters. Set this and then use the filter (at the bottom of the dialog) to see only key parameters.

In the image above, Key Parameters have been selected.

In the image above, some Key Parameters have been selected, and the filter has been set to view only the Key Parameters.

Comment
This is the same as in the Inventor parameter editor.

Other Controls

Immediate Update
When using the parameter editor to change the model, this option will cause the model to update immediately after you change a parameter (which might also cause Inventor equations and iLogic rules to run). This allows you to see changes to the model.

Condense and Expand Parameter Editor View
It is possible to view the Parameter Editor in Expanded or Condensed mode. When creating new parameters it is useful to have all of the columns visible. Once the parameters have been created, it is often advantageous to condense the Parameter Editor. With the Parameter Editor condensed, you have more screen space for graphics and it is easier to see the model change in response to changing parameter values.

Save and Load XML

Note:
You should create parameters before writing the rules that use them. But if you forget and create a rule and then later create a parameter for it, the rule will not connect to the parameter right away. You have to regenerate the rule manually (using Regen Rule in the iLogic Tree Editor ) or edit the rule to make the connection.


Rule Editor

iLogic Rule Editor

The iLogic rule editor is used to create and edit rules. A rule is a small Visual Basic (VB.NET) program, usually with connections to Inventor parameters, features or components.
To access the rule editor, click on the Add Rule icon in the iLogic ribbon panel.

Clicking on the Add Rule icon opens the Rule Name dialog box. You can name the rule at this point.

Click OK to open the iLogic Rule Editor.

Inventor Parameter names can be used directly in rules, as VB variable names. When you run the rule, the variable will have the value of the parameter. For an Inventor variable, this will be a real number (a Double in VB). The value will be in document units (as specified in the Units under Tools -> Document Settings).
iLogic parameters will be either String or Boolean variables in the rule.

The Rule Editor shows several views of the Inventor model tree, to make it easy to select items to insert into the rule.
The default tree (and first tab) is the Parameters tree. This shows the top-level file and the parameters it contains, grouped into Model Parameters, User Parameters and iLogic Parameters. If you left-click on the Model Parameters item, a list of parameters will show up in the list on the right. If you double-click on a parameter in the list, that name will be inserted into the rule text. You can also right-click on an item and choose "Capture Current State" to insert text into the rule that assigns values to the item. Capturing the state of a parameter it will insert text such as:

d0 = 4.0 in

Parameters are always captured with their units, but units are not required when you write equations from scratch.
You can capture the state of all model parameters, all user parameters etc.

For an assembly document, the parameters tree will show sub-assembly and part files. If you expand a part file item, it will show the parameters and features within that file. If you click on a parameter in a part file (named PartX.ipt) within the assembly, it will appear as:

PartX.ipt.d0 = 12.0 mm

This shows one method that iLogic uses to access part parameters within an assembly.

Tabs in the Rule Editor Dialog

  • Rule Syntax

  • Rule Editor Options

Code Snippets

Custom Code Snippets


Code Snippets

Code snippets provide "short cuts" for frequently used pieces of code. iLogic provides several pre-defined snippets in the "System" tab ready for you to use in your rules. You can also add your own snippets in the Custom tab.

The snippets are arranged into several different categories. Hover over each snippet to display a tooltip describing its function in more detail.

Parameters

These snippets are used for working with part and assembly parameters. Using these snippets you can get or set single or multiple values, access values from an Excel spreadsheet, or read/write parameters to a XML file.

Features

These snippets are used to turn a feature on or off, change the color, or work with threads.

Components

These snippets are used to turn activate a component, replace one component with another one (or an iPart), change a component's color, or give a sub-component a name.

iProperties

These snippets are used to access several different iProperties.

Excel Data Links

These snippets are used to access data stored in an Excel spreadsheet; the spreadsheet can be an external file or embedded in the Inventor model.

iParts

These snippets are used to manipulate Inventor's iParts.

iFeatures

These snippets are used to manipulate Inventor's iFeaturess.

Constraints

These snippets are used to manipulate constraints in the Inventor model.

Measure

These snippets are used to measure distance, angles, areas, permits and extents.

Work Features

These snippets provide access to Inventor's work features.

MessageBox

These snippets can be used to quickly construct a primitive UI to obtain user input while a rule is running.

Document

These snippets are used to obtain path information about the current document, save the document, update the document or open a new document.

Run Other

These snippets are used to run other iLogic rules, rules in other components, Inventor Macros and rules defined in VB.NET.

BOM

These snippets are used to access Inventor's "Bill of Materials" functionality.

Math

These snippets are used to access several mathematical routines. Refer to the VB.NET documentation for complete details.

Strings

These snippets are used to access several string manipulation routines. Refer to the VB.NET documentation for complete details.

Variables

This section contains snippets for declaring and manipulating variables. In particular, "shared variables" (used between rules) can be created.

Material Properties

These snippets are used to access various material properties. These properties are stored on the component definition in the Inventor API model.

Sheet Metal

These snippets are used to manipulate sheet metal models from iLogic rules.

Advanced API

This section contains snippets of interest to advanced users. Refer to Inventor API documentation for complete details.

DoubleForEquals Off

Normally, iLogic converts Doubles into its own double class; this is so that it can use a tolerance when comparing two numbers. This snippet provides a quick way to disable this feature.


Rule Editor Options

The Options tab of the Rule Editor provides a set of options to control various aspects of iLogic behavior. Each of the setting groups is described below.

Rule Behavior

Suppressed

A suppressed rule will not run automatically. You can still run it manually. You can also suppress a rule in the iLogic Tree Editor.

Silent Operation

This option causes a rule to run without displaying Inventor dialog boxes. Use this if you have Inventor dialog boxes popping up, and you always want to pick the default response.

Fire dependent rules immediately

As a result of this rule running, other rules might run (fire), because they refer to a parameter that this rule changes. These rules can be called "dependent rules". Normally these rules will be run after this rule finishes. Firing it "immediately" means as soon as the parameter changes value. By running it immediately, you can include an update (InventorVb.DocumentUpdate) after you are done setting the parameters. At the time of the update, the parameters will have changed and the dependent rules will have run.

Don't run automatically when parameters change

Checking this option will prevent the rule from running in response to parameter changes. You will have to run it manually (or with iLogicVb.RunRule).

Straight VB code

This option is for Advanced Rule Programming. It allows you to share code between rules, but the shared code is harder to write. Don't use this unless you need it!

Rule Editor

Automatic Highlighting

This is on by default. It provides the color-coding of syntax. If you turn it off, then Undo (Ctrl-Z) and Redo (Ctrl-Y) will work. You can update the color coding with the Refresh button (at the bottom of the dialog) or with the F5 key.

Capture Syntax

Use Parameter syntax for parameters in components

By default, this check box in the Capture Syntax is checked. This allows the user to use Parameter (previously known as DynaParam) syntax for parameters in components. When creating rules at the assembly level, the user can enter the names of parameters into rule text by double clicking on the parameter name. With this option selected, the parameters are automatically put into Parameter syntax, using the component name.
This syntax is recommended because you might want to suppress or replace a component. If you "stabilize" the component name by changing it to something different than the original filename, this Parameter syntax can always find it.


 Rule Syntax

This tab in the Rule Editor dialog box displays several lists of text items. These text items are grouped in categories according to their function within iLogic Rules.
These lists include:

A - Keywords: the Commands used to build rules in iLogic
B - Operators: mathematical symbols
C - Functions: the tools of iLogic
D - Function Categories: Functions are categorized according to use.

Double-clicking on a text item will insert the text into the rule, at the current cursor position.
The Keywords and Operators lists don't change.

Function Categories

Math: Mathematical operations that can be used in rules.

Data Links: Used to read and write to an Excel spreadsheet

Component/Feature: Used to manipulate activation states and attributes of parts.

Parameters

iProperties : deals with the iProperties of a part, assembly or component.

Constraints : used to manipulate constraints in the context of assemblies

iParts: used to select configurations of iParts, iAssemblies and iFeatures

iFeature: These functions are used in rules that involve table driven iFeatures.

Measure: Functions to measure distances and angles.

Sheet Metal : Functions for sheet metal applications.

Message Box: Functions for message boxes.

Document Functions: Functions that deal with files and documents.

Other: Miscellaneous functions

Advanced API


Wizards

Wizards guide the user through a set of steps to complete a task. Four wizards are currently available in iLogic:

  1. Create Rule to Include a Dialog Box - use a custom dialog box to drive parameter values.

  2. Capture Current View - Allows the user to "capture" values for the view orientation and zoom.

  3. Create a rule which displays a Windows "Message Box".

  4. Set minimum and maximum values for parameters.

All of the wizards are accessed from the "Wizards" tab in the Rule Editor Dialog Box:

Create a Rule For a Dialog

To use the "Create Rule for a Dialog" wizard, press the button labeled "Create Rule for a Dialog" on the left side of the Rule Editor.

The Open DLL File dialog box will open in the iLogicAdd folder which contains previously created .dll files.

Selecting a .dll will then open the Rule for External DLL dialog box which contains the appropriate class and variable names to create the dialog box in the rule.

Next, the selections are made and accepted, the wizard automatically creates the code that will tie the model parameters to the dialog box.

Capture Current View

This wizard allows the user to write an iLogic rule to capture the current view on the display. Code to restore the view orientation (and optionally the zoom factor) is entered into the rule. Three different size options are available.

Save and Restore Current view extent

InventorVb.SetViewCamera(ViewCameraOption.SetExtents, New Double() {-0.99249715423843576, -6.1197358859382947, 5.0685658005771792}, New Double() {0.078079334601750539, 0.21133048849780245, 0.26580656776641076}, New Double() {0.031439829508135772, 0.600698303470465, 0.79885736231708149}, New Double() {9.5406209391673631, 4.7703104695836815})

Running a rule containing this function causes the view to restore to the orientation and zoom it was in when the rule captured the view.

Don’t change view size on restore

InventorVb.SetViewCamera(ViewCameraOption.NoChangeExtents, New Double() {-0.99249715423843576, -6.1197358859382947, 5.0685658005771792}, New Double() {0.078079334601750539, 0.21133048849780245, 0.26580656776641076}, New Double() {0.031439829508135765, 0.60069830347046493, 0.79885736231708127}, New Double() {9.5406209391673631, 4.7703104695836815})

This function moves the model to the center of the display, and sets the orientation, but does not change the zoom.

Fit to model extents on restore

InventorVb.SetViewCamera(ViewCameraOption.FitExtents, New Double() {-0.99249715423843576, -6.1197358859382947, 5.0685658005771792}, New Double() {0.078079334601750539, 0.21133048849780245, 0.26580656776641076}, New Double() {0.031439829508135765, 0.60069830347046493, 0.79885736231708127}, New Double() {9.5406209391673631, 4.7703104695836815})

When this line is included in the rule, the result is the same as the Zoom All function. The model is moved to the middle of the display and fills the display.

Message Box

Windows Message Boxes have several options; this wizard presents a GUI for generating Message Boxes. The Message Box Code is added to rule automatically.

For example, to generate this code

MessageBox.Show("The Value you entered was incorrect","My iLogic Dialog",MessageBoxButtons.OK,MessageBoxIcon.Information, MessageBoxDefaultButton.Button1)

Use the following options to the Message Box wizard:

Parameter Limits

You may wish to display a diagnostic message when parameter limits are outside of a specified range. Using the parameter wizard

The following code is generated:


Math Functions

In the iLogic Rule Editor, the math functions are accessed from the Rule Syntax tab by clicking on the Math category in the Function field located on the top right of the Editor window. iLogic includes the following functions.

Sin()
Cos()
Tan()
PI
Abs
Sqrt()
Sign()
Round()
Ceil()
Floor()
Log10()
Ln()
Pow(,)
Min(,)
Max(,)
MinOfMany(,,,)
MaxOfMany(,,,)
EqualWithinTolerance(a,b,0.001)

Trigonometric Functions

Sin(), Cos() and Tan() - Standard trigonometric functions whose arguments are in RADIANS -- not degrees. To convert from degrees to radians, use the formula:

radians = degrees *(PI/180)

Sin(0) = 0
Sin(PI) = 0
Sin(PI/2) = 1
Cos (0) = 1
Cos (PI/2) = 0
Cos (PI) = 0
Tan(0) = 0
Tan(PI/4) = 1

PI = 3.1415926......

Other Math Functions

Abs() - returns the absolute value of the argument.

Abs(10) = 10
Abs(-9.87) = 9.78

Sqrt() - returns the square root of the argument

Sqrt(25) = 5
Sqrt(100) = 10
Sqrt(3) = 1.732051

Sign() - Returns a number indicating the sign of a number

If the value is positive, Sign(value) = 1
If the value is negative, Sign(value) = -1
If the value is zero, Sign(value) = 0

Round() - rounds the argument to a specified number of decimal places

Syntax: Round(argument, optional # of decimal places desired)

Round(2.55689) = 3
Round(2.55689, 1) = 2.6
Round(2.55689, 3) = 2.557
Round(PI, 4) = 3.1416

Ceil() - rounds the argument to the next higher integer

Ceil(2.56) = 3
Ceil(Sqrt(3))= 2

Floor() - rounds the argument to the next lower integer

Floor(1.789) = 1
Floor(PI) = 3

Log10() - returns the base 10 logarithm of the argument.

Log10(10) = 1
Log10(100) = 2
Log10(15) = 1.176091

Ln() - returns the natural logarithm of the argument. (base e logarithm)

Ln(5) = 1.609438
Ln(37) = 3.610918

Pow(argument1, argument2) - returns the result of raising argument1 to the exponent of argument2.

Pow(2,2) = 22 = 4

Pow(2,3) = 23 = 8

Pow(3,2) = 32 = 9

Comparison Functions

Min( argument1, argument2 ) - returns the lesser of the two arguments

Min (2,4) = 2
Min (9,4) = 4
Min (Sqrt(2),Sqrt(3)) = 1.4142.....

Max( argument1,argument2 ) - returns the greater of the two arguments

Max (2,4) = 4
Max (9,4) = 9
Max (Sqrt(2),Sqrt(3)) = 1.73205.....

MinofMany( ,,, ) - returns the lesser of many arguments

MinofMany (2,4,3,6,7,8) = 2
MinofMany (9,4,5,67,3,5) = 3
MinofMany (Sqrt(2),Sqrt(3), Sin(PI/2)) = 1

MaxofMany( ,,, ) - returns the largest of many arguments

MaxofMany (2,4,3,6,7,8) = 8
MaxofMany (9,4,5,67,3,5) = 67
MaxofMany(Sqrt(2),Sqrt(3), Sin(PI/ignored>/2)) = 1.73205.....

EqualWithinTolerance(a, b, 0.001)

Compares the values of two parameters [represented by a and b] and compares the difference to the stated tolerance value [specified here as 0.001]. If the difference is less than the tolerance, the function returns the Boolean value True. If the difference is greater than the tolerance, the function returns the Boolean value False.

Example

If a = 10.00 and b = 10.01

EqualWithinTolerance(a,b,0.015) = True [Abs(a-b) is less than the tolerance value of 0.015 in]

EqualWithinTolerance(a,b,0.001) = False [Abs(a-b) is greater than the tolerance value of 0.001]

EqualWithinTolerance(a, b)

Uses a default tolerance of 0.0000001

Most of these functions are from the standard VB.NET Math Library
(which is made available to a rule by iLogic using an Imports statement).

If you use Capture Current State on a trigonometric formula in the Rule Editor , you might have to edit it by hand to convert the argument to radians.

Some functions are not from the standard library, but are provided by iLogic.
The following functions are provided to replicate functions available in standard Inventor equations:
Ceil (same as Math.Ceiling)
Sign0(a) = 1 if a > 0.0, = 0 otherwise
Ln (same as Math.Log)

Special cases for capture of Inventor equations:
If the function "sign" occurs, it will become "sign0" in the rule.
"log" will become "log10" in the rule.
This is done because these Inventor functions are different from the VB.NET standard Math functions of the same name.


String Functions

In the iLogic Rule Editor, a set of string functions is accessed from the Rule Syntax tab by clicking on the String category in the Categories column located on the top right of the Editor window. iLogic includes the following functions.

Len()
Left()
Right()
Mid()
LCase()
UCase()
String.Compare()
CStr()

Most of these functions are provided as part of the standard VB.Net String Library.
Documentation for these functions is available here: String Methods

iLogic-Specific Functions

CDblAny(string) - Convert a string into a Double value. This is similar to the standard VB.NET function CDbl, but it will convert a string using either a comma or a period as a decimal separator, independent of your Windows language settings. It can fail if the string does not represent a valid number. For instance:

x = CDblAny("3.14159") ' returns 3.14159

x = CDblAny("3,14159") ' returns 3,14159

Note: this function is useful for converting values of iLogic string parameters to numbers. In drawing documents, you can create string parameters, but not numeric ones.

FormatAsFraction(value, [numberOfDecimals]) - Format a numeric value as a string, in fraction form (e.g., for representing inch measurements).

Returns a fraction (e.g., "1/2"), or number and fraction (e.g., "3 5/8"), if the converted value has a power-of-2 denominator (up to a maximum of 64, within 0.0000001). Otherwise returns a decimal number.

The numberofDecimals argument affects the rounding of the resulting string, if decimals are returned. This argument is optional, and defaults to 3 if it is not provided. For instance:

FormatAsFraction(0.75)  ' returns  "3/4"
FormatAsFraction(2.375)  ' returns  "2 3/8"
FormatAsFraction(2.4)
' returns "2.4"
FormatAsFraction(2.00001)  ' returns  "2.000"
FormatAsFraction(2.00001,
6)  ' returns   "2.00001"

RoundToFraction(value, fractionFactor, roundingMethod) - Format a numeric value as a string, in fraction form (e.g., for representing inch measurements).

This always returns a fraction (e.g., "1/2"), or number and fraction (e.g., "3 5/8"). It will round the value to a multiple of the fraction factor.

fractionFactor must be 1/2, 1/4, 1/8, 1/16 or 1/32.

roundingMethod is either:

RoundingMethod.Round : round to the closest multiple of fractionFactor

RoundingMethod.RoundUp : round to the nearest multiple of fractionFactor greater than or equal to the value

RoundingMethod.RoundDown : round to the closest multiple of fractionFactor less than or equal to the value

For instance:

RoundToFraction(0.7502, 1/4, RoundingMethod.Round) ' returns "3/4"
RoundToFraction(0.7502, 1/4, RoundingMethod.RoundUp) ' returns "1"
RoundToFraction(0.749, 1/4, RoundingMethod.RoundUp) ' returns "3/4"
RoundToFraction(0.749, 1/8, RoundingMethod.RoundUp) ' returns "3/4"
RoundToFraction(0.7, 1/8, RoundingMethod.RoundUp) ' returns "3/4"
RoundToFraction(0.6, 1/4, RoundingMethod.RoundUp) ' returns "3/4"
RoundToFraction(0.6, 1/8, RoundingMethod.RoundUp) ' returns "5/8"
RoundToFraction(0.7502, 1/4, RoundingMethod.RoundDown) ' returns "3/4"
RoundToFraction(0.749, 1/4, RoundingMethod.RoundDown) ' returns "1/2"


Data Links

iLogic provides rule functions for reading and writing to Microsoft Excel spreadsheet documents. Because iLogic uses VB.Net as its base language, it is possible to read and write many different file formats if you have the programming knowledge required to do so. Future versions of iLogic will provide more simplified functions for reading and writing to common database and file formats.

Excel Data Link Functions

GoExcel.Application | provides access to the Excel Application object
GoExcel.CellValue | read from or write to a specific cell address in a spreadsheet
GoExcel.CellValues | get or set the values of a range of cells at once
GoExcel.ChangeSourceOfLinked | modify the target of a spreadsheet link in an Inventor model
GoExcel.Close | close the currently open spreadsheet
GoExcel.CurrentCellValue | read from or write to a specific cell address in a spreadsheet subsequent to using the GoExcel.CellValue function. This function does not require a filename or sheet name, as it links automatically with the file and sheet opened using GoExcel.CellValue.
GoExcel.CurrentRowValue | read column values from a row found using the GoExcel.FindRow function.
GoExcel.DisplayAlerts | Controls whether Excel prompts are displayed during subsequent operations
GoExcel.FindRow | search for a row based on one or more column value search criteria.
GoExcel.FindRowStart | sets the starting row to start looking for data in GoExcel.FindRow
GoExcel.Open | open a spreadsheet file to make it available for reading or writing.
GoExcel.Save | save and close the spreadsheet document after writing to it.
GoExcel.Tolerance | used to control matching of cell values in GoExcel.FindRow

GoExcel.FindRow

Syntax Usage

GoExcel.FindRow("file name and path","sheetname","1st column title", "operator",value to look for, "2nd column title", "operator", value to look for, "3rd column title",.etc)

searches for a row based on one or more column value search criteria.

"filename and path” Name of Excel file containing the table. If the path is not specified, iLogic will assume the Excel document is in the same folder as the Inventor document. A relative path will be interpreted as relative to the Inventor document folder.

Filename extensions supported are .xls, .xlsx, .xlsm and .xlsb. Use ”3rd Party:Embedding #” for embedded spreadsheets.

”sheetname” Name of the sheet in the Excel document containing the table to be searched. This may be any existing sheet.

”1st column title” Title of first column in table to be searched. Can be any column.

"operator”

<= (find row with a value less than or equal to the value being searched for in the column)

>= (find row with a value greater than or equal to the value being searched for in the column.)

= (find row with a string or numeric value equal to the string or numeric value being searched for in the column)

value to look for This can be a string, numerical value, parameter or local variable

"2nd column title" Title of second column in table to be searched. Can be any column.

”operator” <= , >= or =

value to look for This can be a string, numerical value, parameter or local variable

”3rd column title” etc... You can find a row based on multiple criteria.

Returns

Row number (integer) where cell value in searched column matches search criteria

- 1 on error

Errors

If a matching row is not found

File not found

Sheet name not found

Column name is not found

Input value is wrong type (doesn’t match column value type)

Search value is an unassigned variable or inventor parameter

Excel Table format requirements

Can be embedded into the Inventor document (or linked) or external.

External tables do not require any links to Inventor

Embedded table requires at least one link to an Inventor parameter. The table must be embedding using the ”link” option from the Inventor parameter editor dialog box.

Embedded table name must not be changed from the default name assignment given to it by inventor when it is added to the design browser panel (i.e., Embedding 1)

Table configurations must be horizontal (configurations defined by rows not columns)

Columns must have titles in the first cell of the column

Lookup values may be numeric or strings

Excel file name extensions supported are .xls, .xlsx, .xlsm, and .xlsb

i = GoExcel.FindRow("C:\mytable.xls", "Sheet1", "Dia", "=", 0.2, "len", ">=",4.1)

This example sets the value of the parameter variable ”i” to the row number of the table where the ”Dia” is equal to 0.2 and the ”Len” is greater than or equal to 4.1. This code references an external spreadsheet.

i = GoExcel.FindRow("3rd Party:Embedding 1", "Sheet1", "Dia", "=", 0.2, "len",">=", 4.1)

This example sets the value of the parameter variable ”i” to the row number of the table where the ”Dia” is equal to 0.2 and the ”Len” is greater than than or equal to 4.1. This code references a linked embedded spreadsheet.

Note: ”3rd Party:” must be provided as a prefix with no space between it and

the Embedding name.

GoExcel.CurrentRowValue

GoExcel.CurrentRowValue("column name”) read a value from the row found using the GoExcel.FindRow function.

”column name” column title name for cell value to be retrieved from the current row as found by previous use GoExcel.FindRow function.

Returns

Cell value from column of current row value returned by GoExcel.FindRow function

Errors

Returns an error message if the column is not found.

Example

i = GoExcel.FindRow("iLogic_SCHS.xls","Sheet1","thread_diameter","=", Screw_Size,"screw-length",">=",screw_length_required)

thread_diameter = GoExcel.CurrentRowValue("thread_diameter")

screw_length = GoExcel.CurrentRowValue("screw_length")

head_diameter = GoExcel.CurrentRowValue("head_diameter")

head_thickness = GoExcel.CurrentRowValue("head_thickness")

socket_size = GoExcel.CurrentRowValue("socket_size")

thread_pitch = GoExcel.CurrentRowValue("thread_pitch")

GoExcel.CellValue

GoExcel.CellValue(”file name and path”,”sheetname”,”cellnumber”) read or write values to spreadsheet cells.

"filename and path" Name of Excel file containing the table. If the path is not specified, iLogic will assume the Excel document is in the same folder as the Inventor document. A relative path will be interpreted as relative to the Inventor document folder.

Filename extensions supported are .xls, .xlsx, .xlsm and .xlsb. Use ”3rd Party:Embedding #” for embedded spreadsheets.

"sheetname” name of the sheet in the Excel document containing the cell to read or write to. This may be any existing sheet.

"cell number” cell address to read or write to (ex. A7) You can also specify a named range.

Returns

Value of cell

No assignment on error

Errors

File not found

Sheet name not found

Excel Table format requirements

Can be embedded into Inventor document (or linked) or external.

External tables do not require any links to Inventor

Embedded table name must not be changed from the default name assignment given to it by Inventor when it is added to the design browser panel (ie. Embedding 1)

Cell values may be numeric or strings

Excel file name extensions supported are .xls, .xlsx, .xlsm, and .xlsb

Examples:

Read Embedded Spreadsheet

head_rad = GoExcel.CellValue("3rd Party:Embedding 4", "Sheet1","A1")

Write to Embedded Spreadsheet

GoExcel.CellValue("3rd Party:Embedding 4", "Sheet1", "A1")= head_rad

Write to External Spreadsheet

(requires ”GoExcel.Save” to save changes to spreadsheet)

GoExcel.CellValue("Spreadsheet.xls", "Sheet1", "A6") = "Hello World"

GoExcel.Save

Read an External Spreadsheet

head_rad = GoExcel.CellValue("Spreadsheet.xlsx", "Sheet1","A5")

msgbox = GoExcel.CellValue("Spreadsheet.xlsx", "Sheet1","A5")

GoExcel.CurrentCellValue

GoExcel.CurrentCellValue("cellnumber")

Read from or write to a specific cell address in a spreadsheet subsequent to using the GoExcel.CellValue function. This function does not require a filename or sheet name. It uses the file and sheet opened using GoExcel.CellValue.

”cellnumber” Cell address or named range of the cell value to be read or written to from the current spreadsheet last opened by the previous use of GoExcel.CellValue function.

Returns

Cell value from cell number specified

Errors

No assignment on error.

An error message will pop up.

Example:

Read a series of cells from a single Spreadsheet document

head_rad = GoExcel.CellValue("Spreadsheet.xlsx","Sheet1","A1")

head_thick = GoExcel.CurrentCellValue("B1")

pin_length = GoExcel.CurrentCellValue("C1")

shaft_rad = GoExcel.CurrentCellValue("D1")

Write to a series of cells in a Spreadsheet document

GoExcel.CellValue("Spreadsheet.xlsx","Sheet1","A1") = head_rad

GoExcel.CurrentCellValue("B1") = head_thick

GoExcel.CurrentCellValue("C1") = pin_length

GoExcel.CurrentCellValue("D1") = shaft_rad

GoExcel.Save

GoExcel.NamedRangeValue("PinLength")

This is similar to CellValue. Instead of a cell address you should give it a named range that you have defined in the Excel workbook. This must be a workbook-scope name. The range should be a single cell. (You can access worksheet-scope named ranges using the standard CellValue syntax, using the name instead of a cell address.)

You must use GoExcel.CellValue (to open the Excel file) before using NamedRangeValue in a rule.

GoExcel.Open

Opens the specified Excel spreadsheet file, and optionally activates a named worksheet. Functions such as GoExcel.CurrentRowValue and GoExcel.CurrentCellValue can then be used to extract information from or modify the worksheet.

Returns

N/A

Errors

N/A

Examples:

When no sheet name is specified, "Sheet1" is assumed.

GoExcel.Open("Spreadsheet.xls")

Some other worksheet can also be specified.

GoExcel.Open("Spreadsheet.xls", "MyOtherSheet")

GoExcel.Save

Save Spreadsheet documents modified by the GoExcel.CellValue and GoExcel.CurrentCellValue functions.

Returns

N/A

Errors

N/A

Example:

GoExcel.CellValue("Spreadsheet.xls", "Sheet1", "A1") = "Hello, World!"

GoExcel.CurrentCellValue("A2") = "My name is Autodesk, Inc."

GoExcel.Save

GoExcel.CellValues

These functions read values from a specified range of cells in an Excel spreadsheet and assign them to a MultiValue list

or

Take the values from a multivalue list and write them to a specified range of cells in an Excel Spreadsheet.

Reading from an Excel Spreadsheet

Values can be read from a vertically oriented range of cells. The function will read values starting in the first cell and will continue downward, reading values until it reaches the second cell specified in the function.

Multivalue.List("parameter") = GoExcel.CellValues("filename.xls","Sheet1","A1","A10")

If the second cell address is replaced by a null string [ "" ], iLogic will start reading at the first cell address continue downward, reading values until a blank space is encountered.

Multivalue.List("parameter") = GoExcel.CellValues("filename.xls","Sheet1","A1","")

Values can be read from a horizontally oriented range of cells.

Multivalue.List("parameter") = GoExcel.CellValues("filename.xls","Sheet1","A1","J1")

The filename can be omitted completely if the spreadsheet of interest has been previously referenced in the rule.

Multivalue.List("parameter") = GoExcel.CellValues("B2","G2")

Writing to an Excel Spreadsheet

Values can be written to a vertically oriented specified range of cells. The function will write values starting in the first cell and will continue downward, writing values until it reaches the second cell specified in the function.

GoExcel.CellValues("filename.xls","Sheet1","A2","A10") = Multivalue.List("parameter")

Values can be written to a vertically oriented range of cells. If the second cell address is replaced by a null string [""], iLogic will use as many cells as required to contain all members of the multivalue list.

GoExcel.CellValues("filename.xls","Sheet1","A2","") = Multivalue.List("parameter")

Values can be written to a horizontally oriented range of cells.

GoExcel.CellValues("filename.xls","Sheet1","A1","J1") = Multivalue.List("parameter")

The filename can be omitted completely if the spreadsheet of interest has been previously referenced in the rule.

GoExcel.CellValues("B2","G2") = Multivalue.List("parameter")

GoExcel.Close

Including this line in the rule allows iLogic to close an Excel spreadsheet without requiring user input.

GoExcel.FindRowStart

GoExcel.FindRowStart = 2

This function is used with the GoExcel.FindRow function. GoExcel.FindRowStart sets the number of the first row in the spreadsheet that contains data. By default the value is 2, which means that the data starts on row 2 and there is one row on the spreadsheet for titles.

GoExcel.ChangeSourceOfLinked(partialOldName, newName)

This function allows the user to make changes to a model whose dimensions are driven by a linked [not embedded Excel spreadsheet]. This function will replace an Excel spreadsheet that is currently driving a model with another spreadsheet. The values contained in the new spreadsheet will then drive the dimensions of the model.

Syntax

changeOK = GoExcel.ChangeSourceOfLinked(partialOldName, newName)

partialOldName - a portion of the name of the spreadsheet to be replaced

partialOldName can be an empty string "". This will match the first linked Excel

file, and usually there will be only one in the part or assembly.

newName - the entire name of the new spreadsheet (an absolute or relative filename)

Example

if size = "small" then

changeOK = GoExcel.ChangeSourceOfLinked("pipe"," smallpipe.xlsx")

else if size = "medium" then

changeOK = GoExcel.ChangeSourceOfLinked("pipe", "mediumpipe.xlsx")

else if size = "large" then

changeOK = GoExcel.ChangeSourceOfLinked("pipe", "largepipe.xlsx")

end if

GoExcel.Tolerance

This function is used in conjunction with a GoExcel.FindRow function. The tolerance allows the iLogic to find a value on a spreadsheet within a specified range.

Example:

GoExcel.Tolerance = 0.10

i = GoExcel.FindRow("dims.xlsx", "Sheet1", "length", "=", 1.75)

mass= GoExcel.CurrentRowValue("mass")

MessageBox.Show(mass & " kg", "Title")

GoExcel.Tolerance = 0.10

i = GoExcel.FindRow("dims.xlsx", "Sheet1", "length", "=", 1.80)

mass= GoExcel.CurrentRowValue("mass")

MessageBox.Show(mass & " kg", "Title")

GoExcel.DisplayAlerts

GoExcel.DisplayAlerts = True

GoExcel.DisplayAlerts = False

This function can be used to prevent the displaying of Excel prompt dialog boxes. When the function is set to False, the Excel prompts are not displayed. When the function is set to True, the Excel prompts will be displayed.

GoExcel.Application

excelApp = GoExcel.Application

This function gives you access to the Excel Application object. Use this only if you have experience with the Excel COM interface. It's necessary to call another GoExcel function (to initialize the application) in the rule before using this statement.


Components and Feature Functions

iLogic provides rule functions for setting or reading feature and component suppression states, colors and thread designations, as well as a function for replacing one component with another. These functions are useful for driving different configurations of parts or assemblies. Creating a "Logimetric" model with iLogic involves over-designing the model (part or assembly) to include all of the geometry or components necessary to represent all possible valid configurations of a product. We call this method "super modeling". When the parts or assembly components are too complex or numerous and super modeling becomes impractical, the Component.Replace function is recommended.

The iLogic Component and Feature functions are accessible by clicking on the Component/Feature entry in the Function Categories window on the Rule Syntax tab on the iLogic Rule Editor.

Component.IsActive

Syntax:

Component.IsActive("ComponentName")

Set or read the suppression state of an assembly component using the component name.

This works on single components, or on component patterns. For patterns, use the pattern name. The pattern must be in the same level of the assembly as the rule. It can't be in a sub-assembly.

Suppressing sub-components is not recommended. It is better to do the suppression from a rule inside the component. Example:

An assembly named TopAssembly contains SubAssembly:1 which contains SamplePart:1.

It is better to have a rule inside SubAssembly to suppress SamplePart:1. This rule could have a parameter that drives the suppression state, and this parameter could be driven by a rule in TopAssembly.

When a component is suppressed with iLogic, it is represented as a Reference Component in the Bill of Materials dialog box. When the component is suppressed and then unsuppressed, iLogic returns the component back to the state it was in prior to suppression. [ Normal, Inseparable, Purchased or Phantom ]

Note: Suppressing or unsuppressing a component manually using the Inventor context menu does not change the BOM structure attribute. iLogic uses this method of suppression and unsuppression as a means of including or excluding components from a product configuration without deleting them.

Before using an iLogic rule to change the level of suppression state of a component in an assembly, you must create and save a new custom "Level of Detail" in place.

It is strongly recommended that you customize all component names before referencing the names in a rule. Changing the component name from the default name assigned by Inventor stabilizes it so that it will not change in the event the .ipt or .iam file it references ever changes.

You can actually change the component name back to the original name and it will still be stable. To do this: make a minor change to the name, and then change it back to the original.

For components placed from the Content Center, you have to change the name to stabilize it for iLogic functions. This is required even if you don't replace the component.

Examples (you can use 1 instead of "true" and 0 instead of "false" if you prefer)

Set

Component.IsActive("PartA:1") = false

Component.IsActive("PartB:1") = 0

Component.IsActive("PartC:1") = false

Component.IsActive("PartD:1") = 0

Read

MyBooleanParam = Component.IsActive("ComponentName:1)

If Component.IsActive("PartE") then

' do something

End If

Component.IsActive(MakePath("SubAssem1:1","Part2:1"))

Set or read the suppression state of an assembly component using the component name of the subassembly that contains it. "MakePath" is necessary only when identical component names exists in the assembly. Without MakePath, iLogic will look at the first instance of a component it finds in the case of duplicate names. Avoid using duplicate component names in assemblies if possible.

Component.iComponentIsActive("iPartParentName:1")

Set or read the suppression state of an iPart or iAssembly component using the component name. If you do not manually change the component name, then iParts and iAssemblies require the use of this dedicated syntax. The "iPart parent name" is the name of the factory part (without the .ipt).

It is recommended that you change the component name. Then you can use Component.IsActive instead of this function.

Component.Color

Component.Color("iPartA:1")

Examples:

Set

Component.Color("iPartA:1") = "Green"

Component.Color("iPartA:2") = "Aluminum (Cast)"

Component.Color("iPartA:3") = "As Material"

Read

MyStringParameter = Component.Color("iPartA:1")

Component.Visible

Component.Visible("componentName")

Examples

Set

Component.Visible("plate") = true

Component.Visible("bearing") = false

Read

parameter = Component.Visible("plate")

parameter = Component.Visible("bearing")

If Component.Visible("PartE") = true then

do something

End If

A component whose visibility has been turned off will be displayed on the Bill of Material whereas suppressed components will not. When a component is suppressed with iLogic, it is represented as a Reference Component in the Bill of Materials dialog box. When the component is suppressed and then unsuppressed, iLogic returns the component back to the state it was in prior to suppression. [ Normal, Inseparable, Purchased or Phantom ]

Component.SkipDocumentSave

Component.SkipDocumentSave = true

In this rule, do not save a component if it is changed and then suppressed.

Component.Replace

Component.Replace("ComponentToReplaceName", "OtherPartfilename.ipt", True)

Replace one part or subassembly with another by specifying the component name of the part to replace and the part file name of the part to replace it with. The third argument value can be:

True : replace all instances of this component

False : replace only the single instance that you name

NOTE: Before using this function you should "stabilize" the name of the component so that it doesn't change when the swap occurs. Do this by changing the name of the component. (You can actually change it once, and then change it back to the original name.) If you don't do this, the replace operation will change the component to match the different part name. Then the rule will be unable to find the component when it runs again.

Use iMates in components being swapped to keep the assembly constraints intact. It is possible to swap a part for a part, a part for an assembly or an assembly for a part.

This function will also work on component patterns.

Example:

if PartType = "Type A" then

Component.Replace("Widget","PartA.ipt", True)

elseif PartType = "Type B" then

Component.Replace("Widget","PartB.ipt", True)

end if

Component.Replace with Specified Level of Detail

Component.Replace("SubAssem:1", "OtherAssemFilename.iam<Level of Detail>", True)

Component.Replace("SubAssem:1", "OtherAssemFilename.iam<Level of Detail>", False)

This function allows the user to replace a component in an assembly with another component at a specific level of detail. The True or False entry in the rule indicates whether a single instance of a component or all of the instances of that component will be replaced.

Using this function, it is possible to replace a subassembly with the same subassembly at a different level of detail.

Component.ReplaceiPart

Component.ReplaceiPart("iPart1:1", "OtherPartfilename.ipt", True, rowNumber)

This is required for iParts with custom parameters, and it is recommended for standard iParts. Use this instead of Component.Replace when the component is an iPart. The "rowNumber" argument allows you to replace the component and choose an iPart row at the same time. You can use iPart.ChangeRow or iPart.FindRow after replacing to further change the particular iPart configuration.

For an iPart with custom parameters, list values for the custom parameters after the rowNumber. List them in the order they are found in the table. Example:

Component.ReplaceiPart("iPart1:1", "OtherPartfilename.ipt", True, rowNumber, customParam1, customParam2)

To set the custom parameters, you have to repeat the custom values in Component.ReplaceiPart and again in iPart.ChangeRow or iPart.FindRow after that in the rule.

Example using ChangeRow:

Component.ReplaceiPart("iPart1:1", "OtherPartfilename.ipt", True, rowNumber, customParam1, customParam2)

iPart.ChangeRow("iPart1:1", rowNumber, customParam1, customParam2)

Example using FindRow:

Component.ReplaceiPart("iPart1:1", "OtherPartfilename.ipt", True, rowNumber, customParam1, customParam2)

i = iPart.FindRow("iPart1:1", "Dia", ">=”, 3.0, ”r;|”, customParam1, customParam2)

MakePath

MakePath("SubAssemblyComponentName", "PartComponentName")

Function for defining a path in an assembly to a component name existing in a subassembly. List all sub-assembly levels in the order they appear in the tree. This function is necessary to specify a component name when the same name also exists elsewhere in the assembly.

Example

Component.IsActive(MakePath("SubAssem1:1", "Part2:1")) = true

Component.IsActive(MakePath("SubAssem1:1", "SubSubAssem2:1", "Part2:1")) = true

Feature Functions

Feature.IsActive

Feature.IsActive("featurename")

Set or read the suppression state of assembly or part features by specifying the feature name. Any Inventor part or assembly feature can be suppressed using this function. Changing the activation state of a feature automatically causes dependent features to follow suit. This means that you don't need to specify dependent features in your rule.

Manual changes to the activation state of a feature will not cause rules referencing them to fire automatically as Inventor provides no event handler for this action. Using a rule to drive a feature's activation state automatically overrides the feature properties suppression settings.

Changing the name of a feature reference in a rule requires the rule to be manually updated to reference the new feature name or the rule will give an error message next time it fires. It is recommended that you name all features accordingly before writing rules that reference them.

Feature names are a string type variable so they must always be enclosed by quotation marks.

Example:

if bracket_width >= 3 then

Feature.IsActive("flange_hole_pattern") = true

Feature.IsActive("base_hole_pattern") = true

else

Feature.IsActive("flange_hole_pattern") = false

Feature.IsActive("base_hole_pattern") = false

end if

Feature.IsActive("filename.ipt","featurename")

Set or read the suppression state of subassembly or part features by specifying the filename and featurename. Use this syntax to control the activation state of features in parts from an assembly level rule

Example

Set

Feature.IsActive("PartA.ipt","Hole1") = false

Read

MyStringParameter = Feature.IsActive("PartA.ipt","Hole:1")

Feature.Color

Feature.Color("featurename")

Set or read the color attribute of an assembly or part feature by specifying the feature name.

The color value is a string that must be enclosed in quotation marks and match the exact spelling and case of the colors available in the active standard of the current Inventor document.

Example:

Set

Feature.Color("Hole:1") = "Green"

Feature.Color("Hole:2") = "Aluminum (Cast)"

Feature.Color("Hole:3") = "As Material"

Read

MyStringParameter = Feature.Color("Chamfer:1")

Feature.Color("filename.ipt","featurename") set or read the color of subassembly or part features by specifying the filename and feature name.

Thread Functions

Feature.ThreadDesignation

Feature.ThreadDesignation("featurename") = "3/8 -16 UNC"

Set or read the thread designation of a thread feature in a part or assembly document. Thread designation is a string type variable that must be specified with the exact string as it appears in the Designation combo box of the threaded feature editing dialog.

For a tapered thread, specify the value that would show up in the Size box of the thread dialog. (This is usually a shortened version of the full thread designation.)

For some thread types, a valid thread designation for this function will not be the same as what shows up in the dialog box. In this case, create an iLogic string parameter named threadDes and use the following line of code to look at the current value of the designation:

threadDes = Feature.ThreadDesignation("Thread1")

This will show you the format that is needed.

When driving the thread designation with a rule the hole size will follow suit automatically.

When dealing with a threaded rod, you can use a rule to change the rod diameter and the thread designation at the same time. The rod diameter has to be compatible with the thread designation or Inventor will return an error message for the thread feature.

Example

if rod_type = "small" then

Feature.ThreadDesignation("Thread1") = "3/8-16 UNC"

rod_diamteter = .375

elseif rod_type = "large" then

Feature.ThreadDesignation("Thread1") = "1/2-13 UNC"

rod_diameter =.500

end if

You can set or read the thread designation of a thread feature in a part or assembly document from an assembly level rule by specifying the component or filename and the threaded feature name.
Examples:

Feature.ThreadDesignation("PartA.ipt", "featurename") = "1/2-13 UNC"

Feature.ThreadDesignation("PartA:1", "featurename") = "1/2-13 UNC"

Feature.SetThread

Feature.SetThread("featurename", "thread type", "thread designation", "thread class")

Make major changes to a hole or threaded feature. Set the type, designation and class. You can use this to switch between inch and metric threads. You cannot switch between a straight and a tapered thread.

Note: for a tapered thread, there is no thread class. Use an empty string ("") for the thread class. Also, use the Size instead of the Designation.

Feature.SetThread("componentName", "featurename", "thread type", "thread designation", "thread class")

Make major changes to a hole or threaded feature in a component.

Feature.ThreadType

currentType = Feature.ThreadType("featurename")

Get the thread type of a hole or threaded feature. (Examples: "ANSI Unified Screw Threads", "ANSI Metric M Profile")
To change the type, you have to use SetThread, and set the designation and class at the same time.

currentType = Feature.ThreadType("componentName", "featurename")

Get the thread type of a hole or threaded feature in a component

Feature.ThreadClass

Feature.ThreadClass("featurename") = "3B"

Set the thread class of a hole or threaded feature. A higher number means more accuracy.

currentClass = Feature.ThreadClass("featurename")

Get the thread class of a hole or threaded feature.

Feature.ThreadClass("componentName", "featurename") = "3B"

Set the thread class of a hole or threaded feature in a component.

Note: this does not apply to a tapered thread.

currentClass = Feature.ThreadClass("componentName", "featurename")

Get the thread class of a hole or threaded feature in a component.


Parameters Functions

Parameter

Parameter("parameterName")
(Formerly known as DynaParam. You can use the old name DynaParam or Parameter interchangeably to access these functions.)
This function allows you to change parameter values directly. It is most useful in assemblies to access parameters in components that may be suppressed. If the component is suppressed you can't access the parameter directly with an assignment statement. So instead of:

PartA.ipt.d12 = 6.3

you have to use

Parameter("PartA.ipt.d12") = 6.3

or

Parameter("PartA.ipt", "d12") = 6.3

If the part name might change, it's better to use the component name. You should rename the component manually so that Inventor will not change the component name if you replace the component. Then you can use the component name syntax:

Parameter("PartA:1", "d12") = 6.3

For the component name, you can also use the MakePath function:

Parameter(MakePath("SubAssem1:1", "Part1:1"), "d12") = 6.3

You can read the current value of a parameter:

param_val = Parameter("d0")

or

param_val = Parameter("PartA:1", "d0")

As shown in this case, the parameter can be in the current document. You can use any parameter (Inventor or iLogic) that can be accessed from the rule.

The "Parameter" function is useful if you want to change a parameter immediately. A standard assignment statement will not change the parameter in Inventor until the rule finishes (or you use RuleParametersOutput). (Here is an overview: Parameters In Rules)

Using Parameter together with the "Fire dependent rules immediately" option for the rule and the InventorVb.DocumentUpdate function is a good way to have changes to the Inventor model show up immediately while running a rule. Using RulesParametersOutput is more efficient. But Parameter is required in code running in an external DLL.

Parameter.UpdateAfterChange = True

This will cause an Inventor model update to happen after every change you make to a parameter value using the Parameter function. This is not very useful in rules within the model, because it will cause too many updates. It is more useful in code that you might create for a custom dialog box.

Parameter.Quiet = True

If a parameter is not found, you would normally get an error message. Setting Parameter.Quiet = true will suppress this message. Use this if you know the parameter is missing (maybe it doesn't exist in every part that the rule applies to) and you are ready for that condition.

Advanced Parameter Functions

You can access more properties of an Inventor parameter using

param = Parameter.Param("parameterName")
param = Parameter.Param("componentName", "parameterName")

This gives you an object of the class Inventor.Parameter. See the Inventor API Reference for properties and methods available on this object.

Here is an example

param = Parameter.iLogicParam("parameterName")

param = Parameter.iLogicParam("componentName", "parameterName")

Use this to access an iLogic parameter. It gives you an object of the type iLogicParameter, which is defined in iLogic Automation Interfaces

MultiValue Functions

These functions allow you to access and change the list of values that are stored with a multivalue parameter.

MultiValue.SetList("d0", 0.5, 0.75, 1.0, 1.25)

This example shows how to set the list of available values for the parameter "d0".

MultiValue.SetList("d0", "3/8", "d1 * 2", "d1 * 3")

Set equations instead of values. You can mix equations and values in the list.

MultiValue.SetList("filename.ipt.str0", "Value1", "Value2")

Sets a list of values for a string parameter.

MultiValue.SetList("Part1:1", "d0", 0.5, 0.75, 1.0, 1.25)

Sets the list of values of a parameter in a component.

values = MultiValue.List("d0")

Gets the current list of values. The variable "values" is an object of the VB type ArrayList.

MultiValue.List("d0") = New Double() {0.5, 0.75, 1.0, 1.25}

This is another way to set the list of values. Examples using values from Excel can be found here: GoExcel.CellValues

MultiValue.SetValueOptions(True, DefaultIndex := 0, NumericCompare := "=")

Sets an option for MultiValue. After you use this, when you change the multivalue list of a parameter it will also set the current value of the parameter to one of the values in the list. If its current value is in the list it will not be changed. So you can force the parameter to always have a value that is in the list. The default arguments are shown:
DefaultIndex := 0 ' this means that if the current parameter value is not in the new list, the parameter will be set to the first value (Index 0) in the list
NumericCompare := "=" ' test for equality. You can also use "<=" or ">="

MultiValue SetValueOptions Notes

MultiValue.SetValueOptions(False)

With this setting, when you change the multivalue list of the parameter, the actual value of the parameter does not change. This is the default behaviour of MultiValue.

MultiValue.UpdateAfterChange = True
This is similar to Parameter.UpdateAfterChange. If you make changes to Mulitvalue lists, with the SetValueOptions set to True, it might change the current value of the parameter. Setting UpdateAfterChange to true will cause the Inventor model to update immediately. See the note for Parameter.UpdateAfterChange

MultiValue.Quiet = True
If the parameter is not found, you would normally get an error message. Setting MultiValue.Quiet = True will suppress this message. Use this if you know the parameter is missing (maybe it doesn't exist in every part that the rule applies to) and you are ready for that condition.

foundVal = MultiValue.FindValue(aList, "<=", 4.0)

This will find a value in a list that matches a condition most closely. "aList" can be an ArrayList or Array. The comparison argument can be "<=", "=" or ">=". This example will find the value which is less than or equal to 4.0, and if there is more than one it will return the value that is closest to 4.0. If there is no value that matches it will return the VB constant "Nothing". You can test for this condition.

Shared Variable Functions

iLogic shared variables are shared between rules. They are stored in computer memory. Unlike Inventor and iLogic parameters, they aren't associated with any part or assembly. You can use them instead of Inventor or iLogic parameters to pass data between rules. You can also use them to store data that can't be stored in Inventor or iLogic parameters.

SharedVariable("Thread1") = "1/4-20 UNC"

This assigns a string value to a shared variable called "Thread1". It creates the variable if it doesn't exist.

s0 = SharedVariable("Thread1")

This assigns the value of a shared variable to a string parameter. You know what type the variable is since you have created it previously.

SharedVariable("Distance1") = 7.2

This assigns a number to a shared variable.

d0 = SharedVariable("Distance1")

This assigns the value of a shared variable to an Inventor parameter.

if SharedVariable.Exists("Thread1") then

This tests whether a parameter exists or not. You might need to use this if the parameter was created in another rule.

SharedVariable.Remove("Thread1")

Remove (delete) a shared variable. This is not required, but it is a good idea if you know you no longer need the parameter.

SharedVariable.RemoveAll()

Remove all shared variables. Use this with care in a rule, because you might have other unrelated parts and assemblies open that use shared variables. Instead of this function, you can use the manual command Clear iLogic Memory on the iLogic Utilities dialog.


iProperties

iProperties Functions

iLogic provides rule functions for setting or getting the iProperties of Inventor part and assembly documents. As rules are used to morph or modify designs into new configurations, you will want to keep the iProperties of the design documents up to date. iProperties need to be up to date in order for the Bill of Materials to be correct. Rules can also be used to read the iProperty values of a document and react to them. For example, you may have a rule that causes the thickness of a part to change when the material property changes. You could have a part's colors change automatically when the weight of the part exceeds a maximum or minimum for a type of conditional formatting. Any iProperty that can be set manually can be set or read using a rule.

iProperties.Value

Summary, Project, Status and Custom iProperties Functions

Syntax:

iProperties.Value("property tab name", "property name")

iProperties.Value("filename.ipt", "property tab name", "property name")

Use this syntax method in assembly level rules to access the iProperties of a part or subassembly.

Note that if the part or sub-assembly file name changes, the rule text must be changed to suit.

It's often better to use the component name (after customizing it) rather than the file name as shown below.

iProperties.Value("custom component name", "property tab name", "property name")

This syntax method uses the component name rather than the file name. Customize the component name (change it from its original default name) so that it will not change if the file reference changes. This syntax is required for setting or reading the property values of virtual type assembly components.

Examples

Set

iProperties.Value("Summary","Subject") = "Set the Properties"

Read

MyStringParam = iProperties.Value("Summary","Subject")

Custom iProperties Examples

Set

iProperties.Value("Custom","Age") = 41 'number type

iProperties.Value("Custom","Company") = "Autodesk, Inc" 'text type

iProperties.Value("Custom","Date") = CDate("11/1/2008") ' date type

iProperties.Value("Custom","Insured") = true 'yes or no type

Read

age = iProperties.Value("Custom", "Age")

company = iProperties.Value("Custom","Company")

thedate = CStr(iProperties.Value("Custom","Date")

insured = iProperties.Value("Custom","Insured")

Note:

Most properties are strings. Properties that have "date" in their name are dates.
Often you don't have to be aware of the property types because VB.NET will automatically convert the value for you.
The "Estimated Cost" property (under Project) is a number.
The "Design State" property (under Status) is a special case. You have to use a number, although it shows up in the iProperties editor as a list of choices. Here is a rule snippet using temporary variables:

Work_In_Progress = 1

Pending = 2

Released = 3

iProperties.Value("Status", "Design State") = Pending

Deprecated Functions

Previous versions of iLogic used the following functions to get the iProperties from parts in assemblies. The iProperties.ValueInDoc function references the file name and the iProperties.ValueInComponent function references the name of the customized component name. These functions are not listed the Function window on the Rule Syntax tab of the Rule Editor but they will work if used in a rule. It is preferred practice not to use these older functions.

iProperties.ValueInDoc("filename.ipt", "property tab name", "property name")

iProperties.ValueInComponent("custom component name", "property tab name", "property name")

Physical iProperties Functions

iProperties.Material

Use this syntax to set or read the material of a document.

When setting the material you must use the exact material name (case sensitive) as it exists in the active standard physical materials list.

Material values are always string type which requires they be enclosed within quotation marks

Examples

Set

iProperties.Material = "Gold"

Read

MyStringParam = iProperties.Material

iProperties.MaterialOfDoc("filename.ipt")

Use this syntax to set or read the material property of assembly virtual type components.

iProperties.MaterialOfComponent("componentname:1")

Use this syntax method in an assembly level rule to access the material properties of a part included in an assembly using the component name. (change it from the default assigned in order to prevent the name from changing if the file name referenced ever changes.)

iProperties.PartColor

Use this syntax to set or read current Part Color of a document.

This function only applies in part level rules.

Part Color values are string type, which requires them to be enclosed in quotation marks.

Changing the color does not affect the current material value.

Examples

Set

iProperties.PartColor = "Green"

iProperties.PartColor = "As Material"

Read

MyStringParam = iProperties.PartColor

MultiValue.List("MyStringParam") = iProperties.Material

Use this syntax to set an iLogic string parameter to a list of values equivalent to the list of materials available in the current active standard.

Physical iProperties Mass and Volume Functions

iProperties.Mass

The mass properties of a part or component can be read or set using iLogic function functions. These functions work in the document units.

iProperties.Mass

Read or write the mass of the document (part or assembly) that the rule is in.

iProperties.MassOfDoc("filename.ipt")

Read or write the mass of a part or assembly in an assembly level rule, referencing the filename.

iProperties.MassOfComponent("component name:1")

Read or write the mass of a component, in an assembly level rule referencing the component name.

Use this syntax to read or write to the mass of a virtual type assembly component.

Examples

Read

MyMassParam = iProperties.Mass

MyMassParam = iProperties.MassOfCompopnent("component:1")

MyMassParam = iProperties.MassOfDoc("mypart.ipt")

Set (override automatic calculation)

iProperties.Mass = 3

iProperties.MassOfComponent("virtual_component") = 3

iProperties.MassOfDoc("mypart.ipt") = 3

iProperties.Mass = -1 'set it back to automatic calculation

iProperties.Volume

iProperties.VolumeOfDoc("filename.ipt")

Read or write the volume of the document that the rule is in.

iProperties.VolumeOfComponent("component:1")

Read or write the volume of a component, in an assembly level rule referencing the component name.

Use this syntax to read or write to the volume of a virtual type assembly component.

Examples

Read

MyVolumeParam = iProperties.Volume

MyVolumeParam = iProperties.VolumeOfCompopnent("component:1")

MyVolumeParam = iProperties.VolumeOfDoc("mypart.ipt")

Set (override automatic calculation)

iProperties.Volume = 3

iProperties.VolumeOfComponent("virtual_component") = 3

iProperties.VolumeOfDoc("mypart.ipt") = 3

iProperties.Volume = -1 'set it back to automatic calculation

iProperties.CenterOfGravity

pt = iProperties.CenterOfGravity

Read the center of gravity of the model in the document the rule is in.

pt is of the type Inventor.Point

You can read the X, Y and Z values of the point (which are in the units of the rule document):

cx = pt.X

cy = pt.Y

cz = pt.Z

pt = iProperties.CenterOfGravityOfComponent("component")

Read the center of gravity of a component in an assembly level rule.

iProperties.Area

surfaceArea = iProperties.Area

Read the surface area of the model in the document that the rule is in.

surfaceArea = iProperties.AreaOfComponent("component:1")

Read the surface area of a component, in an assembly level rule.


Assembly Constraints

Assembly Constraint Functions

iLogic provides rule functions for driving the suppression status of assembly constraints. Driving the suppression state of constraints is necessary when defining assembly level configurations with iLogic rules. For example, if you want to define alternate locations for a component in an assembly, you can define all of the mates necessary to constrain the component in each location and then use a rule to suppress and unsuppress the mates as necessary to relocate the component for each configuration. Because Inventor does not allow conflicting constraints, it is necessary to create the constraints for each position of a component and then manually suppress them before creating the next set of constraints required for the alternate position/s of the component. Once you have created all of the constraints to locate the component for each configuration, you can write the rules necessary to manage the suppression states of all of the constraints.

Constraint Functions

C onstraint Functions are available on the Rule Syntax tab by clicking in the Constraint option in the Function Window at the top right of the iLogic Rule Editor.

Constraint.IsActive

Syntax

Constraint.IsActive("Mate:1")

Constraint.IsActiveInDoc("SubAssem.iam", "Mate:1")

Constraint.IsActiveInDoc("SubAssem.iam", "Mate:1")

Constraint.IsActive("Mate:1")

S et or read the suppression state of a top level assembly mate by specifying the name of the mate.

It is recommended to give each mate to be referenced in a rule a unique custom name so that:

- The rules are more easily understood

- Renaming a mate ”stabilizes” the name so that it is not subject to change automatically for some reason resulting in errors when the rules fire.

Note that manually changing the suppression state of a mate will not cause rules that reference it to fire automatically.

Examples:

Set

If ConfigStyle = ”A” then

Constraint.IsActive("MateLeftSide:1") = true

Constraint.IsActive("MateRightSide:2") = false

Elseif ConfigStyle = ”B” then

Constraint.IsActive("MateLeftSide:1") = false

Constraint.IsActive("MateRightSide:2") = true

end if

Read

If Constraint.IsActive("MateLeftSide:1") = true then (Do something)

Constraint.IsActiveInDoc("SubAssem.iam","Mate:1")

Set or read the suppression state of a sub-assembly level mate by specifying the sub-assembly file name and name of the mate.

It is recommended to give each mate to be referenced in a rule a unique custom name so that:

- The rules are more easily understood

- Renaming a mate "stabilizing" the name so that it is not subject to change automatically for some reason resulting in errors when the rules fire.

If you plan on copying and renaming all of the files in an assembly while keeping all of the rules intact, use Constraint.IsActiveInComponent where the subassembly component name is used instead of the file name.

Examples:

Set

If ConfigStyle = ”A” then

Constraint.IsActiveInDoc("SubAssem.iam",”LeftMate”) = true

Constraint.IsActiveInDoc("SubAssem.iam",”RightMate”) = false

Elseif ConfigStyle = ”B” then

Constraint.IsActiveInDoc("SubAssem.iam",”LeftMate”) = false

Constraint.IsActiveInDoc("SubAssem.iam",”RightMate”) = true

end if

Read

Constraint.IsActiveInDoc("SubAssem.iam",”LeftMate”) = true then (Do something)

Constraint.iMateDefIsActive - iMate Suppression

Constraint.iMateDefIsActive("iMate:1") = False

This will suppress the iMate with the name "iMate:1", in the current rule document. This produces the same result as suppressing it with the context menu in the user interface.

Constraint.iMateDefIsActive("SubAssem:1","iMate:1") = False

This will suppress the iMate with the name "iMate:1", in the component "SubAssem:1"

Similarly:

Constraint.iMateDefIsActive("PartA:1","iMate:1") = True

This will unsuppress the iMate with the name "iMate:1", in the component part "PartA:1"


iPart Functions

iLogic provides special functions for driving iPart and iAssembly configurations in an assembly using rules. A rule can be used to automatically change the current configuration of iParts/iAssemblies based on the conditions and logic you define.

Available Functions

iPart.ChangeRow switch the active row in an iPart/iAssembly table.

iPart.FindRow search the iPart/iAssembly table by column to find a row containing a specific or approximate value and set the active configuration to the row found.

iPart.CurrentRowValue once a row has been found using "iPart.FindRow", this function is used to read associated column values (numerical type) from that row.

iPartCurrentRowStringValue once a row has been found using "iPartFindRow", this function is used to read associated column values (string type) from that row.

iPart.ChangeRow

Syntax Format and Specifications

iPart.ChangeRow("iChangedComponentName:1","rowName")

"iChangedComponentName:1" is the name of the component as you see it in the Inventor assembly browser. You must manually change the default component name assigned by Inventor in order to stabilize it so it will not change when the table configuration row is modified.

"rowname" is the name assigned to the row in the Member column of the table

iPart.ChangeRow("iChangedComponentName:1","rowName", customParam1,customParam2)

For a custom iPart, you put the custom parameters after the "rowName", in the same order as they appear in the table.

This also works for FindRow. Because FindRow already has a variable number of parameters, you have to add a marker (";" or "|" or "/") in the list:

iPart.FindRow

i=iPart.FindRow("iChangedComponentName:1","columnName","<=",0.2,"columnName","<=", 4.1,"|",customParam1,customParam2)

i=iPartFindRow("iChangedComponentName:1","columnName", "<=",d1,"columnName","<=",d2)

"i =" is a local variable that can be used to test if a valid row number is found

"iChangedComponentName:1" is the name of the component as you see it in the Inventor assembly browser. You must manually change the default component name assigned by Inventor in order to stabilize it so it will not change when the table configuration row is modified.

"columnName" is the column in the iPart table to search. Use the column header name exactly as it appears in the iPart table. Be aware that the key columns header names require a suffix (columnName <key>0</key>) not seen in the iPart table but only visible by viewing the table using Excel. iLogic will not find key columns if the complete column name including the suffix is not specified. iLogic rules eliminate the need for key parameter columns in iPart table so it is best not to use them or remove them if manual table usage is not a requirement.

iPart.FindRow("iParentFileName:1","columnName","<=",d1,"columnName","<=",d2)

"iParentFileName:1" refers to the iPart parent file name with ":1" inserted in the place of the usual .ipt or .iam extension.

Although this syntax is supported, it is not recommended in cases where the parent file name is subject to change in the event of the part being replaced in the assembly by a new iPart with a different name. Rules referencing file names will fail when those file names change unless the rule is updated accordingly.

iPart.CurrentRowValue

d0 = iPart.CurrentRowValue("columnName")

The current row is set by iPart.FindRow or iPartChangeRow.

"columnName" refers to the name of the iPart table column you want.

iPart.RowValue can only be used to read numerical values. Use the iPart.CurrentRowStringValue function to read columns containing string values.

iPart.CurrentRowStringValue

iPart.CurrentRowStringValue("PartNumber [Project]")

This is identical to the iPart.CurrentRowValue function except that it is dedicated to reading iPart columns containing string type values.

When reading the "Part Number" column from an iPart table you must include"[Project]" as a suffix to the column name. This suffix is only visible if you edit the iTable using Excel.

Examples

iPart.Findrow,iPartCurrentRowValue Example

In this example we search the Port_Size column of the "port_1_flare_flange" iPart table for an exact value matching the value of the Inventor parameter named "Port_1_Size". Once the row is found we use "iPart.CurrentRowValue" to retrieve the dimensions from the "A_dim" and"B_dim" columns of the table and assign their values to the Inventor parameters named "Port_1_screw_A_dim" and "Port_1_screw_B_dim".

i = iPartFindRow("port_1_flare_flange","Port_Size","=", Port_1_Size)

Port_1_screw_A_dim = iPart.CurrentRowValue("A_dim")

Port_1_screw_B_dim = iPart.CurrentRowValue("B_dim")

iPart.ChangeRow Example #1

In this example, the current iPart configuration is changed based on a conditional statement evaluating an Inventor user parameter named "Port_1_Size". iPart.ChangeRow requires only the iPart component name ("port_1_Flange_screw") and the iPart table "Member" name ("Screw-01") in order to drive the active iPart configuration.

If Port_1_Size = .50 then

iPart.ChangeRow("port_1_flange_screw","Screw-01")

else if Port_1_Size = .75 then

iPart.ChangeRow("port_1_flange_screw","Screw-02")

else if Port_1_Size = 1.00 then

iPart.ChangeRow("port_1_flange_screw","Screw-03")

end if

iPart.FindRow Example2

The example below searches an iPart table for a row with column values that are equal to or greater than the values being searched for. iLogic switches the current iPart configuration to the row found automatically with no further coding required.

The code in this example finds row number 5 as the match according to the operators used.

iPart.FindRow("port_1_flange_screw","Thread_Diameter",">=", .45, "Thread_Length", ">=",2.0)

iPart.Tolerance

iPart.Tolerance = 0.0000001

This function allows the user to state a tolerance for conducting searches in an iPart table

Example

Given an assembly consisting of two iParts that are governed by the following iPart parameter table.

iPart.Tolerance = 0.05

i = iPart.Find Row("block1","length", "=",2.30)

i = iPart.Find Row("block2","length", "=",2.31)

In the second line of the rule, the iLogic iPart function will search the table for the iPart block1. iLogic will look in the column named "length" for an entry equal to 2.30. If the first line of the rule was not included, iLogic would not find any valid entries in the "length" column since no entry matches 2.30 in.

Including the following line results in "expanding the range of acceptable values"

iPart.Tolerance = 0.05

The command

i = iPart.FindRow("block1","length","=",2.30) becomes equivalent to

i = iPart.FindRow("block1","length",">=",2.25,"length","<=",2.35)

There is a value between 2.25 and 2.35 in the length column of the iPart table [ 2.25 in row #4]

The command

i = iPart.FindRow("block1","length","=",2.31) becomes equivalent to

i = iPart.FindRow("block2","length",">=",2.26,"length","<=",2.36)

In spite of the fact that the tolerance has been "relaxed", there is no value between 2.26 and 2.36 in the length column of the iPart table.

Component.ReplaceiPart

Component.ReplaceiPart("iPart1:1", "OtherPartfilename.ipt", True, rowNumber)

This is required for iParts with custom parameters, and it is recommended for standard iParts. Use this instead of Component.Replace when the component is an iPart. The "rowNumber" argument allows you to set the row immediately during the replace operation. You can use iPart.ChangeRow or iPart.FindRow after replacing to further change the particular iPart configuration.

For an iPart with custom parameters, list values for the custom parameters after the rowNumber. List them in the order they are found in the table. Example:

Component.ReplaceiPart("iPart1:1", "OtherPartfilename.ipt", True, rowNumber, customParam1, customParam2)

To set the custom parameters, you have to repeat the custom values in Component.ReplaceiPart and again in iPart.ChangeRow or iPart.FindRow after that in the rule.

Example using ChangeRow:

Component.ReplaceiPart("iPart1:1", "OtherPartfilename.ipt", True, rowNumber, customParam1, customParam2)

iPart.ChangeRow("iPart1:1", rowNumber, customParam1, customParam2)

Example using FindRow:

Component.ReplaceiPart("iPart1:1", "OtherPartfilename.ipt", True, rowNumber, customParam1, customParam2)

i = iPart.FindRow("iPart1:1", "Dia", ">=”, 3.0, ”|”, customParam1, customParam2)

See also iFeature Functions


iFeature Functions

These functions are used to choose a configuration (row) in a table driven iFeature.
They are listed in the iPart category on the Rule Syntax tab of the iLogic Rule Editor.

iFeature.ChangeRow

iFeature.ChangeRow("iFeatureName", "rowName")

This function allows the user to switch the active row in an iFeature parameter table.

Syntax Format and Specifications

iFeature.ChangeRow("iFeatureName", "rowName")

"iFeatureName" the name of the iFeature as you see it in the model tree.

"rowName" the name assigned to the Key Row in the iPart parameter table.

Example

In this example, the current iFeature configuration is changed based on a conditional statement evaluating an Inventor user parameter named "size". iFeature.ChangeRow requires only the iFeature component name ("RectangularPocket1") and the iFeature table "Key Column" name ("Pocket-01") in order to drive the active iFeature configuration.

if size = "small" then

iFeature.ChangeRow("RectangularPocket1", "Pocket-01")

else if size = "medium" then

iFeature.ChangeRow("RectangularPocket1", "Pocket-02")

else if size ="large" then

iFeature.ChangeRow("RectangularPocket1", "Pocket-03")

else if size ="very large" then

iFeature.ChangeRow("RectangularPocket1", " Pocket-04")

end if

iFeature.FindRow

i = iFeature.FindRow("iFeatureName", "columnName", "<=", 0.2, "columnName", "<=", 4.1)

This function searches for a row based on one or more column value search criteria

"iFeatureName”- name of the table-driven iFeature that is subject to the search

"columnName” &endash; title of the column to be searched

Operator

"=” find a row with a value equal to the value being search for in the column

">=” find a row with a value equal to or greater than the value being search for in the column

">=” find a row with a value equal to or greater than the value being search for in the column

Value &endash; this can be a numerical value, string, parameter or a local variable

Returns

Row number (integer) where the cell value in the searched column matches search criteria

Errors

-1 on error

iFeature.CurrentRowValue("columnName")

This function will read a value from the row found using the iFeature.FindRow function.

"columnName" - column title name for cell a value to be retrieved from the current row as found by the previous GoExcel.FindRow function.

Returns

Cell value of current row value returned by GoExcel.FindRow function.

Errors

If column does not exist in the iFeature, the rule will not compile

Example

i = iFeature.FindRow("RectangularPocket1", "pocketdepth", "=", 0.250)

pocketlength = iFeature.CurrentRowValue("pocketlength")

pocketwidth = iFeature.CurrentRowValue("pocketwidth")

iFeature.CurrentRowStringValue("columnName")

This function used when the entry being sought in the iFeature table is text rather than numerical.

Example

Part_number = iFeature.CurrentRowStringValue("Part Number")

iFeature.Tolerance

iFeature.Tolerance = 0.0000001

This function is used in conjunction with the iFeature.FindRow function. Including the iFeature.Tolerance function in a rule allows iLogic to search for a value within a range rather than searching for a specific value.

Set the tolerance by specifying the value in the function.

Example 1:

For a tolerance of .25, the function would be:

iFeature.Tolerance = 0.25

Example 2:

Consider the iFeature with the parameter table shown below.

Case 1

i = iFeature.FindRow("insertpocket", "pocketlength", "=", 1.875)

MessageBox.Show(i, "Row Number")

The table for the iFeature called ”insertpocket” includes a value of 1.875 in the column called ”pocketlength”. The first line of the rule instructs iLogic to search the table for the iFeature called ”insertpocket”. iLogic will look for a value of 1.875 in the column named ”pocketlength”. 1.875 is found in Row #3.

iLogic will find the value 1.875 in Row #3 in the "pocketlength" column.

The second line of the rule creates the message box indicating the row number.

Case 2

i = iFeature.FindRow("insertpocket", "pocketlength", "=", 1.88)

MessageBox.Show(i, "Row Number")

In this case, iLogic will not find any values in the "pocketlength" column to match 1.88 exactly. iLogic will return a value of -1 for the row number.

Case 3

iFeature.Tolerance = 0.010

i = iFeature.FindRow("insertpocket", "pocketlength", "=", 1.88)

MessageBox.Show(i, "Row Number")

If the iFeature.Tolerance function is included, the iFeature.FindRow function will search the "pocketlength” column of the table for an entry within in a range of values rather than a specific value.

Adding the iFeature.Tolerance = 0.010 line to the rule will cause iLogic to search for a table entry in the range 1.87 to 1.89.

The table entry of 1.875 is within this range and iLogic will locate it on the table in Row #3


Measure Functions

The Measure Functions can be accessed from the Function Categories list on the Rule Syntax tab in the Rule Editor.

Distance and Angle Measurement

Measure.MinimumDistance and Measure.Angle measure distance or angle between two (or three for angle) entities. They can accept these kinds of entity names:

A) A work feature (work plane, work axis or work point). This can be a standard Inventor work feature such as "XY Plane" or "X Axis"
or
B) An iMate that is attached to a face, edge or vertex (This is a way to give the element a permanent name. You don't have to use the iMate for a constraint. The iMate can be suppressed.)

The entities can be in the same part or assembly, or in different components within an assembly.

Measure.MinimunDistance can also measure between two components in an assembly, looking at the components as a whole.

When using the measure functions in a rule, you probably want to include RuleParametersOutput and InventorVb.DocumentUpdate() function before the measure functions.

This will ensure that the measure function is examining an updated version of the Inventor model.

Distance Measurement

Measure.MinimumDistance

Measure.MinimumDistance("entityName1", "entityName2")

Measure the minimum distance between two points, two planes or two axes. The function can also measure the distance between a plane and a point, a plane and an axis and a point and an axis.

Example: Point to Point

distance = Measure.MinimumDistance("Work Point1", "Work Point2")

Example: Point to Axis

distance = Measure.MimimumDistance("Work Point1", "Work Axis1")

Example: Axis to Axis

distance = Measure.MinimumDistance("Work Axis1", "Work Axis2")

Example: Plane to Plane

distance = Measure.MinimumDistance("Work Plane1", "Work Plane2")

This function can also be used at the assembly level to measure distances between entities defined at the assembly level. Distances can be measured between two points, two planes or two axes. The function can also measure the distance between a plane and a point, a plane and an axis and plane and a point.

Measure.MinimumDistance("componentName1", "entityName1", "componentName2", "entityName2")

Measure the distance between entities on two components in an assembly. These entities can be points, planes or axes.

distance = Measure.MinimumDistance("componentName1", "entityName1", "componentName2", "entityName2")

Example: Plane to Plane distance between two components in an assembly

distance = Measure.MinimumDistance("componentName1", "entityName1", "componentName2", "entityName2")

distance = Measure.MinimumDistance("Wheel1", "Work Plane1", "Wheel2", "Work Plane2")

Measure.MinimumDistance("componentName1", "componentName2")

This function measures the minimum distance between the two components of an assembly. It looks at the components as a whole, and finds the closest points anywhere on the components.

distance = Measure.MinimumDistance("partA:1", "partB:1")

distance = Measure.MinimumDistance("Wheel1", "Wheel2")

Caution!

Axis to Axis Measurement

Exercise caution when measuring the distance between two non-parallel axes. Consider the following scenario. An assembly is made of two blocks as shown in the diagram. The angle between the faces of the blocks is 60 degrees. Each block has a hole located at the middle of the top (and bottom) face of the block. The axes of these two holes are non-parallel coplanar lines which intersect. When the Measure.MinimumDistance function is used, the distance will be measured from the closest end points of the two markers used to represent the axes locations. Although it would be expected that the minimum distance between the two axes is zero. The number returned by the Measure.MinimumDistance function is 1.36 inches.

distance = Measure.MinimumDistance("Block1","Axis1","Block2","Axis1")

To counter this difficulty, manually extend the lines representing the axes of the holes. Now, the Measure.MinimumDistance function will return the value of 0 inches, as expected for intersecting lines.

Measure.Angle

angle = Measure.Angle("entityName1","entityName2")

This function measures the angle between two entities at the part level. This function can measure the angle between two axes, two planes or an axis and a plane. The entities can be work features or iMates.

angle = Measure.Angle("componentName1","entityName1","componentName2","entityName2")

This function measures the angle between two entities in two components at the assembly level. This function can measure the angle between two axes, two planes or an axis and a plane.

angle = Measure.Angle("entityName1","entityName2","entityName3")

This function measures the angle between the two lines defined by three points included in the parentheses. "entityName2" defines the vertex of the angle. This function is intended for use at the part level.

angle = Measure.Angle("componentName1","entityName1","componentName2","entityName2","componentName3","entityName3")

This assembly function measures the angle between the two lines defined by three points included in the parentheses. "entityName2" defines the vertex of the angle. Each point can be in a different component.

Other Measure Functions

Measure.Area("sketchName")

This function measures the sum of the areas of the regions enclosed by the closed profiles in a sketch.

If the sketch contains multiple closed profiles, the function will calculate the sum of the areas enclosed by the profiles. If the closed profiles intersect then the function will calculate the sum of the areas enclosed.

If the sketch contains multiple profiles with one of the profiles contained completely in the other one, the Measure.Area function will give the difference of the two areas.

Measure.Perimeter("sketchName")

This function measures the sum of the perimeters of the closed profiles in a sketch. For a sketch containing a single closed profile, the function calculates the length of the perimeter of the profile.

Example: A Single Profile

size = Measure.Perimeter("Sketch1")

For a sketch containing non intersecting multiple closed profiles, the function calculates the sum of the lengths of all of the perimeter of the profile.

Example: Multiple Closed Profiles - Non Intersecting

size = Measure.Perimeter("Sketch1")

For a sketch containing intersecting multiple closed profiles, the function calculates the sum of the lengths of all of the perimeter of the profile.

Example: Multiple Closed Profiles - Intersecting

size = Measure.Perimeter("Sketch1")

Extents Measure Functions

These functions get the X, Y and Z dimensions of the extents of a part or assembly. The extents might be larger than the exact dimensions of the model along that axis, especially if there are curved shapes.

Measure.ExtentsLength

Gets the X extent (along the red axis) of the model.

Measure.ExtentsWidth

Gets the Y extent (along the green axis) of the model.

Measure.ExtentsHeight

Gets the Z extent (along the blue axis) of the model.


Work Feature Functions

These functions can modify existing work features.

WorkPlane.FlipNormal(workPlaneName, axisWanted)

Flip the normal vector of a work plane. This flips the work plane over. If there is a sketch built on the plane, it will be flipped over as well. This can be used to change a feature from left-handed to right-handed. It is most useful for a mid-plane extrusion.
This doesn't flip the normal every time you use it. Instead, it ensures that the normal is in the direction you want. It might flip the normal, or it might not. It will flip the normal if it is not "in agreement" with the axis you specify.
The first argument to the function is the work plane name.
The second argument is the name of a part axis, with optional "-" sign to indicate the direction. This gives the function the approximate direction for the plane normal. If the plane is not exactly aligned to a model axis, use the axis that is closest to the plane normal you want. (Alignment within 60 degrees is OK).

For instance:

WorkPlane.FlipNormal("Work Plane1", "X")
WorkPlane.FlipNormal("Work Plane1", "-X")
WorkPlane.FlipNormal("Work Plane1", "Y")
WorkPlane.FlipNormal("Work Plane1", "-Y")
 WorkPlane.FlipNormal("Work Plane1", "Z")
WorkPlane.FlipNormal("Work Plane1", "-Z")

Sketch Functions

Sketch.Redefine(sketchName, planeName, originName, axisName, AxisIsX := True, NaturalAxisDirection := True )

Redefine a sketch: choose different inputs to define it. This works best on self-contained sketches, without any projected geometry. All sketch geometry should be dimensioned from the origin point, or somehow constrained to the origin. To have names to give as input, the sketch must be defined using named items, which can be:

A) work features
B) standard planes or axes
C) faces, edges or vertices that have iMates associated with them
(This way of using entity names is also used by the Measure Functions.)

A rguments:

sketchName | Name of the sketch
planeName | Name of an entity to use as the sketch plane
originName | Name of an entity to use as the origin point of the sketch
axisName | Name of an entity to use as a sketch axis (either the X or Y axis, see below)
AxisIsX | True (the default) means that the axis specified by axisName will be the X (Horizontal) axis of the sketch. False means that the axis specified by axisName will be the Y (Vertical) axis of the sketch.
NaturalAxisDirection | True (the default) means that the sketch axis should have the same direction as the axisName entity. False means that the sketch axis should have the opposite direction to the axisName entity


iLogic Sheet Metal Functions

Sheet Metal Functions

iLogic provides rule functions for setting and reading the current Sheet Metal Style (aka Sheet Metal Rule) and KFactor in a sheet metal document. These functions make it possible to change the current Sheet Metal Style automatically with a rule based on certain conditions such as the current material or material thickness.

Sheet Metal Functions:

SheetMetal.SetActiveStyle | set the active Sheet Metal Style with an option to set the KFactor at the same time.
SheetMetal.GetActiveStyle | get (read) the active Sheet Metal Style
SheetMetal.ActiveKFactor | set or get the Active KFactor (Note: Currently only getting the active KFactor is supported)

SheetMetal.SetActiveStyle

Syntax Usage:

SheetMetal.SetActiveStyle("styleName")
Set the current active Sheet Metal Style by specifying a name from the Style List in the Sheet Metal Styles Dialog.

Examples:

SheetMetal.SetActiveStyle("MyStyle") where "MyStyle" is the actual name of the style in the list.
SheetMetal.SetActiveStyle(MyStyleParameter) ' where MyStyleParameter is an iLogic String type parameter.

sheet metal styles list image

The Style Name specified must match the available names in the Sheet Metal Rule list, but is not case sensitive.

Note: What is a K Factor? During bending the inner surface of the bend is subjected to compression while the outer surface is subjected to tension. However there is a layer in between that is free from any forces and thus its length remains the same. This is called the neutral axis. The radius of this layer of metal is called the neutral bend arc radius and is defined as the inside bend radius plus a percentage of metal thickness. The K Factor depends on the material, the type of bending operation, the ratio of the bend radius to the metal thickness. Valid values range from 0 to 1, and typically are between 0.3 and 0.5. For most types of steels it is around 0.33 to 0.4.

SheetMetal.GetActiveStyle

Use this function to assign the currently Active Sheet Metal Style to an iLogic string type variable or to a local variable in a rule. With this method it is possible to have a rule do something or change something in a model based on the Active Sheet Metal Style.

Example:

CurrentStyleParameter = SheetMetal.GetActiveStyle()

SheetMetal.ActiveKFactor

Use this function to read the current Active KFactor.
KFactor is read using a value (double) and not by name.

Examples:

KFactorParameter = SheetMetal.ActiveKFactor

Flat Pattern Extents Functions

These functions get the extents of the unfolded flat pattern. This gives the values that you see by right-clicking on the Flat Pattern in the sheet metal part model tree, and choosing Extents.

SheetMetal.FlatExtentsLength

Gets the width (X dimension) of the flat pattern extents.

SheetMetal.FlatExtentsWidth

Gets the width (Y dimension) of the flat pattern extents.

SheetMetal.FlatExtentsArea

Gets the area (X * Y) of the flat pattern extents.


Message Box Functions

These functions allow the use of message boxes in a rule.

MessageBox.Show

MessageBox.Show("Message", "Title")

This is the base for the message box functions in iLogic. The contents of the first set of quotation marks will be displayed in the gray area of the message box. The contents of the second set of quotation marks will be displayed in the title bar of the message box.

Message Box Buttons

The following functions allow the inclusion of buttons in the message box.

MessageBox.Show("Message",'"Title", MessageBoxButtons.OK)

MessageBox.Show("Message",'"Title", MessageBoxButtons.OKCancel)

MessageBox.Show("Message",'"Title", MessageBoxButtons.RetryCancel)

MessageBox.Show("Message",'"Title", MessageBoxButtons.YesNo)

MessageBox.Show("Message",'"Title", MessageBoxButtons.YesNoCancel)

MessageBox.Show("Message",'"Title", MessageBoxButtons.AbortRetryIgnore)

Message Box Icons

A third optional parameter can be provided to place one of a set of possible icons on the dialog. The following group of icons is available:

MessageBox.Show("Message",'"Title", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Error)

MessageBox.Show("Message",'"Title", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Exclamation)

MessageBox.Show("Message",'"Title", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Information)

MessageBox.Show("Message",'"Title", MessageBoxButtons.YesNoCancel, MessageBoxIcon.None)

MessageBox.Show("Message",'"Title", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question)

MessageBox.Show("Message",'"Title", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Stop)

MessageBox.Show("Message",'"Title", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Warning)

Specifying the Default Button

A fourth argument may be provided to specify which of the buttons on the message box should be selected when the message box is shown. The following are available, corresponding the 3 potential buttons on the message box (i.e., depending on which MessageBoxButtons option is used).

MessageBox.Show("Message",'"Title", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1)

MessageBox.Show("Message",'"Title", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button2)

MessageBox.Show("Message",'"Title", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button3)

InputBox

myparam = InputBox("Prompt", "Title", "Default Entry")

This function creates a message box that will prompt for and accept input.

"Prompt" the message that will appear in the box

"Title" the text that will appear in the title bar of the box

"Default Entry" the text that will be displayed in the input field of the box

InputListBox

d0 = InputListBox("Prompt", MultiValue.List("listName"), defaultEntry, Title := "Dialog Title", ListPrompt := "List Prompt")

This function creates a message box that will display a list of available options.

"Prompt" the message that will appear above the "OK" button in the box

MultiValue.List("listName") the name of the multi-value list to use

defaultEntry the value that will be selected in the list box

Title the text that will appear in the title bar of the box

ListPrompt the message that will text that will appear above the list in the box

d0 the value from the list that was selected

This rule creates the input list box shown below:

material= InputListBox("Choose Part material", MultiValue.List("material"), _

material, Title := "Part material", ListName := "Available Standard materials")

InputRadioBox

booleanResult = InputRadioBox("Prompt", "Button1 Label", "Button2 Label", booleanParam, Title := "Title")

This function creates a message box that will prompt for one of two available options.

"Prompt" the message that will appear in the box

"Button1 Label" the message that will appear for the first option

"Button2 Label" the message that will appear for the second option

booleanParam True to select the first option, False to select the second option

Title the text that will appear in the title bar of the box

booleanResult True if the first option was selected, False if the second option was selected

This rule creates the input radio box shown below:

booleanParam = InputRadioBox("Choose an Edge Treatment option", "Chamfer", "Fillet", _

true, Title := "Edge Treatment")


Document Functions

In these functions, ThisDoc refers to the document in which the rule is written. It is often the active Inventor document, but it might also be a part within an assembly. Wherever a rule lives, ThisDoc will give you access to that document.

ThisDoc.Path

This function returns the document's path (folder name) as a string.

ThisDoc.FileName(False) 'without extension

Returns the name of the document file. The file extension is not included when False is written in the parentheses. To include the file extension, write True in the parentheses.

ThisDoc.PathAndFileName(False) 'without extension

Returns the path and the file name of the document. The file extension is not included when False is written in the parentheses. To include the file extension, write True in the parentheses.

changedName = ThisDoc.ChangeExtension(".new")

Gives you a new filename that is formed from the filename of the document, with a changed extension.

ThisDoc.WorkspacePath

Returns the path (folder name) of the active Inventor project workspace.

ThisDoc.Launch("path\file.ext")

This function will launch a file, given the path and filename (including extension) in its native application.

ThisDoc.Save

Save the document.

iLogicVB.UpdateWhenDone = True

If this is included in a rule, iLogic will do an update for the document that the rule is in, after the rule (and any rule it triggers) has finished running. This update is the same as the Update button in the user interface

RuleParametersOutput() 'use this before DocumentUpdate

If your rule has changed any parameter values, this will apply the new values to the Inventor model. If you don't use this, the values are not applied until the rule has finished running. Use this if you want to do an Update or use the iLogicVb.RunRule.

InventorVb.DocumentUpdate() 'Update now

This does an immediate Update in the current document (the document that the rule is in). Use this if you want to do something that requires that the geometry be rebuilt, such as calculating mass (using iProperties.Mass). If the rule fires other rules (by changing parameters), you should use the "Fire dependent rules immediately" option. That way the other rules will have finished running when you do the update.

InventorVb.DocumentUpdate(False) 'Don't update the display

The function InventorVb.DocumentUpdate will also update the display, If for any reason you don't want the display to update, use this function instead.

ThisApplication.ActiveView.Update()

InventorVb.CheckParameters("")

This is useful in the following special case (and possibly others).Suppose you have parameters that are linked to a skeleton part, and in that skeleton part they are linked to an external spreadsheet. It is possible to change parameter values in the spreadsheet and save it without the changes showing up in the main part. Use InventorVb.CheckParameters in a rule in the main part before using GoExcel to change values in the spreadsheet. This will ensure that the skeleton part is loaded (in the background) and changes will propagate through it to the main part of the assembly.


BOM Functions

These functions operate on the Bill of Materials in an assembly.

ThisBOM.OverrideQuantity( "Model Data", partNumber, quantity)

 Override the quantity for a component. You might want to do this if you only show a few instances in the model, but the BOM shows the actual number.
This function does what you could do manually in Inventor by choosing:
Tools -> Bill of Materials..
and then in the QTY column for a component, choose "Static Quantity" instead of "Calculate Quantity".

The first argument names the BOM view, and it should always be "Model Data".
Other arguments:
partNumber: the Part Number property of the component you want. This should show up as a column in the BOM view.
quantity : the quantity you want to set for this component

Example:
ThisBOM.OverrideQuantity( "Model Data", "Top Screws", 18)

quantity = ThisBOM.CalculateQuantity( "Model Data", partNumber)

 This will set the BOM quantity back to the automatically calculated quantity.

Example:
quantity = ThisBOM.CalculateQuantity( "Model Data", "Top Screws")

ThisBOM.Export(BOMViewName, fileName, format)

 Export the BOM to an external file.
NOTE: This function only works at the Master Level of Detail in the assembly.

Arguments:
BOMViewName : this can be "Model Data", "Structured" or "Parts Only". This is the name that appears in a tab in the Inventor Bill of Materials dialog. You must enable the view you want to use before you run the rule the fist time (right-click on the tab in the BOM table).

fileName: The name of the export file to be created (with filename extension). If you don't specify a full path, the BOM will be exported to the folder where the assembly is.
Note: for Excel export, the filename extension must be .xls (.xlsx is not supported).

format: This can be one of the following:
kMicrosoftAccessFormat = Microsoft Access
kMicrosoftExcelFormat = Microsoft Excel
kdBASEIIIFormat = dBASE III
kdBASEIVFormat = dBASE IV
kTextFileTabDelimitedFormat = Text File Tab Delimited
kTextFileCommaDelimitedFormat = Text File Comma Delimited
kUnicodeTextFileTabDelimitedFormat = Unicode Text File Tab Delimited
kUnicodeTextFileCommaDelimitedFormat = Unicode Text File Comma Delimited

Examples:

ThisBOM.Export("Parts Only", "Bom353.xls", kMicrosoftExcelFormat)

ThisBOM.Export("Structured", "Bom631.xls", kTextFileTabDelimitedFormat)

ThisBOM.Export("Structured", ThisDoc.ChangeExtension(".mdb"), kMicrosoftAccessFormat)


Other Functions

iLogicVb.RunRule("ruleName")

Run another rule. The usual way to run another rule is to change a parameter that is used in the rule, which will automatically trigger it. Use RunRule if the rule does not have any parameters, or is flagged for "Don't run automatically in response to parameter changes". This is useful for rules such as report generators that don't affect the model but may contain many parameters. You can run any rule this way.

iLogicVb.RunRule("componentName", "ruleName")

Run another rule that is stored in a component within an assembly. This is the same as RunRule (above) except that the rule ruleName is in a component, not in the main assembly.

Example:

iLogicVb.RunRule("PartA:1", "Rule0")

Add Reference "fileName.dll"

This is required if you want to use external .NET code. (Advanced Rule Programming)


Advanced API Functions

app = InventorVb.Application

This gets the Inventor Application object. With this function you can directly access the Inventor API. For Help on the API, look at Programming Help

on the Inventor Help Menu

ThisApplication

This provides a way to access the Inventor Application object. The syntax makes it easy to use Inventor VBA samples from the Programming Help.

doc = iLogicVb.RuleDocument

This gets the document that the current rule is in, as an Inventor.Document object. This is useful for using the Inventor API. It can be used as a starting point to examine or modify the model.

doc = ThisDoc.Document

This gets the document that the current rule is in, as an Inventor.Document object. (Same as iLogicVb.RuleDocument )

doc = ThisDoc.ModelDocument

In a drawing document, this gets the model document (part or assembly) that is shown in the drawing. If there is no model document, it returns Nothing. If there is more than one model document, it will return the first one that it finds.

AddReference "fileName.dll"

This is required if you want to use external .NET code (Advanced Rule Programming).

auto = iLogicVb.Automation

Use this to access the iLogicAutomation object in a rule.

InventorVb.RunMacro("projectName","moduleName","macroName")

Run an Inventor VBA macro. Macros can be stored in the document or in separate ivb files. Use Alt - F11 to bring up the Microsoft Visual Basic editor to see the available macros and to load or edit macros. If the macro requires arguments, add them after the macro name.

You can call a VBA Function but you can't get a return value.

Examples:

InventorVb.RunMacro("DocumentProject","Module1","DrawCustomLines")

InventorVb.RunMacro("ThreadMacros","Module1","ThreadsInit")

InventorVb.RunMacro("ThreadMacros","Module1","AddThreads","3/8-16 UNC")

ThisApplication.UserInterfaceManager.UserInteractionDisabled = False

This is required in a rule before using some Inventor API functions such as Document.SelectSet.Select. If You find a VBA sample or other API code that doesn't work in a rule, try adding this statement at the top of the rule.

compo = Component.InventorComponent("PartA:1")

Use this to get direct access to a component. compo is of the type Inventor.ComponentOccurrence.

feat = Feature.InventorFeature("Extrusion1")

Use this to get direct access to a feature. feat is of the type Inventor.PartFeature.

feat = Feature.InventorFeature(componentOrDocName, "Extrusion1")

Use this to get direct access to a feature in a component or document. feat is of the type Inventor.PartFeature.

iParam = DynaParam.iLogicParam("ConnectorType")

Get direct access to an iLogic parameter. iParam is of the type iLogicParameter (defined in the help files under iLogic Automation)

iParam = DynaParam.iLogicParam("PartA:1","ConnectorType")

Get direct access to an iLogic parameter in a component or document. iParam is of the type iLogicParameter (defined in the help files under iLogic Automation)


iLogic Tree Editor

The iLogic Tree Editor shows all iLogic items (rules, parameter groups and parameters) in the document that you are currently editing.

(This view is also available in the standard Inventor browser tree but not when you are editing a component in an assembly.)

Double-click on a rule to edit it. Click twice (slowly) on a rule to rename it.

Rule Context Menu

Right-click on a rule or parameter to bring up a context menu.

For a rule, the context menu commands are:

Run Rule

This will run the rule. You can use this to test the rule, or to make sure the model is up-to-date. You can also use this to manually run rules that don't run automatically (see Rule Editor Options)

Edit Rule

This will open the iLogic Rule Editor for the selected rule.

Regen Rule

This regenerates the selected rule. It reconnects the rule to the Inventor parameters that it references, then recompiles and runs the rule.

Suppress Rule (or Unsuppress Rule)

A suppressed rule will not run automatically. You can still run it manually.

Delete

Delete the rule. The Delete key also works. If you want to delete all rules and iLogic items, you can do it with Utilities.

Reordering the Tree

Drag and drop any item to change the order of the items in the tree.

Drop it on an item and it will take that place in the tree.

The item you drop it on will be moved down in the tree.

Some reorder operations are not allowed. To complete the reorder operation, you have to hit OK. Do not activate another component or file without hitting OK or your changes will be lost.

Top - Level Context Menu

Right click on the root of the tree to bring up a context menu:

Add Rule

This is the same as pressing the Add Rule button on the iLogic toolbar or panel bar. It initiates the creation of a new rule, first displaying the Rule Name dialog.

Run All Rules

Run all rules in the document. If the document is an assembly, it will also run all rules in all sub-assemblies and parts. This is useful to verify that the model is up to date. It will stop after the first error. If you get an error you may have to edit the offending rule and then repeat this command.

This command is also useful if the user has changed something in the model that is driven by a rule. Rules will only fire in response to parameter changes. Anything else (such as feature or component suppression, iPart configuration, manual changes, iProperties) that a rule can set can also be changed independently by the user.

Run All Rules will ensure that the model is in the state specified in the rules.

Regen All Rules

Re-connect the rules to Inventor parameters, recompile the rules and run them. Like Run All Rules, it will process rules in sub-assemblies and parts. This is useful when opening an older model in a newer version of iLogic.


 iTrigger

This command will create an Inventor user parameter (called iTrigger0) in the document being edited. If this parameter already exists, it will increase the value by one (1). This is designed to be used to trigger a rule. If you include a line like:

trigger = iTrigger0

in a rule, that rule will fire (run) when the iTrigger button is pressed.


 iLogic Utilities

iLogic Utilities

Regen All Rules
This will re-connect the rules to Inventor parameters, re-compile the rules and run them. Like Run All Rules, it will process rules in sub-assemblies and parts. This is useful if you are opening an older model in a newer version of iLogic.

Rules Triggered by Events
Opens a dialog to select Rules Triggered by Events

Free iLogic Memory
This will do two things:
A) Unload all iLogic rule code from memory, if possible.
B) Clear (delete) any shared variables that rules have created (with SharedVariable). These variables are not tied to the CAD models and will stay in memory (unless you remove them with the rule). Using this command can free some memory. Also it makes sure you don't have any shared variables left over, which might affect the logic of rules that you want to run later on.

Delete All Rules
 Use this if you are done configuring the model and want to save or export a "dumb" configuration without rules (but with iLogic parameters, to provide some information about the model).
 If you run this in an assembly, it will delete all rules in the subassemblies and parts as well.

Delete All Rules and iLogic Parameters
 If you run this in an assembly, it will delete all iLogic items in the subassemblies and parts as well.


Place iLogic Component

This is similar to the Place Component command. The major difference is as follows:

Place Component command places an instance of an existing part or assembly.

Place iLogic Component makes a unique copy of the part or assembly to be placed. Then it places the copy as an instance in the main assembly. This allows you to make changes to the copy without affecting the original. (There is a way to prevent some files from being copied. See Standard Models below.)

Note about terminology in this help page:

The word "assembly" refers to the main assembly: the one that you're placing the component into.

The word "component " refers to the part or sub-assembly being placed. (It is not truly a component until the command is finished.)

The Place iLogic Component command:

  • Allows you to modify the value of component parameters (and connect them to assembly parameters) before placing the component.

  • Makes a unique copy of the component, so it can be individually modified and driven by rules in the assembly.

It will make a copy of the component part (or assembly and parts) in the directory of the assembly you are working in. Because of this, your assembly must be saved before using this command.

The command brings up a file browser dialog:

iLogic Component File Dialog

It is recommended that you choose a component from one of the Library directories of your project. This makes it easy to switch between the Library directory and the Workspace directory, where the main assembly will most likely be.

The component is shown in a small preview window. The component parameters are shown in a small dialog (which is similar to the iLogic Parameter Editor).
If the component contains Key parameters, then they are the only ones that will be shown in the parameter dialog. Otherwise, all parameters will be shown.

Here is a sample of the dialog for the component parameters:

Component Parameters (Free)

All parameters are initially <Free>. This means that they are not driven by assembly parameters.
You can change parameter values manually, and the component will update to show your changes.
If you click on the drop-down list in the From Assembly column, it will show a list of assembly parameters that are available to drive this parameter. (These parameters must already exist in the assembly, so you should create any that you need before placing the component.)

Here is a sample of the dialog with some of the parameters driven by assembly parameters:

Component Parameters (driven)

The component parameter "ID" is now driven by the assembly parameter "rod_diameter".
The component parameter "rod_material" is driven by the assembly parameter "rod_material".

When you click OK, iLogic starts up the standard Inventor Place Component command, so you can place the copied component in the main assembly.

The filename(s) for the component are automatically generated. They will be unique in the assembly directory.
For instance, a component part named Bushing.ipt would be copied to a new file in the assembly directory with the name:

Bushing-01.ipt
Bushing-02.ipt

If you choose to drive one or more parameters from the assembly, a rule will be created in the assembly. It will be named for the component, for example "Bushing-01 Rule". This will have a few lines to drive the parameters. You can edit this rule to adjust the relationship between the parameter values.

Standard Models

When you place an iLogic component, all parts and subassemblies that are in the same directory or subdirectories of that component assembly will be copied to the directory of the main assembly, and renamed with unique names.

It is possible to include parts and subassemblies that will remain as standard models. They won't be copied as unique instances into your main assembly. You can use this for parts and assemblies that will remain unchanged and won't be modified by rules in the iLogic model. They can be shared with other assemblies.

The way to do this is to organize your iLogic component files so that these standard models are outside of the directory of the assembly that you want to place as an iLogic component. The standard models can be in a Content Center directory, or in another Library directory. When you place this assembly as an iLogic component, these files won't be copied to the directory of the main assembly. The iLogic component in the assembly will continue to have links to the original files, in their original locations.


 External Rules

External rules can be used as rules, or as small programs to be 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.

Running Manually

In the iLogic Tree Editor there is a tab for External Rules. From here, you can load an external rule or create a new one. If you have an existing rule that you want to make external, the easiest way is to open it, copy the code, then create a new external rule and paste it there. You can save external rules to any folder you want. Save them as .iLogicVb files (this is the recommended extension), or as .vb or .txt.

The Tree Editor has a context menu for the top node (External Rules in Files) and for each rule in the tree.

You can create an icon for the rule, and it will show up in the tree editor. Just create a .bmp file (size 16 X 16 is recommended) with the same name as the rule file, in the same folder. For instance:
Custom Checks Rule.iLogicVb
Custom Checks Rule.bmp
(You have to close and then re-open the tree editor to show a new icon. You can't edit the icon while Inventor is running.)

Editing

The recommended way to edit external rules is in the Rule Editor. Double-click on the rule in the tree to edit it.
You can also use an external program such as Notepad to edit a rule. After you save it, use Reload From File in the context menu in the tree to bring the changes into Inventor.

Running from Other Rules

External rules can be run from standard rules (in an Inventor document) using the function:
iLogicVb.RunExternalRule("ruleFileName")
Where "ruleFileName" is the name of the rule file, with or without the file extension. You can also specify a file path here, but that is not recommended (for portability). iLogic will look for the rule file in the following folders (in this order):

1) The folder that the current Inventor document is in (this allows models to be copied with associated rules)
2) The current Inventor Project Workspace folder
3) The list of folders set in iLogic Configuration (TODO: link) (this is generally for workgroup or company rules)

The rule names can be relative path names, based in any of these folders.

External rules that are run from another rule don’t have to show up in the iLogic Tree Editor. But if you want to edit the rule, then you must add it to the Tree Editor.

Running as an Event Driven Rule

External rules can be run as an Event Driven Rules (TODO: link)

External Rules and Parameters

External rules do NOT run automatically in response to particular parameter changes. Unlike internal rules, parameter names are not automatically available as rule variables. That is, rule statements like:
d1 = d0 * 0.5
won't work. Instead you should use:
Parameter("d1") = Parameter("d0") * 0.5
This statement will work on any part or assembly that has parameters named d0 and d1. (This type of external rule can be used to operate on related parts that share something in common.)


 Rules Triggered by Events

Rules can be triggered to run by several types of events that occur in Inventor documents (parts, assemblies or drawings).

You can choose rules to be triggered by these events from the iLogic Utilities button.

This shows a dialog box:
Rules Triggered by Events

Right click on an event name in the tree to add or remove rules for this event. The rules will be run in the order you list them. You can change the order by dragging rules up or down. You can choose rules in the document or External Rules

The events available are:

After Open Document
This is fired right after the document is opened. Note: the document is not displayed at this point.

Before Save Document
This fires right before the document is saved. If you have a rule for this event, it can change the document and the changes will be saved.

After Save Document
This fires after the document is saved. At this point, your rule can do things like export the model to DWG or DWF or other formats.

Close Document
This fires right before the document closes. You shouldn't change the document in a rule that is assigned to this event.

Any Model Parameter Change
This will fire when any model parameter changes. This is useful when you want to detect any change to the part shape or size. You might want to check the mass properties in a rule like this.

Material Change
This is available only in part documents. If you have a rule for this, it would probably check the material with statements like:
If iProperties.Material = "Steel" Then
...


 Dialog Box in a Rule

You can use a rule to show a dialog box (a form) for user input. The dialog box can be completely contained in the rule, but it is easier and more flexible to have it in an external DLL (class library).

To do this, use Visual Studio version 2005 or 2008. Visual Basic Express is available as a free download from Microsoft. (see below for a Visual Basic Tutorial)

Here's how to create a dialog box that will enable you to display and modify some Inventor parameter values.
In Visual Studio:
  • Create a new project of type Class Library
  • In the Solution Explorer, right click on the project name, and select Add -> New Item -> Dialog
  • This brings up a graphical view of your dialog box in the Windows Form Designer. Here you can add controls.
  • Use View -> Toolbox to see the controls you can add
  • The most useful control is the TextBox. This can show the value of an Inventor parameter and let you edit it.
  • Add a Label for each TextBox to show the parameter name
  • Double-click on the dialog background. This will bring up the code editor, in a new Sub called Dialog1_Load. In this Sub, add the line:
TextBox1.Text = d0

Move your cursor in the code editor to right below the line:

Public Class Dialog1

Add the line:

Public d0 As Double

There should be a Sub OK_Button_Click below that. At the top of that Sub, add the line:

d0 = TextBox1.Text

Your code should now look like this:
__________________________________________
Imports System.Windows.Forms

Public Class Dialog1

Public d0 As Double

Private Sub OK_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK_Button.Click
Me.DialogResult = System.Windows.Forms.DialogResult.OK
Me.Close()
End Sub

Private Sub Cancel_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cancel_Button.Click
Me.DialogResult = System.Windows.Forms.DialogResult.Cancel
Me.Close()
End Sub

Private Sub Dialog1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
TextBox1.Text = d0
End Sub

End Class
__________________________________________

Build the project and save it (using File -> Save All).
Building this project will create a DLL. You can either copy this DLL to the iLogicAdd directory (under the Inventor program bin directory, usually in C:\Program Files\Autodesk\Inventor 2010\Bin\iLogicAdd) or change the project settings so that the DLL is automatically sent to that directory. You can change the directory where iLogic will look for the DLL using Advanced Configuration.
(See Advanced Rule Programming for more information on using DLL's in rules).

Here is a sample rule that uses the dialog:
_________________________
AddReference "ClassLibrary1"

Sub Main()
dim dlg as new ClassLibrary1.Dialog1
dlg.d0 = d0
i = dlg.ShowDialog()
if (i = vbOK) then
d0= dlg.d0
end if
End Sub
_________________________

This rule sends the current value of the Inventor parameter d0 to the dialog, then shows the dialog. The user can edit the value in the dialog. If he hits OK, the value from the dialog is assigned back to the parameter.

You can generate code like this for a dialog automatically, using the Rule for a Dialog Box Wizard

Tutorial For Visual Basic 2008

1 If you do not already have it installed on your computer, download and install Visual Basic 2008 Express from http://www.microsoft.com/express/vb/Default.aspx (it's free!)
Create a new project of type Class Library.

2 Be sure to name the project before clicking OK. In this case, we will use the default name, ClassLibrary1. Write this name down exactly as you have typed it. This name will be very important in the future.
Click OK

3 A new screen will appear. In the top right corner of the screen is the Solution Explorer. Move your mouse over the title of the project. Right click on it and choose Properties. This will bring up another dialog box with several tabs along the left hand side.
Choose New Item.

4 Click on the tab titled Compile.

5 Go back to the Solution Explorer, right click on the project name, this time select Add. A new selection box will appear. Choose New Item.

6 The Add New Item dialog box will open. Choose the Dialog template and click Add.

This brings up a graphical view of your dialog box in the Windows Form Designer. Here you can add the controls for your dialog box.

7 On the left side of the screen, contained in the ToolBox, are the controls that you can add to the dialog box. This project will make use of a TextBox. This can show the value of an Inventor parameter and let you edit it. Add a Text box to the Dialog box by left mouse button clicking on TextBox in the ToolBox panel and dragging it into the dialog box. Place the TextBox in the gray area of the dialog box. You can re size the dialog box as required.

8 Add a Label for each TextBox to show the parameter name.

9 Double-click on the dialog background. This will bring up the code editor. Be careful not to double click the Label or the TextBox. You should see he code below.

Move your cursor in the code editor to right below the line:

Public Class Dialog1

add the line:

Public d0 As Double

Next, there should be a Sub OK_Button_Click below that. At the top of that Sub, you will add a line.
Place your cursor in front of Me.DialogResult, etc. and press enter to add a the line. Now type:

d0 = TextBox1.Text

In a new Sub called Dialog1_Load. In this Sub, add the line:

TextBox1.Text = d0

10 Save your work by using the File > Save or the File > Save All command

11 We are almost ready to build our project. When we perform the build operation, Visual Basic creates a .dll file. We can specify where Visual Basic should create this file by modifying the output path for the build operation. Click on the tab with the project title on it. Click on the Compile tab again. The output path should be:

Program Files\Autodesk\Inventor 2010\Bin\iLogicAdd\.

12 To build the project, press the Build tab in the top menu. If the build proceeds without problems, Build succeeded will be displayed in the status bar in the bottom left corner of the screen.

Save your work again using the Save All command and go into Inventor.

Click on iLogic Add Rule. The name of this rule will be ”Form Rule”.

Here is the rule that this sample uses. Just copy and paste this code into your form rule:
_________________________
AddReference "ClassLibrary1"

Sub Main()
dim dlg as new ClassLibrary1.Dialog1
dlg.d0 = d0
i = dlg.ShowDialog()
if (i = vbOK)then
d0 = dlg.d0
end if
End Sub
_________________________

Note: you can use the "Create Rule for a Dialog" button on the Wizards tab in the Rule Editor to create code like this.

This rule sends the current value of the Inventor parameter d0 to the dialog, then shows the dialog. The user can edit the value in the dialog. When the OK button is pressed, the value from the dialog is assigned back to the parameter.


Additional VB Learning Resources

Visual Basic .NET Programming for Beginners

Visual Basic Tutorials

Programming Tutorials

Microsoft Visual Basic Development Center


Parameters in Base Parts

You can access parameters in a base part from a derived part or assembly. You can also access them from an assembly that contains a part that is derived from the base part. (Base parts are also known as "skeleton parts".)

Sometimes it is useful to drive parameters in the base part from rules in the assembly. Changing a base parameter causes linked parameters in all derived parts to change.

You might not see the part and its parameters in the model tree in the Rule Editor. But you can access them with the Parameter function. For example, to change a parameter in a base part:

Parameter("BaseShaft.ipt.Diameter") = 0.125 in

Usually, you don't have to read parameter values from the base part because the parameters are already linked into the part or assembly you are working in.


Advanced Rule Programming

iLogic rules can be written using only Inventor parameter assignment statements, predefined iLogic functions and simple VB.NET code. But you are not limited to this. You can use more advanced features of VB.NET in a rule. Visual Basic 2005 or 2008 can be used to create external DLL's, which can be called from rules. You can also call DLL's written in C#.

Within the rule code, Visual Basic 2008 (.NET Framework 3.5) syntax is supported.

The following statements can be used at the top of the rule, before the main rule code:

Option Explicit On

Option Strict On

Option Infer Off

AddReference "filename.dll"
Imports ...

AddVbRule "Other Rule"
AddVbFile "filename.vb"
AddResources "filename.resources"

Option and Imports are standard VB.NET statements. The rest of these statements are described below.

”Option Explicit Off” is the default. This allows you to use local variables without declaring them.

"Option Strict Off" is the default. Option Strict On should also work for most rules.

"Option Infer On" is the default.

The main rule code is an "implicit" Sub. If you want to add more Subs or Functions or Properties or Classes, you have to explicitly declare a Sub Main() as follows:

Sub Main()

' your main rule code here

End Sub

Sub Main() is OK to use in any rule, whether or not the rule has additional code.
See below for more detailed information about explicitly declaring your rule class.

Rule Processing

AddReference

”AddReference” is special iLogic syntax. Putting a dll name in an AddReference statement is similar to using ”Add Reference” and browsing for a dll in Visual Studio or Visual Basic Express. Only .NET assemblies are supported. The dll can be a standard Microsoft assembly (in the Microsoft.NET\Framework directory).

Example:

AddReference "System.Drawing.dll"

or

AddReference "System.Drawing" ' the .dll is optional

You can also specify a user-created or third party class library as a reference. User-created or third party dll’s must all be in one directory. The default location is under the Autodesk Inventor install in an iLogicAdd subdirectory, usually:

C:\Program Files\Autodesk\Inventor 2010\Bin\iLogicAdd

You can change this location using the iLogic Configuration button.
You can also add references to dll’s in the main Inventor Bin directory (e.g. C:\Program Files\Autodesk\Inventor 2008\Bin)

A full path is not supported in the AddReference statement. You can only specify a filename.
You can add references to assemblies in the Global Assembly Cache (GAC), using a qualified name, such as:
AddReference "VsWebSite.Interop, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"

You can also use registered COM objects in a rule, using CreateObject or GetActiveObject. It is not necessary to use AddReference for a COM dll.

AddVbRule

( Example: AddVbRule "Other Rule")
Use this to include the code from the specified rule as VB code, to be compiled with the main rule. The specified rule cannot be a standard rule: it has to have the "Straight VB" option enabled (in Rule Editor Options). iLogic does no pre-processing on the code in such a rule. It should contain Classes or Modules that can be called from other rules. Use this to share code between rules, or for convenience in keeping code modular.

AddVbFile

( Example: AddVbFile "fileName.vb")
This is similar to AddVbRule. The only difference is that the VB code is stored in an external file instead of a rule. The code must be "Straight VB". This is useful for sharing common code between Inventor models. The file should be a relative name. iLogic will search for it in the directory of the current Inventor document, and in other directories using the same search order it uses for External Rules.

AddResources

( Example: AddResources "fileName.resources")
This adds resources (strings, bitmaps etc.). They must be compiled with Visual Studio.

Imports

You can’t have duplicate Imports statements. Here are the default Imports statements that are used in all rules:

Imports System

Imports System.Math

Imports System.Collections

Imports Microsoft.VisualBasic

Imports Autodesk.iLogic.Interfaces

Imports Autodesk.iLogic.Runtime

If you use MessageBox in a rule then

Imports System.Windows.Forms

will also be added.

If you use ThisApplication or other Inventor objects, then

Imports Inventor

will also be added.

Additional Statements

If you use Sub Main(), then the rule follows standard VB.NET format for a class, except that you don’t see the Class...and End Class statements, and the statements before Sub Main are outside the class. So any assignment statements must be inside a Sub, Function or Property. You can have declaration statements for class member variables such as

Private temp As Double = 4.5

outside of a Sub or Function.

You can add Sub, Function, Property and Class definitions after Sub Main()... End Sub. Any Class you add is nested in the main rule class for that rule. It cannot be used from another rule.
If you want to add independent Classes and Modules, you can explicitly declare the rule class, using:
Class ThisRule
' ...

Sub Main
End Sub

' ...

End Class

Then you can add other classes and modules outside of this. Class ThisRule becomes your main rule class, and Sub Main (within it) will be called by iLogic to run your rule.

If you want to have modules or classes that are visible to multiple rules, you can put them in an external assembly (dll). You can also put them in a "Straight VB" rule in the Inventor document (using AddVbRule) or in an external VB file (using AddVbFile).

For developing advanced VB.NET code, rather than coding directly in a rule it is easier to use Visual Studio or Visual Basic Express. You can then cut and paste relatively small snippets of code from Visual Studio into a rule. You can even paste in an entire dialog box class (although resources are not easily supported). For larger units of code, or where required, create an assembly and use it as an external dll from a rule.

You can store objects that are instances of user-defined classes in iLogic rule Shared Variables. To do this, the class must be Serializable or derived from MarshalByRefObject.

External DLL's

As mentioned above, you can write your own external DLL's in .NET and call them from a rule. You can debug a DLL by setting the build output path (under project properties -> Compile) to be "iLogicAdd" (under the Inventor Bin directory), and choosing Inventor.exe for "Start external program" in your project properties in Visual Studio. This allows you all the benefits of the debugging environment, including Edit and Continue.

A good use for an external DLL is to put a dialog box in a rule.

Using the Inventor API

You can use the Inventor API from a rule. The ThisApplication property gives you access to the application. You can create and modify features. Using the Parameter.Param interface you can get direct access to an Inventor.Parameter.

To use the Inventor API, add a reference to Autodesk.Inventor.Interop.dll to your Visual Basic project. It shows up in the Add Reference dialog, on the .NET tab. The version should be 14.0.0.0 for Inventor 2010.

Using iLogic interfaces in External DLL's

All the iLogic functions are grouped under interface objects such as Parameter, iProperties, iPart etc. You can pass iLogic interface objects as arguments to functions in external DLL's. To do this in your project, add a reference to Autodesk.iLogic.Interfaces.dll. Use the Browse tab in the Add Reference dialog, and browse to the iLogicBin directory, under the Inventor bin directory (usually in C:\Program Files\Autodesk\Inventor 2010\Bin\iLogicBin).

Here are the interface definitions.

Here is code that is used in rule code for the VB compiler, which shows how the interfaces are accessed and their object names in the rule. (Note: each object is created only if it is used in the rule.)

iLogic Automation

iLogic Automation can be used to access parameters and rules from outside Inventor.

Parameters in Rules

By default, parameters in rules are not declared as Double, but instead as a custom iLogic type called DoubleForEquals.


Advanced iLogic Configuration

The Advanced iLogic Configuration dialog allows you to configure settings which are primarily of interest to advanced users; many iLogic users will not be interested in this dialog.

External Rule Directories

iLogic rules can be placed in external files rather than stored with the Inventor part. Placing rules in external files makes it easier to use the same rule in several different places. This option specifies the directories iLogic should look in for external rule files; directories are searched in the given order.

Default Extension for External Rule Files

This option sets the default file extension for new external rule files. Using an extension of ".vb" makes it easier to edit the rule in Visual Studio .NET. An extension of ".txt" means you can edit the rule with any text editor such as Notepad. The extension ".iLogicVB" indicates that the file contains standard iLogic rule code (which must be pre-processed by iLogic).

iLogic Addin DLLs Directory

iLogic rules can make use of code in other .NET assemblies; this directory specifies where these .NET assemblies are located. Developing a .NET assembly is done using programming tools such as Visual Studio 2008. See Advanced Rule Programming for more information about using .NET assemblies in rules.

Note that it is good practice to write to C:\Program Files only during installation.


 iLogic Automation

iLogic provides an automation interface. You can use this from Inventor VBA, or VB6 or .NET code to access iLogic parameters and rules.

The class that exposes this capability is iLogicAutomation

In the sample code below, the function GetiLogicAutomation shows you how to access this object in VBA or VB.
In a VBA or VB project, you can use it as a late-bound type (declared as an Object) without adding a reference. Adding a reference doesn't provide any benefit because it is not a full .COM object. You can't browse its methods.

To access the automation object from an iLogic rule, use the property iLogicVb.Automation()

Here is the interface source file. iLogicAutomation implements the interface IiLogicAutomation, so you can use the properties and functions defined on that interface.

Sample Code
Here’s sample code written in Inventor VBA to drive an iLogic string parameter and Boolean parameter.
The function (or rather property) to use is iLogicAuto.ParamValue. It can get or set the value of an iLogic parameter (and also an Inventor parameter). It’s an interface to DynaParam .
This sample also shows (in GetiLogicAddin) how to find and hook up to the iLogic add-in from VBA or another add-in.

Sub Test_iLogic()
Dim oApplication As Inventor.Application
Set oApplication = ThisApplication

Dim iLogicAuto As Object
Set iLogicAuto = GetiLogicAutomation(oApplication)
If (iLogicAuto Is Nothing) Then Exit Sub

Dim curDoc As Document
Set curDoc = oApplication.ActiveDocument

iLogicAuto.ParamValue(curDoc, "str0") = "From Automation"
Dim curVal As String
curVal = iLogicAuto.ParamValue(curDoc, "str0")
iLogicAuto.ParamValue(curDoc, "bool0") = False

Dim rule As Object
Debug.Print (" ------- Rules: ----------")
Dim rules As Object
Set rules = iLogicAuto.Rules(curDoc)
If (Not rules Is Nothing) Then
For Each rule In rules
Debug.Print (rule.Name & " = " & rule.Text)
Next
End If

Dim param As Object
Debug.Print (" ------- iLogic Parameters: ----------")
Dim params As Object
Set params = iLogicAuto.Params(curDoc)
If (Not params Is Nothing) Then
For Each param In params
Debug.Print (param.Name & " = " & param.Value)
 Next
End If

End Sub

Function GetiLogicAutomation(oApplication As Inventor.Application) As Object
'Get the addins collection
Dim addIns As ApplicationAddIns
Set addIns = oApplication.ApplicationAddIns

'Find the add-in you are looking for
Dim customAddIn As ApplicationAddIn
Dim i As Long
For i = 1 To addIns.Count
If (addIns(i).ShortDisplayName = "iLogic") Then
 Set customAddIn = addIns.Item(i)
Exit For
End If
Next i

If (customAddIn Is Nothing) Then Exit Function

customAddIn.Activate
Set GetiLogicAutomation = customAddIn.Automation
End Function


Custom Code Snippets

Custom code snippets allow you to define your own "short cuts" to use in creating iLogic rules.

You can arrange your custom code snippets into categories. Create a new category by right-clicking and selecting the "Insert Category" entry on the context-menu.

New custom snippet

To create a new custom rule snippet, highlight the snippet text in the editor window. With the text highlighted, right-click to get a context menu and select the "Capture Snippet" option. The "Edit Snippet" dialog is then displayed

This dialog allows you to set the title for the snippet as well as specify which category you want the snippet to appear under. You can also set a tooltip and modify the exact code that will be inserted when the snippet is used.

Once you have created a custom snippet, click the "Save" button (the standard disc icon shown above) or Ctrl-S to save your snippet to disk. Snippets will also be saved when you click OK in the rule editor. The first time you save custom snippets, a file dialog will come up so you can choose where to save.

Managing custom snippets

Once you have created custom code snippets, you can arrange them into different categories by dragging the code snippets in the tree. You can also rename your code snippets as well as rename the categories.

The "Save As" toolbar button allows you to have different collections of code snippets for different projects. You can also import code snippets into the current collection ("Open" buttons), either merging the snippets together or completely replacing them.


DoubleForEquals

To support easy comparison of numeric parameter values in rules, iLogic uses a custom type to store the values. By default, parameters in rules are declared as DoubleForEquals. This type is very similar to the standard VB.NET Double type. The main difference is that when you compare two DoubleForEquals values, it compares them as if they were Single values. So it compares 7 decimal places instead of 15.

This makes it easier for the user to ignore round-off error in comparisons. For instance, in an part where the document units are inches, a parameter with a value of 13/16 inches will not be exactly equal to 13/16 in a rule. This is because the parameter value is stored in centimeters in the model, and then converted to inch for use in the rule. So a comparison such as:

if d0 = 13/16 then
...
will fail if d0 is a Double. But if it is a DoubleForEquals the comparison will succeed.

DoubleForEquals stores the value as Double, and does all calculations as Double values. Only comparison is done as Single.

Comparing a value to Zero

Comparison to zero is treated as a special case. When one of the numbers being tested for equality is exactly zero, the test will succeed if the other number is less than 0.0000001 (in absolute value).

This is done to make it easier to ignore round-off errors in the neighborhood of zero. So a test like:

angle = PI/2

x = cos(angle)

if (x = 0) then

...

end if

Will find that x = 0.

Choosing not to use DoubleForEquals

The DoubleForEquals type is used by default for all Inventor parameters used in rules. This can be disabled by using the statement:

iLogicOption DoubleForEquals Off

at the beginning of the rule. (This is similar to the standard Visual Basic Option statement.) Disabling the use of DoubleForEquals may be necessary if:
A) You want to use library functions or custom code that requires the Double type. All efforts have been made to enable transparent conversion to Double. But if a function expects an argument of type Object, no conversion will be done. A DoubleForEquals object will be passed, and the function might expect a Double.

B) You want more control over equality tests or comparisons in the rule (e.g. you want to specify your own tolerance).
C) You don’t have any equality tests in the rule, and you want to avoid the (minimal) overhead of DoubleForEquals by using Double directly.
D) You have some equality tests in the rule, but the parameters are outside of the dynamic range of a Single value (approximately 1.4e-45 to 3.4e38). This is unlikely but possible.


DynaParam.Param Example

Parameter.Param Example

You can use the Parameter.Param function to get direct access to an Inventor parameter. Here is some sample code:

param = Parameter.Param("parameterName")

If (param IsNot Nothing) Then

param.Expression = "5.0 in"

param.Tolerance.SetToDeviation(0.002 * 2.54, -0.004 * 2.54)

param.Comment = "Equation and Tolerance set by a rule"

End If

For an iLogic parameter, you can also get or set the Comment with similar code:

param = Parameter.iLogicParam("iLogicParameterName")

If (param IsNot Nothing) Then

param.Comment = "Comment set by a rule"

End If

Or, if you are sure the parameter exists and it is an iLogic parameter, you can instead use a single line:

Parameter.iLogicParam("iLogicParameterName").Comment = "Comment set by a rule"


External Rule Support

Add External Rule

Create New External Rule

Run Rule

Edit Rule

Reload From File

Open Containing Folder

Delete

External Rules Default Path Configuration

Run External Rule Function

iLogicVb.RunExternalRule("ruleFileName")


Notes for MultiValue.SetValueOptions

Here is some behavior to be aware of, if you use

MultiValue.SetValueOptions(True, DefaultIndex := 0, NumericCompare := "=")

or

MultiValue.SetValueOptions(True)

or any similar statement where the first argument is True.

With this option on, after you set or assign the value list the parameter value might change. If you want to see what value was assigned, and maybe use that value later in the rule, you have to use the Parameter function to read it. For instance:

MultiValue.SetValueOptions(True)

MultiValue.SetList("d1", 0.25, 0.375, 0.5)

d1 = Parameter("d1")

If you're using d1 in the rule, its value will not be automatically set by the SetList function. That's why you have to use the line shown:

d1 = Parameter("d1")

The Parameter function will read the value directly from the model. (See Parameters In Rules)


MultiValue Parameters

A multivalue parameter is a standard Inventor or iLogic parameter that has a list of possible values stored with it. But, like other parameters, at any given time it has a single value. It is not automatically locked to one of the multi-values in the list (although you could make that happen with a rule).

Multivalue parameters can be created and edited in the iLogic Parameter Editor.

Right-click on a parameter (in the Equation or Nominal Value column) to make it multivalue. A dialog box pops up where you can enter a list of values. You can also paste a list of values from a text editor or Excel.

For an Inventor parameter, the value list can include fractions or equations such as:

3/8

12.5 mm

d0 * 0.8

When a parameter is multivalue, the Multivalue column shows a drop-down list from which you can pick the current value (or equation for an Inventor parameter).

In a rule, you can read and write the list of values for a parameter using the MultiValue functions.


Parameters in XML

Parameter Save/Load to XML

From the parameter editor, you can export parameter names and values (or equations) to XML. This allows you to take a snapshot of parameter values. You can also use an external program to create an XML file in this format, and then load it into Inventor. Both Inventor and iLogic parameters are supported.

To do this, right-click on the title row (or anywhere outside a parameter row) in the Parameter Editor.

This brings up a contextual menu with the following options:

Save Table As XML

Load Table From XML

When you save (export), the default filename is the Inventor document name with "-params.xml" added.

The .xml file can be opened in a web browser or a text editor. The diagram shows the .xml file opened using Microsoft Notepad.

To load an .xml file, right-click on the title row (or anywhere outside a parameter row) in the Parameter Editor.

This brings up a contextual menu with the following options:

Save Table As XML

Load Table From XML

Choose the Load table option and locate the .xml file. Click Ok

"Load Table From XML" will create parameters if they don't already exist. It can be used to copy parameters from one model to another, creating them if necessary.

If you want to write to this XML format with your own program, here is VB.NET source code with functions to do it. This code can also be used as a starting point for reading the XML format

"Save Table As XML" and "Load Table From XML" can now be used to import parameters from one inventor file to another. If you load and XML table containing parameters that don't exist in the file you are loading into, iLogic will create any and all missing parameters with their lists intact.


Ribbon UI

iLogic commands are fully integrated into the new Inventor ribbon UI. Using the ribbon allows you to quickly access the needed commands without hunting through menus or dialogs. The larger icons in the ribbon are also more visually appealing making it easier to quickly recognize commands.

iLogic Parameters

The iLogic parameters button appears along with Inventor's parameters button. Whichever button you most recently selected becomes the default button.

iLogic Configuration

The iLogic configuration command is a small drop down button on Inventor's "Options" panel.

pressing the down arrow will show additional icons

iLogic Commands

The iLogic command panel contains several iLogic-specific commands:

This panel is available on the "Manage" tab.

Assembly Environment

When working with an Inventor assembly, you can also place an iLogic component. Like the parameters button, this command appears with Inventor's place button.

Drawing Environment

Inventor does not have parameters in drawings, but iLogic does; the iLogic parameters button appears on the "Manage" tab in the drawing environment.

Zero-doc Environment

When you are not working with any documents, Inventor is in a zero document mode; far fewer commands are available.


Public Class LmiRuleScript
  Implements Autodesk.iLogic.Interfaces.IRuleInterface

  Public m_iLogicVersionDate as Integer = 20090119

  Private iProperties As IiProperties
  Private Component As ICadComponent
  Private Constraint As IAssemConstraint
  Private Feature As ICadFeature
  Private iPart As IiPartRowChanger
  Private iAssembly As IiPartRowChanger
  Private iFeature As IiFeatureRowChanger
  Private Measure As ICadMeasure
  Private GoExcel As IGoExcel
  Private iLogicVb As ILowLevelSupport
  Private InventorVb As ILowLevelSupport
  Private Parameter As IParamDynamic
  Private DynaParam As IParamDynamic
  Private MultiValue As IMultiValueParam
  Private SharedVariable As ISharedVariable
  Private SheetMetal As ISheetMetal
  Private CadDoc As ICadDoc
  Private Sketch As ICadSketch
  Private WorkPlane As ICadWorkPlane
  Private ThisBOM As ICadBom


What's New in iLogic 2009 Release

What's New in The iLogic 2009 Release ?

The following sections highlight enhancements and significant modifications available in the Autodesk Inventor iLogic 2009 release. Where possible, links are provided to the details of the new or modified functionality.

Component Instantiation (Place iLogic Component)

Auto-Hide Dialogs

An auto-hide feature has been added to the iLogic Parameter Editor and Tree Editor dialogs. This allows these dialogs to be collapsed down to their title bars when the cursor is moved out of the dialog frame, and then restored to full size when the cursor is moved back inside the frame.

Parameter Editor

  • Driving Parameter cells are now color-coded

Tree Editor

New commands have been added to the iLogic Tree Editor context menus:

  • Add Rule

  • Regen Rule

Rule Editor

New Code Snippets interface. This supports the inclusion of rule code fragments. A set of built-in snippets is provided. User-added "custom" snippets can also be maintained.

  • Code Snippets

  • Custom Code Snippets

Additional editing capabilities:

  • Rule text area context menu

  • Straight VB Code option

The following new wizards have been provided:

  • MessageBox

  • Parameter Limits

External Rule Support

New functionality has been added to support storing rule code in external files. These rules can then be shared across multiple models.

Component/Feature Functions

New thread feature-related functions:

  • Feature.SetThread

  • Feature.ThreadClass

  • Feature.ThreadDesignation

  • Feature.ThreadType

Component Patterns may now be controlled by the following functions:

  • Component.IsActive

  • Component.Color

  • Component.Visible

  • Component.Replace

  • Component.ReplaceiPart

BOM Functions

A new set of BOM-related functions has been added:

  • ThisBOM.Export
  • ThisBOM.CalculateQuantity
  • ThisBOM.OverrideQuantity

iProperty Functions

The preferred function to set iProperty values in assembly components has been changed. Details are provided here:

  • iProperties.Value

Parameter Functions

Syntax Change: DynaParam becomes Parameter

New Functions:

  • MultiValue.SetValueOptions

Measure Functions

  • Measure between iMates

  • Measure model extents

Data Link Functions

  • GoExcel.Open

  • GoExcel.CellValues

Document Functions

  • ThisDoc.WorkspacePath

Sheet Metal Functions

  • SheetMetal.FlatExtentsLength
  • SheetMetal.FlatExtentsWidth
  • SheetMetal.FlatExtentsArea

iLogic Utilities

  • Rules Triggered by Events

iPart Functions

  • iPart tolerance

Message Box Functions

The following new functions have been added:

  • InputListBox

  • InputRadioBox

iFeature Functions

  • Change Row

  • iFeature Searches

  • iFeature.Tolerance

String Functions

A new set of string-related functions has been added.

Work Feature Functions

New functions added:

  • Sketch.Redefine

  • WorkPlane.FlipNormal

Advanced Rule Programming

It is now possible to trigger the execution of rules in response to certain Inventor events. This is described here:

  • Rules Triggered by Events

Some new functions have been provided:

  • iLogicVB.RunExternalRule

  • AddVbFile

  • AddVbRule

  • AddResources