• Informed Design
  • Inventor

Codeblocks - set and get parameter values

Set and get input values using the Parameter block in the Informed Design Codeblocks Rule Editor.


Step-by-step guide

To begin, create a code block that sets a nominal wall height parameter value when a specific exterior panel material is used, and ensure that the value cannot be changed for that material.

  1. With an already created Exterior Panel Material list, add an If Do block to the canvas.
  • In the Rules workspace of the Informed Design interface, the If Do block being selected from the Logic blocks library; and on the canvas, an Exterior Panel Material list already created.
  1. Add a Comparison block to the if portion of the statement.
  2. Add the Nominal Wall Height value parameter block to the first part of the calculation, and set the drop-down to Exterior Panel Material.
  • Below the Exterior Panel Material list, the If Do block, with an added equals operator and Exterior Panel Material being selected in the parameter drop-down.
  1. Leave the operator set to equals (=) and add a Text block that reads “Steel Cladding”.
  2. To the Do portion of the block, add a Nominal Wall Height value equals block and a Math Number block with a value of 12.
  3. Duplicate this parameter block, place it below the existing one, and adjust the value drop-down to readOnly.
  4. Delete the Math Number from the duplicate, and from the Logic library, add a True block.
  5. Duplicate the Steel Cladding text block and add it to the Exterior Panel Material list.
  • The If Do block set up so that when the Exterior Panel Material is set to “Steel Cladding”, a read-only value of 12 is applied, and a duplicate Steel Cladding text block being added to the Exterior Panel Material list.
  1. In the form, test the logic by selecting each of the Exterior Panel Material options.

When Steel Cladding is selected, a read-only value of 12 is applied, and when the other options are selected, the parameter value can be edited.

  • In the form, Steel Cladding selected and the Nominal Wall Height set to 12, which appears grayed-out to indicate that it is read-only.

Next, use the If Do Else block to create a code block that offers a specific list of materials when the parameter is less than 8, and otherwise, a list with more options.

  1. Add an If Do Else block to the canvas.
  2. To the If portion of the statement, add a Comparison block and a Nominal Wall Height value parameter block, set the operation to less than (<), and add a Math Number block with a value of 8.
  3. Move the existing Create List block to the Do portion of the If Do Else block.
  4. Duplicate the Create List block and add it to the Else portion of the statement.
  5. Click the plus (+) twice to add two additional materials. Right-click a material Text block and select Duplicate, then change the text to “Steel Cladding”. Repeat for “Aluminum Cladding”.
  • The If Do Else block set up so that if the parameter value is less than 8, the user sees a specific list of exterior panel materials; and otherwise, a list with more options.
  1. In the form, test the code block by entering a Nominal Wall Height value of 7.
  2. Expand the Exterior Panel Materials drop-down to see that there are 2 options, since the value is less than 8.
  • In the Form, a value of 7 entered for the Nominal Wall Height, and the material list expanded to show two options.
  1. Update the Nominal Wall Height to 9, and now, the Exterior Panel Material includes 4 options.

Parameters can also be set to be visible or not visible when certain conditions are met.

  1. Start with the code block from the first example, and replace the If Do block with an If Do Else block.
  • Below the Exterior Panel Material lists, the code block from the first example, with the If Do block being replaced by an If Do Else block.
  1. Duplicate the read-only parameter block, set the parameter drop-down to Interior Panel Material, and set the readOnly drop-down to visible.
  • In the duplicated parameter block, the input changed to Interior Panel Material and the readOnly drop-down being set to visible.
  1. Add the duplicated block to the Do portion of the statement below the existing blocks.
  2. Duplicate this new parameter block, add it to the Else portion of the statement, and change the true value to false.

Now, if the Exterior Panel Material is Steel Cladding, then the Interior Panel Material parameter will be visible. For all other exterior materials, the interior material parameter will be hidden.

  • The If Do Else statement with the interior material parameter set to be visible only when the exterior material equals Steel Cladding.

To test the logic:

  1. On the form, select Steel Cladding, and note that the Interior Panel Material list is visible.
  • In the form, Steel Cladding selected as the Exterior Panel Material, and the Interior Panel Material list visible and expanded.
  1. Select a different material, such as Composite Hardboard (Painted Blue), and note that the Interior Panel Material list is now hidden.
  • In the form, Composite Hardboard is selected for the Exterior Panel Material, and the Interior Panel Material list is not visible.

Another way to accomplish the same thing is to set the visibility of the interior material parameter to always be equal to the equation Exterior Panel Material equals Steel Cladding, as shown below.

  • The visibility of the Interior Panel Material parameter set to always be equal to the equation: Exterior Panel Material equals Steel Cladding.
  1. In the form, change the Exterior Panel Material to see that the interior material parameter is only visible when Steel Cladding is selected.

In summary, setting and getting parameter values, or lists of parameter values, is one of the most common code block tasks. Additionally, parameters can be set to be visible or not visible, as well as to be read-only.

Was this information helpful?