Using Dynamo to Brainstorm Revit Toposolids From Sketch
42 Views, 0 Favorites, 0 Comments
Using Dynamo to Brainstorm Revit Toposolids From Sketch
When I think of speed, I think of efficiency. Dynamo is a visual programming tool inside of Revit that can be used to automate tasks. Toposolids are a great Revit feature, but when trying to quickly run through design ideas, manually editing points can be time consuming. Dynamo scripts create efficiency when working on projects, and allow you to do really cool things, like turn a hand drawn heat map into a toposolid. I thought this would be a fun tool to code, as it would allow me to sketch out rough ideas of topographies when brainstorming design ideas. This project also seemed like it could be a great introductory set of instructions on using dynamo to automate a task!
Supplies
For this project you will need:
- Autodesk Revit 2024 or later
- Dynamo for Revit
To learn how to get free access to Autodesk products for students and educators check out the Autodesk website here: https://www.autodesk.com/education/home#students
- Computer
- Mouse
Planning, Pseudo Code, and Flowcharts
Before coding a program in Dynamo, I like to work through the steps the program needs to accomplish. Planning out a general idea of how the program will work helps me code more efficiently. When I do not plan out my code in advance, I can sometimes get a little bit lost in the middle of the program.
The first thing I do is determine the specific task I want to accomplish. In this case, that task is “Create a Toposolid with Elevations based on the Shading of an Image”
Then, I think through the steps I would have to manually do to complete this task, and write them out. Pseudocode is a term for a written out set of programming steps that is not written in a “real” programming language. It is often a mix of written out words and programming concepts. Pseudocode is a good way to plan out the basic steps needed for a program. The pseudocode I wrote for this program is:
- set a minimum height for the toposolid (MinimumToposolidHeight);
- set a maximum height for the toposolid(MaximumToposolidHeight);
- set a length for the toposolid (xDimension);
- set a width for the toposolid (yDimension);
- set a number of sub-element points for the toposolid (determines the detail level) (numPoints);
- set the toposolid level;
- select the toposolid type;
- import an image;
- spilt the image into sections;
- find the brightness of each image section;
- convert each brightness level to a number between the MinimumToposolidHeight and the MaximumToposolidHeight;
- Organize the brightness height levels into a list;
- Use 0, xDimension, and numPoints to find the location of numPoints number of points from 0 to xDimension;
- Use 0, yDimension, and numPoints to find the location of numPoints number of points from 0 to yDimension;
- Organize the coordinates into a lists;
- Create a point at each coordinate with the corresponding brightness height level;
- Create a toposolid from the points, the toposlid type, and the toposolid level;
Another way to visualize how code will run is a flow chart. Dynamo is a visual programming language. AEC visual programming languages like Dynamo and Grasshopper function very similarly to a flowchart, with data able to split into multiple branches traveling through them in one direction. This is demonstrated in the above image.
Set Up
Dynamo can be opened from the Manage tab in Revit. Create a new workspace. Make sure Run is set to Manual. Running a program on Automatic can cause Dynamo and Revit to crash. Make sure to regularly save both your Dynamo and Revit files.
Inputs
The communication between a program and its surroundings are made up of inputs and outputs. Inputs are the information the program receives; outputs are the information the program sends out to its surroundings. Below, I have labeled each input Node with its purpose. The name of each node is in the (parenthesis). If you ever need more information on a node, right click on it and select Help. This will open the Dynamo documentation.
Max Elevation in Feet (Code Block)
- This code block represents the maximum height of the toposolid relative to the toposolid's base level.
X Dimension in Feet (Number Slider)
- X Dimension defines how wide the final toposolid will be.
- Number Sliders allow you to input a range of numbers. I set this slider to have a range from 40 to 200 with a step of 1.
Y Dimension in Feet (Number Slider)
- Y Dimension defines how tall the final toposolid will be.
- I set this slider to have a range from 40 to 200 with a step of 1.
# of Rows & Columns (Integer Slider)
- This node specifies the number of rows and columns there will be in the final grid of toposolid points.
- A higher number of rows and columns will produce a more detailed toposolid, but can also lead to a higher chance of errors and a slower run time.
- Integer Sliders allow you to input a range of integers. I set this slider to have a range from 2 to 20 with a step of 1.
Photo File Location (File Path)
- This node allows you to select an image file to import.
Levels
- Levels allows you to select one of the levels in your project from a list. This will become the toposolid’s level.
ToposolidType.ByName
- Input: Code Block with the name of the toposolid type
- This node assigns a toposolid type
Importing the Image
The File Path node locates our image file, but does not import it. A few more nodes are needed to import the image.
Create File Object (File From Path)
- Input: Photo File Location (File Path)
- File From Path creates a file location from the inputted file location
Image.ReadFromFile
- Input: Create File Object (File From Path)
- Image.ReadFromFile reads the information about your image
Watch Image
- Input: Image.ReadFromFile
- Watch Image creates a preview of our image that we, the user, can see. The graph could run without this node, but it makes the program a lot easier to understand as a human user!
Brightness Level
The brightness level section of the graph determines the brightness level of the pixels in the image, and assigns them to heights within our set range.
Image.Pixels
- Input Image: Watch Image
- Input xSamples: # of Rows & Columns (Integer Slider)
- Input ySamples: # of Rows & Columns (Integer Slider)
- Image.Pixels outputs information about pixels located at specific locations. xSamples and ySamples are the number of x and y locations.
Color.Brightness
- Input: Image.Pixels
- Color.Brightness finds and outputs the brightness value of an input color on a scale from 0 to 1.
List.Flatten
- Input List: Color.Brightness
- List.Flatten takes a multi-dimensional or nested list and converts it into a single, one dimensional list
Math.MapTo
- Input rangeMin: 0
- rangeMin represents the smallest brightness value produced by Color.Brightness
- Input rangeMax: 1
- rangeMax represents the largest brightness value produced by Color.Brightness
- Input inputValue: List.Flatten
- Input targetRangeMin: 0
- targetRangeMin represents the lowest elevation of the toposolid with respect to the toposolid level, 0
- Input targetRangeMax: Max Elevation in Feet(Code Block)
- targetRangeMax represents the highest elevation of the toposolid with respect to the toposolid level
- Math.MapTo converts the numbers in the input list from a scale of rangeMin to rangeMax to a scale of targetRangeMin to targetRangeMax
Math.Round
- Input Number: Math.MapTo
- Input Digits: 1
- Math.Round rounds the imputed numbers to a set number of digits
X and Y Coordinates
In order to assign the height values to specific x and y coordinates, the x and y coordinates need to be created.
Code Block
- Input endX: Y Dimension in Feet (Number Slider)
- The x and y dimension for the image and the toposolid are reversed, so we need to swap their x and y values
- Input numSteps X: # of Rows & Columns (Integer Slider)
- Input endY: X Dimension in Feet (Number Slider)
- Input numSteps Y: # of Rows & Columns (Integer Slider)
- Equations:
- 0;
- endX;
- endX/(numStepsX-1);
- endY;
- endY/(numStepsY-1);
X Range (Range)
- Input Start: 0;
- Input End: endX;
- Input Step: endX/(numStepsX-1);
- Range creates a series of numbers in the given range.
Y Range (Range)
- Input Start: 0;
- Input End: endY;
- Input Step: endY/(numStepsY-1);
- Range creates a series of numbers in the given range.
Point.ByCoordinates:
- Input x: X Range
- Input y: Y Range
- Point.ByCoordinates creates a point at the specified coordinates
Point.X:
- Input: Point.ByCoordinates
- Point.X finds the x coordinate of a point
Point.Y:
- Input: Point.ByCoordinates
- Point.Y finds the y coordinate of a point
List.Flatten
- Input list: Point.X
List.Flatten
- Input list: Point.Y
3D Coordinates and Creating the Toposolid
We can now combine the sections to make a toposolid in Revit!
Point.ByCoordinates
- Input x: List.Flatten of x coordinates
- Input y: List.Flatten of y coordinates
- Input z: Math.Round
Toposolid.ByPointsTypeAndLevel
- Input points: Point.ByCoordinates
- Input toposolidType: ToposolidType.ByName
- Input level: Levels
Toposolid.ByPointsTypeAndLevel is the program's output.
Using the Graph
To use this Dynamo Graph:
- Make sure the Graph is set to Run manually not automatically
- Adjust the input nodes to fit your needs.
- Select the file location of your photo
- Run the graph using the run button
I recommend running the graph with this test image first to dial in the X dimension, Y dimension, and Rows & Column sliders. All of the above toposolids were made using the test image.
Using too low a number of rows and colums can cuase some features of an toposolid to lack some features shown in an image. Using too high of a number of rows and collumsn can cuase unintended zig zag patterns to apear. 17 rows and 17 collumns works well for toposolids with x and y dimensions between 150 and 200 ft made from digital sketches. For hand drawn sketches, 10 rows and columns works better.
Examples
The program works on hand drawn sketches, gradients, and digital sketches! Of the 3, gradients create the smoothest final toposolids.
Next Steps
Your newly created toposolids can be easily integrated into projects, and be used to quickly compare design ideas.
I hope this Instructable has provided you with a new fun, fast way to prototype toposolids!
For more information on Dynamo, check out the Dynamo Primer: https://primer.dynamobim.org/