& Construction

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

Professional CAD/CAM tools built on Inventor and AutoCAD
Transcript
00:00
INSTRUCTOR: In this course, we will discuss how to develop
00:03
a Dynamo .dyn file from scratch.
00:06
Dynamo scripts are often referred to as graphs.
00:10
We'll start by discussing the specific tasks
00:12
we want to automate using Dynamo for Civil 3D.
00:15
We will then open up the Dynamo interface
00:18
and explore the nodes available in the Dynamo
00:21
Library for the Civil 3D and AutoCAD categories.
00:25
Lastly, we will use those nodes to build our graph that
00:28
will automate our tasks.
00:30
Let's start by switching over to the Civil 3D environment
00:33
and taking a look at our data set.
00:35
For this particular design, I would
00:37
like to place trees along the center line of the road,
00:40
as this depicts the curved boulevard in the subdivision.
00:46
I can certainly copy a block multiple times
00:48
if I want to block every 50 feet.
00:50
But what happens if the alignment changes or I
00:52
need the trees every
00:55
I would then need to recopy all of those tree blocks again.
00:59
I want to create a Dynamo script that
01:00
automates this task for me.
01:02
That way, if the alignment changes,
01:04
I can use the Dynamo player to rerun the script
01:06
to place the trees along my new alignment
01:08
at the correct intervals.
01:11
Here's a glance at the final result of our graph.
01:14
In order to create this script, we
01:16
need to think logically about the order in which
01:18
each process would take place.
01:20
We start by creating an area for the designer
01:22
to enter the alignment by name, getting
01:25
the station and specific intervals that they request.
01:29
We will finally drop the last station from this list.
01:33
Once we have those stations, the next step
01:35
will be to get the x and y-coordinate values
01:37
at those station intervals.
01:39
We also need to convert those coordinate values
01:41
into points before finally, in Group 3, creating the block.
01:45
In the third group, we will establish an area for the user
01:48
to input the block name and layer,
01:49
pushing the appropriate station coordinate locations
01:52
to that position, and then creating the block
01:54
and telling Dynamo where we want to draw those blocks
01:57
in the current drawing.
01:59
Let's switch back over to Civil 3D and get started.
02:03
Inside of Civil
02:05
to Manage tab at the top, the Visual Programming panel,
02:09
and click on the Dynamo icon.
02:11
This will launch the Dynamo User Interface.
02:15
Once we're in the Dynamo Interface,
02:17
we will click New to start a new script.
02:19
The first thing I like to do is head on down to the Execution
02:22
bar and switch the Automatic Execute script to Manual.
02:28
This ensures that I have control over when
02:30
the script runs to avoid any errors or issues along the way.
02:34
Since I'm working in the current document,
02:35
I'm going to head to the AutoCAD category,
02:38
Documents subcategory, and hover over the current listing
02:42
in the library.
02:43
If I left-click on this listing in the library,
02:46
it will create the node in my workspace.
02:49
By left picking and holding my mouse button,
02:51
I can move this node in place to organize as I go.
02:55
The next thing I want to do is select the alignment
02:57
by its name.
02:58
Since alignments are Civil 3D objects,
03:00
I'm going to go to the Civil 3D category,
03:02
Selection subcategory, and choose Alignment by Name.
03:08
We're going to move this into place
03:09
and connect the document output to the document input.
03:13
The name input value is looking for a String Data Type.
03:16
This can be found in the Input category under Basic, String.
03:22
Left-clicking, I'm going to add it to my workspace
03:24
and connect the output of the string
03:25
to the input of the name.
03:28
The next portion, I need to select my alignment stations.
03:32
Since alignments are a Civil 3D object,
03:34
I'm going to go back up to the Civil 3D category
03:37
under Civil Objects and go to Alignments.
03:41
The next node that I'm going to choose is the stations.
03:45
Once I bring that into my workspace,
03:47
I already have the data type of alignment.
03:49
So I'm going to connect the output to the input.
03:52
The data type that the interval is looking for is a double.
03:55
If you're not sure what double means,
03:57
you can go to the Library search function and type in "double."
04:01
And you'll notice that it gives you a result of number.
04:05
So I'm going to go ahead and add the number node to my workspace
04:08
and connect number output to interval input.
04:11
For Include Geometry Stations, this
04:13
is looking for a Boolean invalid,
04:15
a true or false statement.
04:17
I'm going to go back up to the library search bar and type
04:20
in "Bool."
04:22
One of the results is a Boolean.
04:24
I'm going to click to add that node.
04:26
I'm going to leave it at False for now
04:28
and connect the output to the input.
04:32
If I were to enter in a string here and run this script,
04:34
I would get a list of stations every whatever interval
04:37
that I enter.
04:39
Since I'm leaving all of this blank for now,
04:42
one of the most important things to do from this list
04:44
is to drop the last item of that list of alignments,
04:47
so that way you get an even interval
04:49
and it just lops off the last station.
04:52
So the next thing I want to do is drop the last item
04:55
from that station list.
04:57
I'm going to go back to the list category in the library
04:59
and go to Modify, Drop Items.
05:06
I'm going to pass the double values into the list.
05:09
And for the amount, I'm going to enter in a negative 1 number.
05:14
So I'm going to go back to the Input category under Basic
05:17
and choose the Number node.
05:19
Entering negative 1, I connect the output data
05:23
to the input on amount.
05:26
I've now finished the first portion of my graph.
05:30
Moving forward, the next thing I want to do
05:31
is convert those alignment stations
05:34
into coordinate systems by station and offset.
05:37
I'm going to go back up to Civil 3D,
05:39
under Civil Objects, Alignments, and I'm
05:42
going to choose the Coordinate System By Station Offset node.
05:47
For alignment input value, I'm going
05:50
to go back to the very beginning where
05:51
I have the output of alignment and connect
05:54
that output to the input.
05:57
For the station listing, I'm going
05:58
to choose my station list from the job items
06:02
and push that into the input value under Station.
06:06
For offset, I can leave this as a default of 0
06:08
because that's the default value for my particular task.
06:12
If I intend to share this with others,
06:14
I may want to offer them the opportunity
06:17
to input an offset value.
06:19
I'm going to go back up to the Input category under Basic
06:22
and select Number.
06:25
I'll connect the Number to the offset input value.
06:32
The next thing I want to do is create the blocks
06:34
in the drawing.
06:35
Now that I have the coordinate values from those stations
06:38
and offsets, I want to create the block at those station
06:41
locations.
06:42
To create the block, blocks are in AutoCAD Objects,
06:45
so I'm going to go back into AutoCAD.
06:47
And I'm going to go to Objects, Block Reference, Create.
06:57
For the source block information,
06:59
I need to call out a specific block that's
07:01
already in our drawing by name.
07:04
So I'm going to go back up to the document
07:06
and choose Block By A Specific Name.
07:09
I'm going to connect the block output to the source block
07:13
input.
07:15
For the name, again, I want to input a string value in here,
07:18
so I'm going to to go back to the Input,
07:20
Basic, [INAUDIBLE] node into my [INAUDIBLE] I'm
07:25
going to connect that string to the name.
07:27
And for the data type of this document,
07:30
I'm going to go way back to the beginning of my graph
07:33
and connect this document current to the input value here
07:38
of the document block by name.
07:42
For the next data type to create this [INAUDIBLE]
07:44
going to need a position.
07:46
The data type the position is looking for is a point.
07:50
The only output value that I have thus far
07:52
is coordinate system.
07:53
I need to find a node that will convert this coordinate system
07:56
value into an output of point so I can then
07:59
pass that information into my block reference creation.
08:02
I would suggest using the library search function
08:04
to try and find that node that converts coordinate systems
08:08
to point.
08:09
The first thing that we'll do is we'll enter in "point."
08:12
You notice that we get a lot of results.
08:15
From experience and searching through this entire result,
08:18
I know that none of these nodes will work.
08:20
I'm going to go back up to the search function and type
08:22
in "coordinate."
08:23
Again, we get a variety of results.
08:26
By scrolling down and again hovering
08:28
over each individual node, by hovering over Origin,
08:33
you'll notice that the input value here is Coordinate System
08:36
and the output is Points.
08:38
That is exactly the node that I want
08:40
to convert coordinate system to point so I can create my block
08:42
reference.
08:44
I'm going to left pick to add that node to my workspace
08:47
and move it in between the two.
08:49
I'm going to connect coordinate system to coordinate system
08:53
and the output of point to my position input on my block
08:56
reference create.
08:58
For normal rotation degrees and scale factors,
09:01
I'm going to leave the default settings.
09:04
For the layer, I need to enter a string
09:06
value, the name of the layer that I want the block inserted.
09:10
I'm going to go back to the Input category in the Dynamo
09:13
Library under Basic and choose String.
09:18
I'll connect the output of String to the layer input.
09:21
And for block, it is looking for where
09:23
do I want to enter this block reference that I'm creating.
09:27
Since I want to create these block references in the model
09:30
space of the current document, I'll
09:32
go back up to the AutoCAD category under Document
09:36
and choose Model Space.
09:39
I'll connect the output block to the input.
09:43
And for documents, since I wanted
09:44
to create it in the model space of the current document,
09:47
I will use the node from the very beginning
09:50
and connect it to the current document.
09:52
Our graph is now complete.
09:55
In the next section, I will show you
09:57
how to organize your graph using the Dynamo grouping
09:59
and aligning tools.
10:00
Organizing your graph is an important step
10:02
for ensuring readability to the next viewer of your script.
10:06
We will also review how to set nodes
10:08
as inputs so they appear as available entries
10:10
within the Dynamo player.
10:12
This is also an important step for anyone
10:14
that wants to use your script in their workflow
10:16
but is not familiar with the Dynamo interface.
00:00
INSTRUCTOR: In this course, we will discuss how to develop
00:03
a Dynamo .dyn file from scratch.
00:06
Dynamo scripts are often referred to as graphs.
00:10
We'll start by discussing the specific tasks
00:12
we want to automate using Dynamo for Civil 3D.
00:15
We will then open up the Dynamo interface
00:18
and explore the nodes available in the Dynamo
00:21
Library for the Civil 3D and AutoCAD categories.
00:25
Lastly, we will use those nodes to build our graph that
00:28
will automate our tasks.
00:30
Let's start by switching over to the Civil 3D environment
00:33
and taking a look at our data set.
00:35
For this particular design, I would
00:37
like to place trees along the center line of the road,
00:40
as this depicts the curved boulevard in the subdivision.
00:46
I can certainly copy a block multiple times
00:48
if I want to block every 50 feet.
00:50
But what happens if the alignment changes or I
00:52
need the trees every
00:55
I would then need to recopy all of those tree blocks again.
00:59
I want to create a Dynamo script that
01:00
automates this task for me.
01:02
That way, if the alignment changes,
01:04
I can use the Dynamo player to rerun the script
01:06
to place the trees along my new alignment
01:08
at the correct intervals.
01:11
Here's a glance at the final result of our graph.
01:14
In order to create this script, we
01:16
need to think logically about the order in which
01:18
each process would take place.
01:20
We start by creating an area for the designer
01:22
to enter the alignment by name, getting
01:25
the station and specific intervals that they request.
01:29
We will finally drop the last station from this list.
01:33
Once we have those stations, the next step
01:35
will be to get the x and y-coordinate values
01:37
at those station intervals.
01:39
We also need to convert those coordinate values
01:41
into points before finally, in Group 3, creating the block.
01:45
In the third group, we will establish an area for the user
01:48
to input the block name and layer,
01:49
pushing the appropriate station coordinate locations
01:52
to that position, and then creating the block
01:54
and telling Dynamo where we want to draw those blocks
01:57
in the current drawing.
01:59
Let's switch back over to Civil 3D and get started.
02:03
Inside of Civil
02:05
to Manage tab at the top, the Visual Programming panel,
02:09
and click on the Dynamo icon.
02:11
This will launch the Dynamo User Interface.
02:15
Once we're in the Dynamo Interface,
02:17
we will click New to start a new script.
02:19
The first thing I like to do is head on down to the Execution
02:22
bar and switch the Automatic Execute script to Manual.
02:28
This ensures that I have control over when
02:30
the script runs to avoid any errors or issues along the way.
02:34
Since I'm working in the current document,
02:35
I'm going to head to the AutoCAD category,
02:38
Documents subcategory, and hover over the current listing
02:42
in the library.
02:43
If I left-click on this listing in the library,
02:46
it will create the node in my workspace.
02:49
By left picking and holding my mouse button,
02:51
I can move this node in place to organize as I go.
02:55
The next thing I want to do is select the alignment
02:57
by its name.
02:58
Since alignments are Civil 3D objects,
03:00
I'm going to go to the Civil 3D category,
03:02
Selection subcategory, and choose Alignment by Name.
03:08
We're going to move this into place
03:09
and connect the document output to the document input.
03:13
The name input value is looking for a String Data Type.
03:16
This can be found in the Input category under Basic, String.
03:22
Left-clicking, I'm going to add it to my workspace
03:24
and connect the output of the string
03:25
to the input of the name.
03:28
The next portion, I need to select my alignment stations.
03:32
Since alignments are a Civil 3D object,
03:34
I'm going to go back up to the Civil 3D category
03:37
under Civil Objects and go to Alignments.
03:41
The next node that I'm going to choose is the stations.
03:45
Once I bring that into my workspace,
03:47
I already have the data type of alignment.
03:49
So I'm going to connect the output to the input.
03:52
The data type that the interval is looking for is a double.
03:55
If you're not sure what double means,
03:57
you can go to the Library search function and type in "double."
04:01
And you'll notice that it gives you a result of number.
04:05
So I'm going to go ahead and add the number node to my workspace
04:08
and connect number output to interval input.
04:11
For Include Geometry Stations, this
04:13
is looking for a Boolean invalid,
04:15
a true or false statement.
04:17
I'm going to go back up to the library search bar and type
04:20
in "Bool."
04:22
One of the results is a Boolean.
04:24
I'm going to click to add that node.
04:26
I'm going to leave it at False for now
04:28
and connect the output to the input.
04:32
If I were to enter in a string here and run this script,
04:34
I would get a list of stations every whatever interval
04:37
that I enter.
04:39
Since I'm leaving all of this blank for now,
04:42
one of the most important things to do from this list
04:44
is to drop the last item of that list of alignments,
04:47
so that way you get an even interval
04:49
and it just lops off the last station.
04:52
So the next thing I want to do is drop the last item
04:55
from that station list.
04:57
I'm going to go back to the list category in the library
04:59
and go to Modify, Drop Items.
05:06
I'm going to pass the double values into the list.
05:09
And for the amount, I'm going to enter in a negative 1 number.
05:14
So I'm going to go back to the Input category under Basic
05:17
and choose the Number node.
05:19
Entering negative 1, I connect the output data
05:23
to the input on amount.
05:26
I've now finished the first portion of my graph.
05:30
Moving forward, the next thing I want to do
05:31
is convert those alignment stations
05:34
into coordinate systems by station and offset.
05:37
I'm going to go back up to Civil 3D,
05:39
under Civil Objects, Alignments, and I'm
05:42
going to choose the Coordinate System By Station Offset node.
05:47
For alignment input value, I'm going
05:50
to go back to the very beginning where
05:51
I have the output of alignment and connect
05:54
that output to the input.
05:57
For the station listing, I'm going
05:58
to choose my station list from the job items
06:02
and push that into the input value under Station.
06:06
For offset, I can leave this as a default of 0
06:08
because that's the default value for my particular task.
06:12
If I intend to share this with others,
06:14
I may want to offer them the opportunity
06:17
to input an offset value.
06:19
I'm going to go back up to the Input category under Basic
06:22
and select Number.
06:25
I'll connect the Number to the offset input value.
06:32
The next thing I want to do is create the blocks
06:34
in the drawing.
06:35
Now that I have the coordinate values from those stations
06:38
and offsets, I want to create the block at those station
06:41
locations.
06:42
To create the block, blocks are in AutoCAD Objects,
06:45
so I'm going to go back into AutoCAD.
06:47
And I'm going to go to Objects, Block Reference, Create.
06:57
For the source block information,
06:59
I need to call out a specific block that's
07:01
already in our drawing by name.
07:04
So I'm going to go back up to the document
07:06
and choose Block By A Specific Name.
07:09
I'm going to connect the block output to the source block
07:13
input.
07:15
For the name, again, I want to input a string value in here,
07:18
so I'm going to to go back to the Input,
07:20
Basic, [INAUDIBLE] node into my [INAUDIBLE] I'm
07:25
going to connect that string to the name.
07:27
And for the data type of this document,
07:30
I'm going to go way back to the beginning of my graph
07:33
and connect this document current to the input value here
07:38
of the document block by name.
07:42
For the next data type to create this [INAUDIBLE]
07:44
going to need a position.
07:46
The data type the position is looking for is a point.
07:50
The only output value that I have thus far
07:52
is coordinate system.
07:53
I need to find a node that will convert this coordinate system
07:56
value into an output of point so I can then
07:59
pass that information into my block reference creation.
08:02
I would suggest using the library search function
08:04
to try and find that node that converts coordinate systems
08:08
to point.
08:09
The first thing that we'll do is we'll enter in "point."
08:12
You notice that we get a lot of results.
08:15
From experience and searching through this entire result,
08:18
I know that none of these nodes will work.
08:20
I'm going to go back up to the search function and type
08:22
in "coordinate."
08:23
Again, we get a variety of results.
08:26
By scrolling down and again hovering
08:28
over each individual node, by hovering over Origin,
08:33
you'll notice that the input value here is Coordinate System
08:36
and the output is Points.
08:38
That is exactly the node that I want
08:40
to convert coordinate system to point so I can create my block
08:42
reference.
08:44
I'm going to left pick to add that node to my workspace
08:47
and move it in between the two.
08:49
I'm going to connect coordinate system to coordinate system
08:53
and the output of point to my position input on my block
08:56
reference create.
08:58
For normal rotation degrees and scale factors,
09:01
I'm going to leave the default settings.
09:04
For the layer, I need to enter a string
09:06
value, the name of the layer that I want the block inserted.
09:10
I'm going to go back to the Input category in the Dynamo
09:13
Library under Basic and choose String.
09:18
I'll connect the output of String to the layer input.
09:21
And for block, it is looking for where
09:23
do I want to enter this block reference that I'm creating.
09:27
Since I want to create these block references in the model
09:30
space of the current document, I'll
09:32
go back up to the AutoCAD category under Document
09:36
and choose Model Space.
09:39
I'll connect the output block to the input.
09:43
And for documents, since I wanted
09:44
to create it in the model space of the current document,
09:47
I will use the node from the very beginning
09:50
and connect it to the current document.
09:52
Our graph is now complete.
09:55
In the next section, I will show you
09:57
how to organize your graph using the Dynamo grouping
09:59
and aligning tools.
10:00
Organizing your graph is an important step
10:02
for ensuring readability to the next viewer of your script.
10:06
We will also review how to set nodes
10:08
as inputs so they appear as available entries
10:10
within the Dynamo player.
10:12
This is also an important step for anyone
10:14
that wants to use your script in their workflow
10:16
but is not familiar with the Dynamo interface.
Try it: Developing the script to automate task