Parameters – Codeblocks
Setting and getting parameter values is a cornerstone of the code blocks workflow. Here we use an if do block to get the value of the exterior panel material parameter and evaluate if it is set to steel cladding.
The due portion of the block will set the value of the wall height parameter to twelve if the material is found to be steel cladding.
To ensure that the user cannot set the wall height to some other height when the cladding is in use, we add a block to set the parameter to be read only.
Finally, we duplicate the cladding text block and add it to the block that sets the materials list values.
Testing the logic with the form shows that it works as expected by setting the height parameter to be read only and the value set to twelve, but only when steel cladding is set as the material.
In the following example, we use an if do else block to get the value of the wall height parameter to evaluate if that value is less than eight.
The existing create list block is moved into the due portion of the block and then duplicated and added to the else portion.
Two additional blocks are added to the list to include steel and aluminum cladding.
The logical intent of the code blocks is to offer the user one list of values when the wall height is less than eight. And a list with more options otherwise.
Just as parameters can be set to be read only in the form They can also be set to be visible or not visible.
Here, an if do block is replaced with an if do else block. Then the interior material parameter is set to be visible only when the exterior material is steel cladding.
Using the exterior material control in the form to test the logic, shows that it hides the interior material parameter as expected.
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.
Once again, using the exterior material control in the form to test the logic shows that it hides the interior material parameter as expected.
In summary, setting and getting parameter values is one of the most common code block tasks.
Similar to parameter values, lists of values can be set or get as well.
Setting parameters in the form to be visible or not visible as well as read only or not read only is an option also.