Video Script - Autodesk Design Academy

advertisement
Data Management – June 18, 2015
In this lesson we will discuss the basic concepts creating and working with lists in Dynamo for Revit and
Dynamo Studio. Let’s begin by searching for the number sequence node. The number sequence will
create a sequence of numbers. To define its inputs start, amount, and step I will use a “number” node.
Connect the output of the number node to the start input to define the starting value of the sequence. I
will then repeat this process with 2 more “number” nodes to define the amount of values in the
sequence as well as the step increment.
Let’s increase the amount to 10 and the step to 1. Clicking on the rectangle in the lower right corner of
the “number-sequence” I will see a pop up indicating that there is an empty list. By pressing run we can
run of definition, updating the displayed list.
Let’s now search for a “number-range” node. The “number-range” node creates a sequence of numbers
in a given range. I will use more “number” nodes to define its inputs. Connect the first node to the start
input, the second node to the end, and the third to the step. Let’s start at 0, end at 10, and step by 1. I
will click on the rectangle at the lower right hand corner of the “number-range” node to display its
output. Again, we need to press run to recalculate our new values.
Clicking run automatically will allow us to see the changes we make reflected automatically.
Let’s now look at how we may use the number node to be able to define sequences. Search the node
library for number to add a new “number” node to the workspace. Using a “watch” node we can display
its output. In the number field of the “number” node type 0..10 and hit enter. This will result in a list of
values beginning with 0 and ending at 10. The step between the values is by default 1. If changes are
made to the “number” node changes are reflected dynamically in the “watch” node. Changing the end
value to 6 we will see that we now have a collection of 5 values, beginning at 2 and ending at 6, and
incrementing by 1.
Let’s copy and paste the “number” and “watch” nodes to see what other sequences we can define using
the “number” node. By adding ..#10 we will see we now have a list stating at 2, ending at 6 with a total
number of 10 values. Remember that the first index in a list is 0, therefore the last number in the index
is 1 less than the number we defined for our total count.
Let’s copy and paste of “number” and “watch” node one last time. This time I will swap the pound sign
for the second number. This will result in a list that starts with 2, contains 6 values, and increments by
10.
Let’s use the string modifier start, end, and count to define a sequence of points. I will search for the
point XYZ node and add it to the workspace. Let’s connect the “watch” output port to the X input port
of our “point-by-coordinates”. Clicking on the rectangle at the bottom right corner of our node we will
see a list of points. To view these points let’s turn on the background 3D preview. Remember, to
navigate the background of the 3D preview you can use ctrl+G. Let’s change the start value in our
sequence. Let’s now change the total count. I will collapse the node display by clicking on the rectangle
again. Notice the icon at the bottom of the “points-by-coordinate” node. This indicates the lacing for
this particular node. Lacing determines how an input port should use the incoming data. By right
clicking on the XYZ node I can access the lacing options shortest, longest, and cross product. By
connecting the output of my “watch node” to the Y input we will see that we now have a diagonal list of
points. By right clicking and change the lacing option to cross product we now have a grid of points.
Lacing operations are an important component to effectively work with multiple sequences of data.
For instance, if you are needing to construct a sequence of line segments you would need to create
more than one collection of points. I will right click on my ‘point-by-coordinates” node and change the
lacing option back to longest. I will disconnect the Y import port and replace it with a number node. I
will also use the “number” node to define the Z port input.
Let’s copy and paste our nodes and create a list of lines by start and end points. I will type line into the
search field of the node browser. My top result is by start and end point. Connecting the output port of
my first point to the start and the output of my second point to the end I will receive a warning from
Dynamo. By mousing over the balloon I will see there is a warning stating that a line cannot be created
because the lines are coincident. I will copy and paste the number node and define a new Z value. By
increasing this value and pressing enter I can now see the display in the background 3D preview update.
By changing the count value in the number node we will now see that we have an uneven number of
points on the top and bottom.
By right clicking on the “line-by-start-point-and-end-point” node I can change the lacing option from
shortest to longest. This more clearly illustrates the way in which Dynamo is computing this particular
solution. The last point in the shorter list is executed on for the remaining items in the longest list. By
right clicking and changing the lacing option back to shortest we will see that the shortest list is no
longer going to execute on the remaining elements in the longest list. By right clicking and changing the
lacing option one last time to cross product we will see that all solutions will be computed. Let’s go
ahead and set the lacing option back to longest.
To make sure we do not end up with 2 lists of varying lengths I will delete my number node defining my
end point. I will use the same number node for both my start and end. By making changes to either of
these values the start or the end we will see that our list will update and the background 3D preview will
display the results.
With the correct number of lines being computed, I would like to now see if I could use a mathematically
function to change the character of our segments. What I would like to see is the effect of a modulating
lower point sequence using a sine function. The “sine” node is located in core-math-actions. The input
port of the sine node is labeled angle. I will put my mouse over the port to see what type of data this
port requires. Because the data input requires the data to be in degrees, I will need to find a node to
convert my sequence of values from radians to degrees. Looking through the list of nodes in the math
category I will see there is a node called “degrees-to-radians”, you will also see “radians-to-degrees”.
We will choose “radians-to-degrees” to add the node to our workspace and connect the output of our
watch node to the input radians. The output of “radians-to-degrees” will connect to the the angle input
of the “math-sine” node. I will now connect the output of the “math-sine” node to the Y input of my
“point-by-coordinates” node.
To add a little more interaction to our definition, let’s look at an interesting feature of the “number”
node. Strings used to define sequences in a “number” node can be modified to include variables. I am
going to replace the count value with the variable “A”. In doing so an input port is added to the
“number” node. We can now connect an “integer slider” to this port to quickly change the number of
points computed. I will take the output port of the integer slider and connect it to the “A” input port of
the “number” node. I can now make changes on the fly and see the background 3D preview display in
real time.
Download