Room: Name access from dynamo

Hello everyone, how can I get access to te “Room: Name” parameter in dynamo. The parameter I am talking is the one of the image

Thanks a lot!

@Rick check this:

1 Like

Didn’t work, for some reason I can’t get the room from plumbing fixtures and others familys

Do you have phasing in your project?

Are the rooms and fixtures in the same phase?

Is there a phase after whatever phase they are on?

1 Like

OHH, yes, i have phases!
They are not in the same phase

But why Revit can get the Room Name, and dynamo can’t?

Dynamo definitely can.

2 Likes

if you share one sample file then I can try.

1 Like

Yes. Dynamo can do it. Rhythm for example is hard coded to get the room in the same phase of the family instance. Code here. I believe that stands true for the OOTB node as well.

For your workflow, you will need a node that allows you to input a phase to “search” in. Let me see if I can add that to Rhythm.

But if you are comfortable copying and pasting a python script. This one should do it:

# import common language runtime 
import clr

# Import RevitAPI
clr.AddReference("RevitAPI")
# import all classes from Revit DB
from Autodesk.Revit.DB import *

# import Revit dynamo libraries
clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)
clr.ImportExtensions(Revit.GeometryConversion)

# custom definition for getting room that works with single items or lists
def GetRoomInPhase(item,phase):
	return item.Room[phase]

# the family instances
items = UnwrapElement(IN[0])
phase = UnwrapElement(IN[1])

# return the results
if isinstance(IN[0], list): OUT = [GetRoomInPhase(x,phase) for x in items]
else: OUT = GetRoomInPhase(items,phase)

SampleDyn:
FamilyInstanceGetRoomInPhase.dyn (11.1 KB)

3 Likes

Yes, of course
Here: look at the two plumbing fixture, image it is a renovation
Project1.rvt (2.1 MB)
Home.dyn (5.3 KB)

Look the schedule, I can get the room name


But in dynamo not
image

Ok, now i get it!
I have elements demolished in “phase 2”, but all my rooms are in the phase 2, I’d like to get my elements in phase 1, and know in which room from phase 2 are they.
Revit can do this in schedules, but i can’t figure out how to do this in dynamo

hmm, there are other ways so let me take a look on my end.

1 Like

Here we go. This one works off of point locations. This is nice because you can move the points around in Dynamo if you know that your element location is a bit off.

FamilyInstanceGetRoomInPhaseAtPoint.dyn (12.8 KB)

and the python:

# import common language runtime 
import clr

# Import RevitAPI
clr.AddReference("RevitAPI")
# import all classes from Revit DB
from Autodesk.Revit.DB import *

# import Revit dynamo libraries
clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)
clr.ImportExtensions(Revit.GeometryConversion)

clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
doc = DocumentManager.Instance.CurrentDBDocument

# custom definition for getting room that works with single items or lists
def GetRoomInPhaseAtPoint(point,phase):
	try:
	    return doc.GetRoomAtPoint(point.ToRevitType(True),phase)
	except:
		return None

# the family instances
locations = UnwrapElement(IN[0])
phase = UnwrapElement(IN[1])

# return the results
if isinstance(IN[0], list): OUT = [GetRoomInPhaseAtPoint(x,phase) for x in locations]
else: OUT = GetRoomInPhase(locations,phase)
5 Likes

Thanks!