DocumentGetRoomAtPoint Python in Dynamo

DocumentGetRoomAtPoint Python in Dynamo

johan_germishuys
Contributor Contributor
693 Views
2 Replies
Message 1 of 3

DocumentGetRoomAtPoint Python in Dynamo

johan_germishuys
Contributor
Contributor

Hi,

 

I'm trying to identify around 80 000 points and find their associated room across around 50 models. I'm doing some testing, and I've realized I really need to do this in Python to avoid significant overhead. For that I'm not sure how to reference the GetRoomAtPoint function.

 

This is what I have so far.

 

johan_germishuys_0-1725488656464.png

 

Everything works up to the "GetRoomAtPoint". As you can see from the above, that I'm trying to go through all the LinkedModels contained inside the current Revit model.

 

Any suggestions or help would be greatly appreciated.

 

0 Likes
694 Views
2 Replies
Replies (2)
Message 2 of 3

johan_germishuys
Contributor
Contributor

Just to be clear, this is the error I'm receiving from the Python Node. When using a type for the class it's reading I'm getting Get Linked Documents: <class 'Revit.Elements.Room'>. I believe this should be cast as a Autodesk.Revit.DB.Architecture.Room but not sure.

 

johan_germishuys_0-1725504584543.png

 

0 Likes
Message 3 of 3

studio-a-int
Advocate
Advocate

Add below Python code in a Dynamo Python from script node:
# Collect all the rooms from you linked Revit document = yourRevitLinkedDocument
allRoomsInRevitLink = FilteredElementCollector(yourRevitLinkedDocument).WhereElementIsNotElementType().OfCategory(BuiltInCategory.OST_Rooms).ToElements()
# create a dictionary
dict = {}
# iterate through each room in your collection and verify if the point XYZ is in the room
# XYZ will have the actual values from your list of points not 0,0,0 as below
for ro in allRoomsInRevitLink:
dict.update({str(ro.get_Parameter(BuiltInParameter.ROOM_NAME).AsString()) : "Is inside room: " + str(ro.IsPointInRoom(Autodesk.Revit.DB.XYZ(0.000,0.000,0.000)))})
# output the dictionary w/ rooms names and boolean values
OUT = dict