Module 1

[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.

one number

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.

Number_2 01 01

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.

Number_3 01 01 01

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.

Number_4 01 01 01 01

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.

Number_5-01

Firstly, the relevant libraries are imported for use in the Python script.

Number_6-01

Importing the DocumentManager allows us to access the current document and set it to the variable doc.

Number_7-01

The incoming points from Geometry.Translate in Point 2 are unwrapped here which allows us to use the points with the Revit API. More information about unwrapping elements can be found here.

Number_8-01

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.

Number_9 01

If the toggle is set to False, this last part of code will run which basically outputs the string “Set toggle to TRUE.

Image02_ProjectView

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.

 

Image05_Schedule_coloured2
dynamo file

Download

*Built for Dynamo Version 0.9.1

Newsletter

  

10 Comments

  1. Dmitry Dronov
    May 5, 2016 @ 3:41 pm

    Centroid is not good decision
    http://joxi.ru/V2VaEagS0XlMkm

    Reply

  2. jeremygraham
    May 7, 2016 @ 5:17 am

    Hey Dmitry.

    I would have agree that in your particular case, it would not be ideal. However, in most conventional ceiling construction it should work quite well.

    Reply

  3. Antony McPhee
    May 8, 2016 @ 1:06 am

    Nicely explained, but why is a toggle as input required at step 8?
    If it is always required why not build it in?

    And what does “node sometimes has a hard time updating” mean? Why does it happen?

    If it is a quirk of Dynamo it would be handy to know.

    Reply

  4. Jeremy
    May 9, 2016 @ 5:56 am

    G’day Antony!

    This is a quirk with Dynamo although I have checked it is still the case in 1.0.

    Basically, Dynamo doesn’t always refresh after its initial run unless you make changes to the script. The toggle lets you refresh the script manually.

    Reply

  5. Tom
    May 18, 2016 @ 4:50 pm

    When I use ceilings as the category, I get an error for the Solid.Centroid node.

    Warning: Internal error, please report: Referencing a non-pointer. (3f47aacd)

    But if I create a room and change the category to Rooms, it works.

    I’m using v1.0.0.1180

    Reply

  6. Jeremy
    May 20, 2016 @ 6:09 am

    Hi Tom,

    That’s very odd.. I built the script using 0.9.1 so that might be the cause of the problem as there were huge changes to the Dynamo API from 0.9.1 to 1.0.

    I plan on redoing this script in the next couple weeks for Dynamo 1.0 and a couple upgrades so hopefully that will fix it for you.

    cheers

    Reply

  7. Felicity
    July 12, 2016 @ 12:48 pm

    You are amazing Jeremy

    Reply

  8. Yien
    November 6, 2016 @ 4:08 am

    Jeremy,

    i tried with Dynamo 1.2 and it doesn’t work.
    please take a look.

    https://drive.google.com/a/msdl.ca/file/d/0BxTXmoEnYjnNQmhCVzRSMVJENlE/view?usp=sharing

    thank you

    Reply

  9. Ariel
    December 5, 2017 @ 10:11 pm

    hello jeremy, first I apologize for my english, it’s not my language, but I hope you can take the idea.
    by the way, thanks for the tutorials, they are really good.

    Well, the reason I’m writing to you is that when I “execute” the script, the python node returns an error like this:

    Warning: IronPythonEvaluator.EvaluateIronPythonScript operation failed.
    Traceback (most recent call last):
    File “”, line 25, in
    AttributeError: ‘NoneType’ object has no attribute ‘Number’

    the line 25 is:

    25. lst.append(room.Number)

    … and I have no idea why this is happening, I would appreciate any explanation

    Reply

    • Jeremy
      December 6, 2017 @ 10:42 am

      Hi Ariel,

      Your English is good, easily understood 🙂

      With your problem, it is likely happening because on line 24, the method “GetRoomAtPoint” is not finding any room. Is the point you are checking definitely within a room volume?

      If you want to send me your revit file I am happy to check why it is happening. What version of Revit and Dynamo are you using?

      Reply

Leave a Reply

Your email address will not be published. Required fields are marked *