Now that we have familiarized ourselves with the interface layout and navigating the Workspace, our next step is to understand the typical workflow for developing a graph in Dynamo. Let's get started by creating a dynamically sized circle and then create an array of circles with varying radii.
Defining Objectives and Relationships
Before we add anything to the Dynamo Workspace, it is key that we have a solid understanding of what we are trying to achieve and what the significant relationships will be. Remember that anytime we are connecting two Nodes, we are creating an explicit link between them - we may change the flow of data later, but once connected we've committed to that relationship. In this exercise we want to create a circle (Objective) where the radius input is defined by a distance to a nearby point (Relationship).
A point that defines a distance-based relationship is commonly referred to as an "Attractor." Here the distance to our Attractor Point will be used to specify how big our circle should be.
Adding Nodes to the Workspace
Now that we have our Objectives and Relationships sketched we can begin creating our graph. We need the Nodes that will represent the sequence of actions Dynamo will execute. Since we know we are trying to create a circle, let's start by locating a Node that does so. Using the Search field or browsing through the Library, we will find that there is more than one way to create a circle.
- Browse to Geometry > Circle > ByCenterPointRadius
- Search > "ByCenterPointRadius..."
Let's add the Circle.ByCenterPointRadius Node to the Workspace by clicking on it in the Library - this should add the Node to the center of the Workspace.
- The Circle.ByCenterPointRadius Node in the Library
- Clicking the Node in the Library adds it to the Workspace
We also will need Point.ByCoordinates, Number Input, and Number Slider Nodes.
- Geometry > Point > ByCoordinates (x,y,z)
- Geometry > Geometry > DistanceTo
- Core > Input > Number
- Core > Input > Number Slider
Connecting Nodes with Wires
Now that we have a few Nodes, we need to connect the Ports of the Nodes with Wires. These connections will define the flow of data.
- Number to Point.ByCoordinates
- Number Sliders to Point.ByCoordinates
- Point.ByCoordinates (2) to DistanceTo
- Point.ByCoordinates and DistanceTo to Circle.ByCenterPointRadius
Executing the Program
With our Program Flow defined, all we need to do is tell Dynamo to execute it. Once our program is executed (either Automatically or when we click Run in Manual Mode), data will pass through the Wires, and we should see the results in the 3d Preview.
- (Click Run) - If the Execution Bar is in Manual Mode, we need to Click Run to execute the graph
- Node Preview - Hovering your mouse over the box on the lower right corner of a Node will give you a pop-up of the results
- 3D Preview - If any of our Nodes create geometry, we will see it in the 3D Preview.
- The output geometry on the creation node.
If our program is working, we should see a circle in the 3D Preview that is passing through our Attractor Point. This is great, but we may want to add more detail or more controls. Let's adjust the input to the circle Node so that we can calibrate the influence on the radius. Add another Number Slider to the Workspace, then double click on a blank area of the Workspace to add a Code Block Node. Edit the field in the Code Block, specifying
- Code Block
- DistanceTo and Number Slider to Code Block
- Code Block to Circle.ByCenterPointRadius
Starting simple and building complexity is an effective way to incrementally develop our program. Once it is working for one circle, let's apply the power of the program to more than one circle. Instead of one center point, if we use a grid of points and accommodate the change in the resulting data structure, our program will now create many circles - each with a unique radius value defined by the calibrated distance to the Attractor Point.
- Add a Number Sequence Node and replace the inputs of Point.ByCoordinates - Right Click Point.ByCoordinates and select Lacing > Cross Reference
- Add a Flatten Node after Point.ByCoordinates. To flatten a list completely, leave the
amtinput at the default of
- The 3D Preview will update with a grid of circles
Adjusting with Direct Manipulation
Sometimes numerical manipulation isn't the right approach. Now you can manually push and pull Point geometry when navigating in the background 3D preview. We can also control other geometry that was constructed by a point. For example, Sphere.ByCenterPointRadius is capable of Direct Manipulation as well. We can control the location of a point from a series of X, Y, and Z values with Point.ByCoordinates. With the Direct Manipulation approach, however, you are able to update the values of the sliders by manually moving the point in the 3D Preview Navigation mode. This offers a more intuitive approach to controlling a set of discrete values that identify a point's location.
- To use Direct Manipulation, select the panel of the point to be moved – arrows will appear over the point selected.
- Switch to 3D Preview Navigation mode.
- Hover over the point and the X, Y, and Z axes will appear.
- Click and drag the colored arrow to move the corresponding axis, and the Number Slider values will update live with the manually moved point.
- Note that before Direct Manipulation only one slider was plugged into the Point.ByCoordinates component. When we manually move the point in the X-direction, Dynamo will automatically generate a new Number Slider for the X input.