Documente Academic
Documente Profesional
Documente Cultură
This example will take you through the process of pulling Room data out of Revit via Dynamo, pushing
that data into Excel, making changes in Excel, then pulling the changes from Excel back into Revit.
The goal here is to pull Room Data from Revit and push it into Excel. So first, place a “Categories” node
that selects “Rooms” and attach it to an “All Elements of Category” node. This will pull all room
elements into Dynamo. If you want to see the 3d Representations of the Rooms, wire in an
“Element.Geometry” node and click “Run”.
Now place a “File Path” node and click Browse. Go to the location where you want to have your Excel
File created. Type in the name of the file you wish to create then click “Open”.
Now place 5 “Element.GetParameterValueByName” nodes along with 5 code blocks for “Name”,
“Number”, “Area”, ”Room Type”, “OccPerSF”. Wire the “All Elements of Category” node into the
element input and wire the Code Blocks into the parameterName input.
Connect the Python Output into another “Element.GetParameterValueByName” node along with a Code
Block with the string “Name”.
Now Click “Run” and the Excel File of your Data should open up. Be sure to save it before closing
Dynamo.
In the same Excel file as was just created, create another sheet named “TypRooms”. In this enter the
RoomTypes and Occupants Per SqFt for each type. (Forgive me if this is all wrong and completely un-
realistic – I’m an engineer and very ignorant when it comes to what architects would/might need to do
with a Room – just focus on the concept and capability).
Once that is done, copy the correct value into the “Room Type” column of the “Rooms” Sheet.
From a Watch Node, you can see that the first index of each list is simply the column headers and thus
needs to be thrown away. First split the list into two separate lists (one for each Excel Sheet) using a
Code Block with x[0] and x[1], then feed the data from each into a “List.RestOfItems” node.
Now that we have the Excel Data back into Dynamo and well-arranged, we need to gather the Room
elements and their data from Revit (similar to part 1). As shown below, the Room Elements, Room
Names, and Room Numbers are gathered.
Before we can do this, we must correct a nasty bit of business that Excel has done. Note that the Room
Numbers that are coming from Revit are strings (text), but Excel recognized all of the Room Numbers we
previously gave it as actual numbers, and thus has “reclassified” them as doubles (numbers). There are
a number of ways to correct this, but the Python script below will do what we want – which is to convert
the number 100.000000 to the string 100. Create a Python Script node and write a script as shown
below. Feed the “RoomNumbers” data list from Excel into this Python Script node.
Now feed the resulting list of index numbers into the list input of a List.Map. Into the function input,
feed a “List.GetItemAtIndex” with the Excel Room Type data feeding into the list input (the index input is
left blank as that is the list that the List.Map is operating with).
Now we need to get the “Occupants per SF” from the “TypRooms” Excel Sheet using the sorted list of
“RoomTypes”. To do this, we will feed the list of RoomTypes through another copy of the “index of
matches” Python Script and then use those indexes to generate a list of “OccPerSF” values from the
TypRooms Excel data.
Below is a solution to take the raw occupants data and ensure that it rounds up to the nearest integer.
Within the Transaction, use “Element.SetParameterByName” nodes to set the “Room Type” and “Room
Occupant Load” parameters within Revit. Feed the Element outputs into a “List.Create” node and then
feed that into a “Transaction.End” to close out the process.
If you have any questions while working through this later, feel
free to email me any questions at bosborne@sdlal.com.
Good Luck
-Ben Osborne