Informed Design Knowledge Center
Share and learn how-to tips, workflows, and general knowledge articles about Informed Design and the future of the Industrialized Construction industry.

An Introduction to Functions in the Informed Design Codeblock Editor

Contributed by:

An Introduction to Functions Thumbnail.png

Autodesk Informed Design helps building component manufacturers supply configurable content to building designers.

 

Configurable models of building products and components are built in Autodesk Inventor and published to Informed Design.

 

In Revit, Informed Design is used to discover, configure, and generate Revit families from the options provided by the product publisher.

 

The Revit user configures options using a Form designed by the product publisher. The product publisher can limit the inputs on the form to manufacturable values.

 

Click here to learn more about Informed Design.

 

This input logic is defined with Informed Design Codeblocks, a ‘drag and drop’ logic interface found in Informed Design for Inventor, Product Definition, Rules Tab, Input workspace.

 

What is a Codeblock Function?

 

In Informed Design, a codeblock function is a reusable module of code that performs a specific task.

 

Functions are used to encapsulate logic or calculations, which can be called from other Codeblocks.

 

Click here for Informed Design Codeblock Video Learning

 

You can find the Function Codeblocks in the Library under ‘Functions’. There are two function codeblocks.

 

  • The ‘do something’ Function takes an input and processes it.
  • The ‘do something – return’ Function takes an input, processes it, and returns a value.

 

Function Codeblocks in Autodesk Informed DesignFunction Codeblocks in Autodesk Informed Design

 

 

A Codeblock Function to convert units

 

In this example, we’ll create a function to convert the units of an input and display it back to the user.

 

Placeholder parameters to use as Form Inputs

 

I’ve started by creating Parameters in Inventor. I’ve included placeholder parameters for use in the Product Definition form. These parameters aren’t used in my model; I’ve set the units to ul and values to 0.

 

I will use Width_in, Depth_in, and Height_in as read-only inputs in the Product Definition Form to display values in alternative units.

 

Placeholder Parameters in the Autodesk Inventor Parameter ManagerPlaceholder Parameters in the Autodesk Inventor Parameter Manager

 

Adopt Parameters from Inventor

 

In the product definition, parameters tab,  I’ve adopted the parameters.

 

Parameters adopted from Inventor in Informed DesignParameters adopted from Inventor in Informed Design

 

Form naming and layout

 

In the Rules tab, Forms workspace, I’ve ordered the inputs and renamed the inputs and the Form itself.

 

TIP: Remember to click ‘Update Form’ to see the changes in the preview.

 

The adopted parameters become inputs on the user FormThe adopted parameters become inputs on the user Form

 

 

Creating a Variable

 

In the Rules tab, Forms workspace, I started by creating a variable to hold the converted value.

 

  1. Click ‘Variables’.
  2. Click ‘Create Variable’
  3. Give your variable a name.
  4. Click OK.

 

Creating a Variable in the Informed Design Codeblock editorCreating a Variable in the Informed Design Codeblock editor

 

 

Creating a Function

 

Next, I added a Function block. I choose a ‘do something and return’ block.

 

  1. Click ‘Functions’
  2. Click ‘do something and return’

 

TIP: I don’t want users to change the returned values shown in Inches, so I’ve added Codeblocks to set these inputs to read-only.

 

Adding a function Codeblock in Informed DesignAdding a function Codeblock in Informed Design

 

 

Adding a Function Variable

 

With the Function block in the canvas, I clicked on the ‘+’ (Plus) symbol to add a function variable. This variable holds the value that we will pass into the Function.

 

As soon as the variable is created in the Function block, it can also be found in the variables section of the Codeblock library.

 

  1. Click on ‘+’ in the Function block to create a variable.

Note: The variable can be found immediately in the Codeblock Library.

 

Adding a variable using the Function Codeblock in Informed DesignAdding a variable using the Function Codeblock in Informed Design

 

 

Adding a Function calling block

 

Using the Codeblocks from the library, I added blocks to convert my input value into my output value.

 

In this case, we are taking the ‘Value in Inches’, and making it equal to the input value, multiplied by 0.039.

The value is returned via the ‘value_in_inches’ variable.

 

The final step is to use the Function calling block. This is the block we will use to call our function. We will pass the calling block a value, and do something with the output.

 

  1. Add the Function calling block to the canvas

 

Adding a function calling block in Informed DesignAdding a function calling block in Informed Design

 

 

Using the Function calling block

 

I  pass the Function calling block the ‘Width’ value, which is converted, and passed to the read-only ‘Width_in’ input.

On updating the Form, we can see the value in inches in the read-only ‘Width (in)’ input field.

 

  1. Using the Function calling block

 

Testing the Informed Design Codeblock functionTesting the Informed Design Codeblock function

 

 

Using the Function multiple times

 

The final step is to ‘Duplicate Connected’, changing the parameters we pass into the calling block, and the parameters that will receive the output value.

 

  1. Hand Width = to the mm_to_in Function, and show the Value in the Width_in read-only input.
  2. Repeat for Height
  3. Repeat for Length
  4. Update the form to see the changes.

 

Reusing the Informed design Codeblock  functionReusing the Informed design Codeblock function

 

 

TIP: The values in the read-only inputs will not equal the values of the parameters we adopted from the model (we set them to ‘0’ remember!). We can use ‘Set Model Values’ and ‘Get Model Values’ to sync up the parameter values ready for publishing.

 

Use 'Set' and 'Get' model values to sync the Form inputs to the Inventor modelUse 'Set' and 'Get' model values to sync the Form inputs to the Inventor model

 

 

Tha parameters in Inventor now match the  Form inputsTha parameters in Inventor now match the Form inputs

 

 

Informed Design Codeblock functions

 

Informed Design Codeblock Functions can be used to optimize your input logic, making it easier to read and quicker to produce.

 

If you ever find yourself copying the same blocks of code multiple times, consider whether you could use a Function instead!

 

Final tip: Use the Backpack, or export code blocks to re-use your Functions across multiple Product definitions. Click here for more Codeblock best practices.