A function is an instruction carried out within a program. The instruction can include arguments or require certain inputs to run successfully.
Functions are typically arranged in a certain order to achieve a desired result. For example, one function retrieves a piece of information from a database, and the next function performs some operation on that data. Usually, each function is independent of the remaining code in a program.
iLogic provides functions to modify the Inventor model or read some data from the model and return it to you. These functions are available as code snippets in the Edit Rule dialog box. You place the functions in rules (small Visual Basic programs) that you define for the model. When a rule is run, the functions within that rule are executed.
iLogic provides many functions for use in rules. Functions are grouped in categories.
The following is one example of how a function can appear in a rule:
returnValue = Category.FunctionName(argument1, argument2,...)
An argument can be a text string, Boolean value of true or false, or number.
A text string value is specified inside a pair of double quotes. “ComponentName:1” and “Hole2” are examples of text strings. Using our previous example, if the arguments are text strings, the function appears as:
returnValue = Category.FunctionName(“ComponentName:1”,“Hole2”)
An iLogic text parameter can be used as an argument to a function that expects a text string. An Inventor numeric parameter can be used as an argument to a function that expects a number.
A return value can be a text string, Boolean value of true or false, or number. It is often something that you want to read or retrieve from the model. You can test the return value, or assign it to a parameter or a local variable in the rule.
Some functions do not have a return value. In VB.NET, this type of function is called a Sub. It often changes the model. For example:
Category.FunctionName(argument1, argument2, ...)
Another type of function can be used to write or assign a value to something in the Inventor model. In VB.NET, this type of function is called a Property. For example:
Category.FunctionName(argument1, argument2, ...) = value
In this example, the function is writing the value to the model.