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.
- With an already created Exterior Panel Material list, add an If Do block to the canvas.
- Add a Comparison block to the if portion of the statement.
- Add the Nominal Wall Height value parameter block to the first part of the calculation, and set the drop-down to Exterior Panel Material.
- Leave the operator set to equals (=) and add a Text block that reads “Steel Cladding”.
- 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.
- Duplicate this parameter block, place it below the existing one, and adjust the value drop-down to readOnly.
- Delete the Math Number from the duplicate, and from the Logic library, add a True block.
- Duplicate the Steel Cladding text block and add it to the Exterior Panel Material list.
- 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.
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.
- Add an If Do Else block to the canvas.
- 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.
- Move the existing Create List block to the Do portion of the If Do Else block.
- Duplicate the Create List block and add it to the Else portion of the statement.
- 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”.
- In the form, test the code block by entering a Nominal Wall Height value of 7.
- Expand the Exterior Panel Materials drop-down to see that there are 2 options, since the value is less than 8.
- 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.
- Start with the code block from the first example, and replace the If Do block with an If Do Else block.
- Duplicate the read-only parameter block, set the parameter drop-down to Interior Panel Material, and set the readOnly drop-down to visible.
- Add the duplicated block to the Do portion of the statement below the existing blocks.
- 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.
To test the logic:
- On the form, select Steel Cladding, and note that the Interior Panel Material list is visible.
- Select a different material, such as Composite Hardboard (Painted Blue), and note that the Interior Panel Material list is now hidden.
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.
- 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.