& Construction

Integrated BIM tools, including Revit, AutoCAD, and Civil 3D
& Manufacturing

Professional CAD/CAM tools built on Inventor and AutoCAD
Integrated BIM tools, including Revit, AutoCAD, and Civil 3D
Professional CAD/CAM tools built on Inventor and AutoCAD
The function code blocks include two primary function block types, as well as a function conditional block. Functions are self contained modules of code that are set up to accomplish a specific task.
Type:
Tutorial
Length:
5 min.
Transcript
00:03
The function code blocks include two primary function block types
00:08
as well as a function conditional block.
00:11
Functions are self contained modules of code that
00:14
are set up to accomplish a specific task.
00:18
Functions are called from another calling block and run on demand. When called
00:23
often a function is handed data from the calling block at the time that it is called.
00:29
The function can be called throughout the rule as many times as needed.
00:34
It can even be handed different data each time it is called
00:38
here, we will create a function to set the area parameter value.
00:43
First, the block is added to the canvas and then the name of the function is typed in
00:49
upon adding the function,
00:51
the calling block is automatically created and added to the function blocks.
00:56
The calling block is added to the canvas at the point from which it is to be called.
01:01
Next. The plus sign is clicked in the function to add a variable.
01:06
This variable is automatically added to the calling block as well
01:10
in effect, wiring up the connection between the two blocks
01:14
using the plus sign again.
01:16
A second variable is added.
01:19
Then the parameters are plugged into the calling block so that the values are passed
01:24
to the function using the variables as the means with which to do so,
01:29
then the area parameter is added to the function
01:33
and a math block is snapped to it
01:35
providing the place to do the calculation of the
01:38
data that is to be passed into the function.
01:41
When it is called
01:43
looking in the variables,
01:44
we find that our variable blocks have been automatically created there.
01:48
For us
01:49
adding them to the math block within the function is all we
01:53
need to do to complete the function to set the area value
01:58
testing with the form shows that the area value updates as expected
02:02
and that our function works as designed.
02:06
Next,
02:06
we'll add another function using the other available function code block type
02:11
which returns an output.
02:14
First, we collapse the existing function blocks to make space in the canvas.
02:19
Next, the block is added to the canvas and then the name of the function is typed in
02:25
the calling block which was created for us
02:27
automatically is added to the canvas as well.
02:31
This type of function block expects a parameter to call the function
02:35
and receive the function output. So one is selected and joined to the calling block.
02:41
Next, the plus sign is clicked in the function to add variables.
02:46
Recall these variables are automatically added to the calling block as well.
02:51
Providing the data connections between the two blocks.
02:54
A new variable is created to provide a
02:57
container for the information that will be assembled
03:00
before passing it back up to the calling block.
03:04
The variable is placed in the function
03:07
and then a text block is added to concatenate
03:09
the label string passed in from the parameter,
03:12
a static string
03:14
and a calculated value that converts the pass
03:17
in parameter value from feet to inches.
03:20
The create text with block can be expanded to add as many lines
03:24
as needed to build the string just as you prefer to see it.
03:28
In this case,
03:29
we will use this string as the tool tip message in the form to provide
03:34
our user a quick way to see the parameter value in an alternate unit.
03:40
Then we'll add the container variable to be returned
03:43
from the function back up to the calling block.
03:47
And then finally,
03:48
we add the parameters to the calling block
03:51
to pass the information to our completed function.
03:54
Ensuring it has the data type. It expects
03:59
a quick test in the form. And we see that it works,
04:03
duplicating the calling block and updating the new instance
04:06
to use the height parameter rather than the length
04:10
is all that is needed to reuse our function
04:14
a quick snap to tidy up.
04:16
And then we can test some values in the form to
04:19
ensure that our function is serving up the feet to inches conversion
04:23
for both parameters that are calling it.
04:30
In summary functions are self contained reusable modules.
04:34
Of code that we set up to accomplish a task
04:39
functions are called from a calling block and run on demand. When called
04:45
functions are often handed data from the calling block
04:48
to perform the task they were created to do.
Video transcript
00:03
The function code blocks include two primary function block types
00:08
as well as a function conditional block.
00:11
Functions are self contained modules of code that
00:14
are set up to accomplish a specific task.
00:18
Functions are called from another calling block and run on demand. When called
00:23
often a function is handed data from the calling block at the time that it is called.
00:29
The function can be called throughout the rule as many times as needed.
00:34
It can even be handed different data each time it is called
00:38
here, we will create a function to set the area parameter value.
00:43
First, the block is added to the canvas and then the name of the function is typed in
00:49
upon adding the function,
00:51
the calling block is automatically created and added to the function blocks.
00:56
The calling block is added to the canvas at the point from which it is to be called.
01:01
Next. The plus sign is clicked in the function to add a variable.
01:06
This variable is automatically added to the calling block as well
01:10
in effect, wiring up the connection between the two blocks
01:14
using the plus sign again.
01:16
A second variable is added.
01:19
Then the parameters are plugged into the calling block so that the values are passed
01:24
to the function using the variables as the means with which to do so,
01:29
then the area parameter is added to the function
01:33
and a math block is snapped to it
01:35
providing the place to do the calculation of the
01:38
data that is to be passed into the function.
01:41
When it is called
01:43
looking in the variables,
01:44
we find that our variable blocks have been automatically created there.
01:48
For us
01:49
adding them to the math block within the function is all we
01:53
need to do to complete the function to set the area value
01:58
testing with the form shows that the area value updates as expected
02:02
and that our function works as designed.
02:06
Next,
02:06
we'll add another function using the other available function code block type
02:11
which returns an output.
02:14
First, we collapse the existing function blocks to make space in the canvas.
02:19
Next, the block is added to the canvas and then the name of the function is typed in
02:25
the calling block which was created for us
02:27
automatically is added to the canvas as well.
02:31
This type of function block expects a parameter to call the function
02:35
and receive the function output. So one is selected and joined to the calling block.
02:41
Next, the plus sign is clicked in the function to add variables.
02:46
Recall these variables are automatically added to the calling block as well.
02:51
Providing the data connections between the two blocks.
02:54
A new variable is created to provide a
02:57
container for the information that will be assembled
03:00
before passing it back up to the calling block.
03:04
The variable is placed in the function
03:07
and then a text block is added to concatenate
03:09
the label string passed in from the parameter,
03:12
a static string
03:14
and a calculated value that converts the pass
03:17
in parameter value from feet to inches.
03:20
The create text with block can be expanded to add as many lines
03:24
as needed to build the string just as you prefer to see it.
03:28
In this case,
03:29
we will use this string as the tool tip message in the form to provide
03:34
our user a quick way to see the parameter value in an alternate unit.
03:40
Then we'll add the container variable to be returned
03:43
from the function back up to the calling block.
03:47
And then finally,
03:48
we add the parameters to the calling block
03:51
to pass the information to our completed function.
03:54
Ensuring it has the data type. It expects
03:59
a quick test in the form. And we see that it works,
04:03
duplicating the calling block and updating the new instance
04:06
to use the height parameter rather than the length
04:10
is all that is needed to reuse our function
04:14
a quick snap to tidy up.
04:16
And then we can test some values in the form to
04:19
ensure that our function is serving up the feet to inches conversion
04:23
for both parameters that are calling it.
04:30
In summary functions are self contained reusable modules.
04:34
Of code that we set up to accomplish a task
04:39
functions are called from a calling block and run on demand. When called
04:45
functions are often handed data from the calling block
04:48
to perform the task they were created to do.
Functions are called from another calling block and run on demand when called.
Often a function is handed data from the calling block. At the time that it is called.
The function can be called throughout the rule as many times as needed.
It can even be handed different data each time it is called.
Here, we will create a function to set the area parameter value.
First, the block is added to the canvas, and then the name of the function is typed in.
Upon adding the function, The calling block is automatically created and added to the function blocks.
The calling block is added to the canvas at the point from which it is to be called. Next, the plus sign is clicked in the function to add a variable.
This variable is automatically added to the calling block as well. In effect, wiring up the connection between the two blocks.
Using the plus sign again, A second variable is added.
Then the parameters are plugged into the calling block so that the values are passed to the function using the variables as the means with which to do so.
Then the area parameter is added to the function, and a math block is snapped to it. Providing the place to do the calculation of the data that is to be passed into the function when it is called.
Looking in the variables, we find that our variable blocks have been automatically created there for us.
Adding them to the math block within the function, is all we need to do to complete the function to set the area value.
Testing with the form shows that the area value updates as expected and that our function works as designed.
Next, we'll add another function using the other available function code block type. Which returns an output.
First, we collapse the existing function blocks to make space in the canvas.
Next, the block is added to the canvas, and then the name of the function is typed in. The calling block, which was created for us automatically, is added to the Canvas as well.
This type of function block expects a parameter to call the function and receive the function output. So one is selected and joined to the calling block.
Next, the plus sign is clicked in the function to add variables.
Record these variables are automatically added to the calling block as well, providing the data connections between the two blocks.
A new variable is created to provide a container for the information that will be assembled before passing it back up to the calling block.
The variable is placed in the function, and then a text block is added to concatenate the label string passed in from the parameter a static string and a calculated value that converts the past in parameter value from feet to inches.
The create text with block can be expanded to add as many lines as needed to build the string just as you prefer to see it.
In this case, we will use this string as the tooltip message in the form to provide our user a quick way to see the parameter value in an alternate unit.
Then we'll add the container variable to be returned from the function back up to the calling block.
And then finally, we add the parameters to the calling block to pass the information to our completed function.
Ensuring it has the data type it expects.
A quick test in the form, and we see that it works.
Duplicating the calling block and updating the new instance to use the height parameter rather than the length, is all that is needed to reuse our function.
A quick snap to tidy up and then we can test some values in the form to ensure that our function is serving up the feet to inches conversion for both parameters that are calling it.
In summary, functions are self contained reusable modules of code, that we set up to accomplish a task.
Functions are called from a calling block and run on demand when called.
Functionsions are often handed data from the calling block to perform the task they were created to do.
How to buy
Privacy | Do not sell or share my personal information | Cookie preferences | Report noncompliance | Terms of use | Legal | © 2025 Autodesk Inc. All rights reserved
Sign in for the best experience
Save your progress
Get access to courses
Receive personalized recommendations
May we collect and use your data?
Learn more about the Third Party Services we use and our Privacy Statement.May we collect and use your data to tailor your experience?
Explore the benefits of a customized experience by managing your privacy settings for this site or visit our Privacy Statement to learn more about your options.