Introduction to Codeblocks for Form Rules
Inform design uses rules created from code blocks to govern the input values and options that control the informed design form.
These code blocks are accessed from the product definition under the rules tab.
The logic within the code blocks constrain the values and options such that it is only possible to enter valid values or valid combinations of values and options that to get define valid manufacturable product variants.
The product definition automatically lists the Inventor user parameters in the parameters tab.
Within this tab, you can choose which Inventor parameters to adopt as informed design parameters.
The order the parameters are listed is the same order in which the parameters are displayed in the informed design input form found in the rules tab.
The parameters list can be filtered by all model, user, key, as well as selected. In the rules tab, code blocks for parameters containing a list are automatically added to the rule.
The informed design block library contains a rich set of code blocks of various categories to allow you to build robust logic rules to govern the design intent of your Inventor model. These include logic blocks to allow the creation of conditional statements.
Loop blocks to allow the iteration of code.
Mathematical blocks to assist with calculations.
A large collection of text blocks.
List blocks for working with collections.
Variables which are user created containers to hold data.
Functions, which can be created to be reused to perform common tasks within your rule.
And parameters, which are adopted from the Inventor model.
You can create local variables to do intermediate calculations, such as a conversion from feet to inches.
Here, this is done by employing the code blocks from the math category to multiply the parameter by a value of twelve.
With code blocks, you can create a conditional if do rule statement to govern the minimum value of an adopted Inventor user parameter.
Here, the logic is created to check that the opening width parameter is not less than sixteen.
When an input value of less than sixteen is detected, The logic resets the parameter to sixteen to maintain the minimum allowable value.
To govern the maximum value of the opening width, a variable called max opening width is created to perform an intermediate calculation.
To calculate that the maximum is the wall length minus nine.
Blocks are pulled from the code block library and arrange to create the logic or equation to match the intended rule logic.
Snaping the blocks together, is as easy as dragging and dropping the puzzle piece ends to fit.
Next, logic is created to check that the opening width parameter does not exceed the maximum opening width as calculated by the previously created variable.
This is done by employing the conditional if do code block statement.
Once complete, the code blocks are snapped together by simply dragging and dropping in order to tidy up the code block rule space. To test the code block logic, you can use the informed design form and enter values that are below the specified minimum and maximum values.
To see the Inventor model update, click the set model values button.
Testing the maximum value of the opening width seems to return an unexpected value as the opening width exceeds the length of the wall in inches.
A quick review of the code block identifies the error.
Updating the code block and retesting using the form and the set model values button confirms the fix.
In summary, the code block library contains code blocks of various categories to allow creation of product definition logic rules. You can create minmax logic to govern the form inputs to maintain the design intent of the Inventor model Conditional logic statements can be created with if do code blocks to govern inputs and options.