• Informed Design
  • Inventor

Codeblocks - set parameter minimums, maximums, and increments

Use code blocks to set parameter minimums, maximums, and increments in the Informed Design Codeblocks Rule Editor.


Step-by-step guide:

In Informed Design, code blocks can be used to set parameter minimums, maximums, and increments, as well as to edit labels and add messages.

Adopted parameters can be configured to include a minimum and maximum value range by applying the Min and Max functions within the parameter blocks.

Begin with blocks setting lists of values already created, as shown below.

  • In the Product Definition dialog box, in the Rules workspace, two blocks setting lists of values for Nominal Wall Length and Nominal Wall Height.

To create a minimum and maximum value range for the Nominal Wall Height parameter:

  1. Remove the Create List With block.
  2. Set the input drop-down to min.
  • The Nominal Wall Height parameter block, with the Create List With block removed and min being selected in the input drop-down.
  1. Add a Math Number block and set the value to 8.
  2. Right-click the block and select Duplicate, change the input drop-down to max, and set the value to 10.
  • The Min and Max blocks configured for the Nominal Wall Height parameter.
  1. Click Update form to test the logic.

The minimum and maximum value range is displayed as an informational label below the Nominal Wall Height input.

  • In the form, Update form being clicked and the value range added and highlighted in red below the Nominal Wall Height parameter.
  1. Test the parameter with a value that is above the maximum, such as 999.

The parameter resets to the maximum value, with a message that explains the adjustment.

  • In the form, the Nominal Wall Height value reset to the maximum value of 10, the hand pointer over the message icon, and the message displayed.
  1. Enter a value below the minimum, such as 1, and the parameter resets to the minimum value.

To set a Min and Max for the Nominal Wall Length parameter:

  1. Right-click the block and select Duplicate Connected to recreate the Min and Max blocks.
  2. Change both parameters to Nominal Wall Length, set the minimum value to 4, and discard the existing Length Values List block.
  • The duplicated and updated Min and Max blocks for the Length parameter.
  1. Click Update form to test the logic.

The minimum and maximum value range appears below the Nominal Wall Length input, and testing values outside the range confirms that it is working correctly.

Next, use an increment value in a parameter block to specify the increments available within the minimum and maximum value range.

  1. Duplicate the Nominal Wall Height parameter max block, change the input drop-down to increment, and set the value to 0.5.
  2. Follow the same steps to add an increment block to the Nominal Wall Length block, and set the value to 0.1.
  3. Right-click the canvas and select Clean up Blocks to align the blocks.
  • The Nominal Wall Height and Length parameter blocks with added increment blocks, and on the canvas, the context menu expanded with Clean up Blocks being selected.
  1. Click Update form to test the logic.

The increment information displays below the input controls, and using the up and down arrows verifies that the increments are working as intended.

  • The updated form, with increment information displayed below each of the two input controls, and incremental values set for each parameter.

Next, adjust the default form labels by removing the underscores and applying a reader-friendly label:

  1. Duplicate the Nominal Wall Length max block and change the input drop-down to label.

The parameter block automatically removes the Math Number block, because it is the incorrect data type.

  1. Add a Text block and enter a reader-friendly label string, such as "Wall Length".
  • The parameter block set up with a label of “Wall Length”.
  1. Click Update form to display the new label.
  • In the form, the updated Wall Length label applied.

Now, update the Stud Spacing parameter to be read-only and remove the underscore from its label:

  1. Duplicate the Nominal Wall Length parameter block and change the drop-down to Stud_Spacing.
  2. Change the input drop-down to readOnly.

The block automatically removes the Math Number block, prompting placement of the correct data type.

  1. Add a True False block with the value set to true.
  2. Duplicate the Nominal Wall Length label block, change the parameter to Stud_Spacing, and add it below the read-only block.
  3. Update the Text block to "Stud Spacing".
  • The Stud Spacing block set up to display a read-only parameter with the label “Stud Spacing” in the form.
  1. Click Update form.

The label updates, and the Stud Spacing parameter is now read-only.

  • In the form, the underscore removed from the Stud Spacing label and the parameter updated and labeled as “Read Only”, with the label and value grayed out.

To control the visibility of parameters in the form, based on a specified condition:

  1. Add an If Do block and an Operation block, with Nominal Wall Length value blocks on both sides of the equation.
  2. Right-click and select External Inputs to wrap the code block for a better fit.
  • The new If Do block, with its context menu expanded and External Inputs being selected.
  1. Set the operation to greater than (>), and set the second input drop-down to max.
  2. Duplicate the Stud Spacing read-only block and add it to the Do portion. Set the input drop-down to visible and the value to false.
  • The If Do block set up to evaluate if wall length exceeds the wall length max value, and if so, then the Stud Spacing input control will not be visible.
  1. To test the logic, in the form, set the Wall Length parameter to a value that exceeds the maximum, such as 999. The Stud Spacing parameter is no longer visible, the Wall Length parameter resets to 10, and a message icon displays.
  2. Set the parameter to a value less than the max, such as 9, and the Stud Spacing control becomes visible again.
  • On the left, the form after entering a length value of 999, with an updated value of 10 and the Stud Spacing parameter not visible; and on the right, the form with a length value of 9 entered and the Stud Spacing parameter visible.

Next, add messages to the parameter controls:

  1. Begin with a variable already created to calculate the area of a wall.
  2. Duplicate the Nominal Wall Length max parameter block and set the input drop-down to message.
  3. Use the Create Text With block to set up a text message that combines static Text with the calculated Area value pulled from the area variable.
  4. Update the Text block to read "The current overall wall area is:", then add another Text block that reads "square feet" and place it below the Area block.
  • An Area variable set up with a Message block.
  1. Click Update form, then place the pointer over the message icon to display the area calculation. Changing the parameter updates the area calculation and message.
  • In two side-by-side images of the form, on the left, length and height values of 4 and 8, with the message showing a calculated area of 32, and on the left, the height updated to 10 and the area updated to 40, both highlighted in red.

Next, add an error message to the parameter input, based on a specific condition:

  1. Set up the If Do block, so that when the calculated area variable is less than 35, the specified error message displays.
  • The If Do block set up to display an error message when the calculated area is less than 35.
  1. Click Update form.

When the condition is true, the Wall Length parameter in the form turns red and displays the specified message.

  • In the form, the Wall Length set to 4, the parameter label and outline displayed in red, and the hand pointer hovering over a red message icon to display the error message.

In summary, there are various ways to adjust and control parameters using code blocks. You can define minimums, maximums, and increments for acceptable parameter values, customize parameter labels, and set parameters to be read-only or not visible. Furthermore, you can use code blocks to add dynamic information and error messages that display when specific conditions are met for parameters.