[Find Ceiling Room by Point]
With this first module, and the rest of the upcoming ones, I’m assuming you have used Revit Dynamo and looking for practical applications for work and play. If you have not used Dynamo, I suggest heading over to www.dynamobim.org and checking out the Dynamo Primer. Or, you can give the example below a crack and let me know if you have any questions of which I will be happy to help you out.
This first module is about a little problem I recently ran in to while using Revit. It was the issue of associating ceilings with rooms. Basically, I wanted to create a schedule in Revit which included a parameter that indicated the room to which the ceiling was associated. In order to achieve this, I utilised Dynamo to basically find all ceilings in the project, create a point under those ceilings and find the room that point lies within.
Before I started the script, I added a parameter to all ceilings which is called “CEILING-ROOM’. This means I can later schedule which room each ceiling is used based on this parameter. The solution to this is shown below and each step explained.
The start of this script is quite simple. Firstly the node Categories allows us to select a category within Revit. We retrieve All Elements of Category which is self-explanatory. Next all of these elements are converted to Solids using Element.Solids and the center point of these solids are found with Solid.Centroid.
The second part of this script basically moves the points we retrieved using Solid.Centroid down in the ZAxis by 1000mm by using Geometry.Translate. This is to make sure the point is within the room area and not situated on the boundary.
Next the points are fed into a Python script which basically finds the room that a point is contained in. This is explained further through points 5 to 9.
Alternatively, you can download the node Get.RoomNumberByPoint which is found in the Juggernaught package, in the Package Manager.
The final node Element.SetParameterByName is used to update the parameter “CEILING-ROOM” in all ceilings, as collected in the All Elements of Category node. The output of the Python Script provides us with the parameter values for each ceiling which is the room number as shown in point 8. As the order of ceilings and room numbers input into the Element.SetParameterByName are the same, the correct room number should be associated with the correct ceiling element.
Firstly, the relevant libraries are imported for use in the Python script.
Importing the DocumentManager allows us to access the current document and set it to the variable doc.
This is where the meat of the script basically is. The toggle variable allows us to reset the script as the node sometimes has a hard time updating. If toggle is set to True, a for loop starts which checks each point for what room it is in using doc.GetRoomAtPoint(points) and then appends the points to the lst list. This list is then fed out to the Dynamo workspace.
If the toggle is set to False, this last part of code will run which basically outputs the string “Set toggle to TRUE“.
As you can see from the image above, the result of the Dynamo script can be seen above. The transparent yellow areas are the ceilings that we have gathered in the script and the blue dots are the points that we have created. These points are shown in two instances; 1 in line with the height of the ceiling and 1 translated 1000mm below the ceiling height. As stated earlier, this allows us to ensure the point is within the room.
The final result is the schedule on the right. This shows each ceiling with the preset parameter CEILING-ROOM which is populated by the corresponding room of which the ceiling is contained it.
Please feel free to comment below or contact me if you have any queries. The Dynamo file used for this can be downloaded below.