• Informed Design
  • Inventor

Informed Design for Inventor - an introduction to Codeblocks for form rules

Discover how Codeblocks in Informed Design can be used to define the layout of the input form that will be used in Revit to configure the manufacturing model.


Step-by-step guide

Informed Design utilizes rules created from Codeblocks to manage the input values and options for the Informed Design form.

To access Codeblocks, begin with the Inventor project open.

  1. On the ribbon, select the Informed Design tab.
  2. Click Product Definition.
  • On the Inventor ribbon, Informed Design tab, the tab name and the Product Definition tool highlighted in red.
  1. In the Product definitions list, select the appropriate option.
  2. Click Edit.
  • The Product definition dialog box with the Edit tool highlighted in red.
  1. Select the Rules tab.
  2. Select the Input workspace.
  • The Product definition open to the Rules tab, Input workspace, with the Input option highlighted in red.

The logic contained in the Codeblocks is used define and restrict the options, values, and combinations of values that can be entered into the form, helping to ensure that only valid, manufacturable product variants are defined. For example, the logic can configure a drop-down so that only specific options can be selected, or it may set maximum or minimum allowable values for an input.

Before designing a form, it is important to first adopt the Inventor parameters:

  1. Click the Parameters tab.

The product definition automatically lists the Inventor User parameters, but other lists are available.

  1. In this case, expand the drop-down and select Key parameters.
  2. Select the Inventor parameters to adopt as Informed Design parameters; for example, select Nominal_Wall_Length, Opening_Width, and Wall_Length_in.
  • On the Parameters tab, the Key parameters displayed, with Nominal_Wall_Length, Opening_Width, and Wall_Length_in selected.
  1. Select the Rules tab to open the Form workspace, where adopted parameters display.

The Form workspace is used to design and customize the visible aspects of the Informed Design form, such as organizing and applying names to the input fields.

For this example, make the following changes:

  1. Remove underscores from the label names.
  2. Rename the form to “Wall Configurator”.
  3. Click Update form to view the changes.
  • The product definition open to the Rules tab, Form workspace, with underscores removed from the label names, the form renamed, and the mouse pointer hovering over the Update form option.
  1. Select the Input workspace.

The Input workspace is used to build the logic and apply constraints that govern the values and options within the form.

Adopted parameters that contain a list are automatically added to the Input workspace. In this example, the Nominal Wall Length parameter is added and contains the list of available selections.

  • On the Rules tab, Input workspace, the Nominal Wall Length adopted parameter highlighted in red, and the corresponding field expanded in the form to show the list of available options.

The Codeblocks library contains a comprehensive set of code blocks within different categories that are used to build the logic rules that govern the design intent of the Inventor model. These include:

  • Logic blocks for the creation of conditional statements,
  • Loops blocks for the iteration of code,
  • Math blocks to assist with calculations,
  • Text blocks for working with strings,
  • Lists blocks for working with collections,
  • Variables, which are user-created containers to hold data,
  • Functions, which can be reused to perform common tasks within a rule, and
  • Parameters, which are adopted from the Inventor model.
  1. Select a category, such as Logic, to view the available blocks.
  • The Codeblocks library, with the Logic category expanded to show the available options.

Variables can be created to perform an intermediate calculation that displays in the form, such as a conversion from feet to inches:

  1. Select Variables > Create variable.
  2. In the New variable name dialog box, type "Feet_To_in".
  3. Click OK.
  • In the expanded Variables library, Create variable selected, and in the New variable name dialog box, the name entered for this example.
  1. From the Variables library, drag the new Set Feet_To_in block into the workspace.
  2. Add an Operation math block, a Nominal Wall Length value parameter block, and a math Number block to the variable block.
  3. Adjust the blocks so that the logic will multiply the Nominal Wall Length value parameter by 12 to convert it to inches.
  • Blocks configured for this example to multiply the Nominal Wall Length value by 12 to calculate the Feet_To_in variable.

A parameter block can be used to map the variable value to an input field and to set it to read-only.

  1. Add two Nominal Wall Length value blocks below the Set variable block, then adjust them to map to the Wall_Length_in parameter.
  2. Add the Set Feet_To_in variable block to the first parameter.

In this case, the input is only for information.

  1. Set the second parameter block to readOnly, and then add a True False logic block with a value of true.
  2. Click Update form.

The Wall Length (in) input field in the form automatically converts the Nominal Wall Length into inches and is a read-only field.

  • Parameter blocks configured to map the conversion from feet to inches to a read-only field in the form, with the Update form button highlighted in red.

The parameter block can also control allowable inputs.

  1. Add another Nominal Wall Length value parameter block to the workspace, and set it to Opening_Width.
  2. Adjust the value to min and add a math Number block with a value of 16. This ensures that the opening width is at least 16 inches.
  • Blocks set up to create a minimum opening width of 16 inches.
  1. Update the form.

The label below the input field now communicates the minimum allowable value.

  1. Enter a value less than the minimum, such as 8, and the input value automatically resets to 16.
  2. Hover the cursor over the message icon to view the reason for the adjustment.
  • In the form, the minimum value displayed below the Opening Width field, with the value reset to 16 and the cursor hovering over the message icon to display the message.

To set a maximum value for the opening width:

  1. Create a Variable called Max_Opening_Width and add it to the workspace.
  2. Add an Operation math block, the Set Feet_To_in variable block, and a math Number block with a value of 9, so that the finished block statement reads Set the Max_Opening_Width to Feet_To_in plus 9.
  • Blocks configured to set the maximum value for the Opening Width to Feet_To_in plus 9.

Next, create logic to ensure that the opening width does not exceed the maximum as calculated by the previously created variable:

  1. Use the conditional If Do block statement, along with an Operation math block, as well as parameter and variable blocks, to create a block statement that reads if the Opening_Width value is greater than the Max_Opening_Width, then set the Opening_Width to equal the Max_Opening_Width.
  • The If Do block statement configured to reset the opening width to the maximum if the input value exceeds the maximum.
  1. Snap all the code blocks together into one set to organize the workspace.
  2. Click Update form.
  3. To test the logic, in the form, enter a value that is above or below the constrained values for Opening Width, such as 999.

The field automatically updates to equal the Wall Length in inches plus 9, or in this case, 81.

  1. To update the Inventor model, click Set model values.

In the Inventor model, the result shows an unexpected error, since the opening width exceeds the length of the wall in inches.

  • The blocks configured and snapped together, the form updated, and Set Model Values being clicked; and in the Inventor model, an unexpected error where the opening width exceeds the length of the wall.
  1. Review the code blocks to identify the error in the logic.

In this case, the Max_Opening_Width variable is set to add 9 inches, instead of subtracting 9 inches.

  1. Update the operation to subtraction.
  2. Click Update form.
  • In the configured codeblocks, the Max Opening Width variable block highlighted in red, with the operation changed from addition to subtraction.
  1. Test the form again by entering an Opening Width value of 999. The value automatically updates to 63.
  2. Click Set model values.

The Inventor model updates, confirming that the fix is successful.

  • The updated form, with the Opening Width reset to 63 and Set model values being clicked; and the updated Inventor model, confirming the successful fix.