Share

26. Unique Codeblocks

Codeblocks that are unique to Informed Design

Informed design makes use of Google Blockly in the rules workspace of a Product Definition, to specify the layout, logic and behavior of the Input Form.

The following Codeblocks are unique to Informed Design's implementation of Blockly and have been added to the standard Blockly library of blocks available.  If you're interested in learning more about Blockly, Click here to check out this Wikipedia article on the subject.

Click here to learn how to create an Informed Design Product Definition in Inventor.

How to use Informed Design Codeblocks in the Input rules of a Product Definition to set and get Input Parameter properties (i.e. value, lists, min, max, visibility, etc.), add comments, and print messages.



Input Parameter Codeblocks

alt

Input Parameter Codeblocks are used to Set and Get the properties of Form Input Controls. Form inputs are based on the parameters which are adopted from the CAD model. The inputs are derived form, and control the CAD model.

Input Parameter Codeblocks are used to:

  • Get or Set the value of an Input.
  • Get or Set the values (the list of values to choose from) of an Input
  • Get or Set the minimum value allowed for a numeric Input
  • Get or Set the maximum value allowed for a numeric Input
  • Get of Set the increment that the value of an Input must adhere to
  • Get or Set the Visibility of an Input
  • Get or Set the Read Only status of an Input
  • Get or Set the Applicable status of an Input
  • Get or Set the Label text for an Input.
  • Get or Set the message associated to an Input that appears on mouse over of the information icon to the right of a control in the Form
  • Get or Set the Error state of the error icon to the right of a control in the Form

alt

Note: Use the Parameters space of the Product Definition to adopt Input Parameters from the base model, in order to include them in the parameter name list in Input Parameter Codeblocks

alt alt



Input Parameter Codeblocks: available properties are based on the adopted parameter data type

Adopted parameters can be Numeric, Text, or Boolean (true/false).

  1. Numeric
  2. Text
  3. Boolean

alt

The available properties for an Input are determined by its adopted parameter data type.

Adopted Parameter Data Type

NUMERIC TEXT BOOLEAN PROPERTY DESCRIPTION
value value value Get or Set the value
values values X Get or Set a list of values
X X trueLabel Get or Set the input Label, if True
X X falseLabel Get or Set the input Label, if False
min X X Get or Set the minimum value.
max X X Get or Set the maximum value.
increment X X Get or Set the value increment.
visible visible visible Get or Set the visibility of the input on the form.
readOnly readOnly readOnly Get or Set the input on the form to read only.
applicable applicable applicable Get or Set the input applicable state (indicates whether a parameter is applicable to the current configuration)
label label label Get or Set the input label.
message message message Get or Set the input message on mouse over of information or error icon to the right of the input control
error error error Get or set the input error state for the error  icon to the right of the input control


Get and Set Input values using the Input Parameter Codeblocks

How to Get and Set Input values with the Informed Design Input Parameter Codeblocks.

To SET an Input Parameter value.

Open a  Product Definition and navigate to the Rules Tab > Input workspace.

  1. From the Codeblock library, select the Parameters category.
  2. Select the 'Set' Input Parameter Codeblock and drag it into the canvas.
  3. From the Codeblock parameter name drop down list, select the desired parameter
  4. From the Codeblock property drop down list, select the value property.
  5. Plug in a Codeblock for setting the value or values list (a text or number block, or a text or number list).
Note: The 'values' property is not available for boolean parameters.

alt

To GET the value of an Input Parameter.

Edit the Product Definition. Navigate to the Rules Tab > Input workspace.

  1. From the Codeblock library, select the Parameters category
  2. Select the 'Get' Input Parameter Codeblock and drag it onto the canvas
  3. From the Codeblock parameter name drop down list, select the desired parameter
  4. From the Codeblock property drop down list, select the value property
  5. Insert the 'Get' Input Parameter Codeblock into another Codeblock as its' value input.
Note: The data type of the value returned depends on the Input Parameter data type - Numeric, Text, or Boolean (true/false).

alt



To Set the minimum, maximum, and increment value an Input Parameter Codeblock.

Codeblocks can be used to limit the allowable values for an Input on the Form.

How to set the allowable minimum, maximum, and increment value.

Edit the Product Definition. Navigate to the Rules Tab > Input workspace.

  1. From the Codeblock library, select the Parameters category.
  2. Select the 'Set' Input Parameter Codeblock and drag it onto the canvas.
  3. From the Codeblock parameter drop down list, select the desired parameter.
  4. From the Codeblock property drop down list, select the 'min' property
  5. From the Codeblock library, select the 'Math' category.  Insert a numeric block and enter a value for the minimum allowed.
  6. Duplicate the connected blocks. Set the property to 'max', set the numeric block value to the maximum allowed.
  7. Duplicate the connected blocks. Set the property to 'increment', set the numeric block value to the increment allowed.
  8. Use the Update Form command to apply all Codeblock changes to the Form and then test the Form to see if it works as expected by entering values not allowed (i.e. too large or small or not incremented as specified).
Note: The Input label below the control on the Form is automatically added to reflect the min, max, and increment information set by the Codeblocks.

alt



To Set an Input label with an Input Parameter Codeblock.

Codeblocks can be used to change the Input Labels on the Form.

How to set the Input labels on a Form with the Input Parameter Codeblocks.

Edit the Product Definition. Navigate to the Rules Tab > Input workspace.

  1. From the Codeblock Library, select the Parameters category.
  2. Select the 'Set' Input Parameter Codeblock and drag it onto the canvas
  3. From the Codeblock Parameter drop down list, select the desired parameter.
  4. From the Codeblock Property drop down list, select the 'label' property
  5. From the Codeblock Library, select the Text category. Insert a 'letter, word, or line of text' block to provide the value for the label.
  6. Use the Update Form command to apply all Codeblock changes to the Form and then review the Form labels to determine if they appear as expected.
Note: See also Input message.

alt



To Set an Input message with an Input Parameter Codeblock.

Codeblocks can be used to add a message to an Input on the Form.

This message appears on mouse over of the information or error icon that appears to the right of the Input on the Form

How to set an Input label message with an Input Parameter Codeblock.

Edit the Product Definition. Navigate to the Rules Tab > Input workspace.

  1. From the Codeblock Library, select the Parameters category.
  2. Select the 'Set' Input Parameter Codeblock and drag it onto the canvas
  3. From the Codeblock parameter list drop down, select the desired parameter.
  4. From the Codeblock property drop down list, select the 'message' property
  5. From the Codeblock Library, select the Text category. Insert a 'letter, word, or line of text' block to set the message text value.
  6. Use the Update Form command to apply Codeblock changes to the Form and review/test the 7. Form to confirm the message appears when it should and contains the desired message.

A blue information symbol will appear to the right of the Input on the Form. On mouse over, the message will be displayed.

Note: Also see the Error message.

alt



To Display an Error message for an input on the form with an Input Parameter Codeblock.

A Codeblock can be used to display an Error message for an Input on the Form.

How to display the Error message with an Input Parameter Codeblock.

Edit the Product Definition. Navigate to the Rules Tab > Input workspace.

  1. From the Codeblock library, select the Parameters category.
  2. Select the 'Set' Input Parameter Codeblock and drag it onto the canvas
  3. From the Codeblock Parameter drop down list, select the desired parameter.
  4. From the Codeblock Property drop down list, select the 'error' property.
  5. From the Codeblock library, select the Logic category. Insert a 'Returns either true or false' block and set its value to 'true'.
  6. Use the Update Form command to apply the Codeblock changes to the Form, then test your Form to see if the error message appears as expected. On mouse over of the error icon that appears to the right on the Input control, a generic error message will be displayed.
  7. (Optional) Connect a second Input Parameter Codeblock that references the same parameter, and use the 'message' property to customize the error message, 

The Input border will turn red. An error icon will appear to the right of the input. On mouse over, the message will be displayed.

A product variant cannot be generated while an Input is in an error state.

Note: Also see the Input message.

alt



To Set an Input to read-only with an Input Parameter Codeblock.

A Codeblock can be used to make an Input read-only.

How to set the Input to read-only with an Input Parameter Codeblock.

Edit the Product Definition. Navigate to the Rules Tab > Input workspace.

  1. From the Codeblock library, select the Parameters category.
  2. Select the 'Set' Input Parameter Codeblock and drag it onto the canvas
  3. From the Codeblock Parameter drop down list, select the desired parameter.
  4. From the Codeblock Property drop down list, select the 'readOnly' property
  5. From the Codeblock library, select the 'Logic' category, insert a 'Returns either true or false.' Codeblock and set its value to 'True'.
  6. Use the Update Form command to apply the Codeblock changes and then test the Form to verify that the read-only state is set as expected.

When read-only is set to 'false', the Input can be edited. When set to 'true', the Input will be read-only, appear as 'greyed out' and "(Read only)" will be appended to the Input label automatically.

Note: See also, Input visibility, and Input applicable.

alt



To Set Input Control Visibility with an Input Parameter Codeblock.

A Codeblock can be used to hide an Input Control on the Form

How to set the Input visibility with an Input Parameter Codeblock.

Edit the Product Definition. Navigate to the Rules Tab > Input workspace.

  1. From the Codeblock library, select the Parameters category
  2. Select the 'Set' Input Parameter Codeblock and drag it onto the canvas
  3. From the Codeblock Parameter drop down list, select the desired parameter.
  4. From the Codeblock Property drop down list, select the 'visible' property
  5. From the Codeblock library, select the 'Logic' category, insert a 'Returns either true or false.' block, and set the value to 'false'.
  6. Use the Update Form command to apply the Codeblock changes and then test the Form to confirm that the Input control visibility behaves as expected.

When visibility is set to 'true', the Input control will be visible. When set to 'false' the Input control will be hidden.

Note: See also, Input read-only, and Input applicable.

alt



To Set an Inputs' applicable option with an Input Parameter Codeblock.

A Codeblock can be used to set the applicable option of an Input. Inputs that are not applicable to a configuration will be indicated in the Informed Design add-in for Revit > Customize and Insert dialog > Select table.

alt

How to set the Input applicable option with an Input Parameter Codeblock.

Edit the Product Definition. Navigate to the Rules Tab > Input workspace.

  1. From the Codeblocks library, select the Parameters category
  2. Select the 'Set' Input Parameter Codeblock and drag it onto the canvas
  3. From the Codeblock Parameter drop down list, select the desired parameter.
  4. From the Codeblock Property drop down list, select the 'applicable' property
  5. From the Codeblock library, select the 'Logic' category, insert a 'Returns either true or false.' block and set its value to 'false'.
  6. Use the Update Form command to apply the Codeblocks changes to the Form and very that the applicable status is set and behaves as expected.

When 'applicable' is true, the Input can be edited. When it's false, the input will be read-only, greyed out, and the Inputs' label will automatically be appended with '(Not applicable)'.

Note: See also, Input read-only, and Input visible.

alt



The Comment Codeblock

Use the comment Codeblock to communicate the intent of the Codeblock logic with inline comments.

How to add Inline comments with the Comment Codeblock.

Edit the Product Definition. Navigate to the Rules Tab > Input workspace.

  1. From the Codeblock library, select the Parameters category.
  2. Select the 'Comment here' Codeblock and drag it into the canvas
  3. Replace the "Comment here" default text in the Codeblock with your comment.
Note: The Comment Codeblock can only display 50 characters. Beyond 50 characters an ellipses (three dots '...') will display. Use multiple Comment Codeblocks for multi-line comments that require more than 50 characters to be visible without clicking into the comment Codeblock.

alt



The Print Codeblock

The print Codeblock is used to display a message that will appear on screen when using the Informed Design add-in for Revit. The message can be triggered as the Revit user changes input values and makes selections in a product form.

How to 'print' values to a message box using Codeblocks.

Edit the Product Definition. Navigate to the Rules Tab > Input workspace.

  1. From the Codeblocks library, select the Text category.
  2. Select the Print Codeblock and drag it onto the canvas.
  3. Insert a text, or number Codeblock (also found in the Text category of the Codeblocks library), to hold the value to be printed.
  4. Use the Update Form command apply the Codeblock changes to the form.
  5. The result will display in a message box that pops up whenever an Input value is changed in the Form.
Note: The Print block will not interrupt the Codeblock logic as it runs. All Codeblock logic gets run after every/any change to the Input value of a Form. The message will be shown when the Codeblock logic has finished running. Values from all print blocks will be written to the message box that appears. You can use the Print block in combination with logic Codeblocks to show different messages in response to different inputs conditions.

alt

Was this information helpful?