Room to-elements not working

hello Pros,

i need to get the linked elements (such as the lighting fixtures) inside a certain room, the room and lighting fixture are from different linkes (not similar to attached script).

however, “room toelements” node from Genius Loci give “null” when a linked revit instance is added!

am i using it wrong or it does not give what i want or it has an error in its script?
room toelements node not working.dyn (10.0 KB)

Hi @sahawneh_majdi

Could you show us your complete graph with all the errors and previews expanded.

there you go,

“Warning: IronPythonEvaluator.EvaluateIronPythonScript operation failed.
Traceback (most recent call last):
File “”, line 26, in
NameError: name ‘doc’ is not defined”

Could you copy/paste Python code here or share the screenshot of code.

#Alban de Chasteigner 2021
#twitter : @geniusloci_bim
#geniusloci.bim@gmail.com
#GitHub - albandechasteigner/GeniusLociForDynamo: Genius Loci is a package of 350+ custom nodes for Dynamo in Revit.

import clr
clr.AddReference(‘RevitAPI’)
import Autodesk
from Autodesk.Revit.DB import *
clr.AddReference(“RevitServices”)
import RevitServices
from RevitServices.Persistence import DocumentManager

rooms = UnwrapElement(IN[0]) if isinstance(IN[0],list) else [UnwrapElement(IN[0])]
inputdoc = UnwrapElement(IN[1])
result=

if inputdoc is None:
doc = DocumentManager.Instance.CurrentDBDocument
transform = Transform.Identity
elif isinstance (inputdoc, RevitLinkInstance):
doc = inputdoc.GetLinkDocument()
transform = inputdoc.GetTotalTransform()
for room in rooms:
elem=
fec = FilteredElementCollector(doc).WhereElementIsNotElementType().WhereElementIsViewIndependent().ToElements().FindAll(lambda x : type(x.Location) == LocationPoint and x.Category.Id != ElementId(BuiltInCategory.OST_Rooms) or type(x.Location) == LocationCurve or isinstance(x, CeilingAndFloor) or isinstance(x,RoofBase))
for e in fec:
loc = e.Location
if type(loc) == LocationPoint:
pt=loc.Point
elif type(loc) == LocationCurve:
pt=loc.Curve.Evaluate(0.5, False)
# sketch-based elements (ceiling, floor and roof)
elif isinstance(e, CeilingAndFloor) or isinstance(e,RoofBase) :
for ref in HostObjectUtils.GetTopFaces(e):
geomFace=e.GetGeometryObjectFromReference(ref)
#Get UV BoundingBox
bbox = geomFace.GetBoundingBox()
uv=(bbox.Min+bbox.Max)/2
pt=geomFace.Evaluate(uv)
locationPoint = transform.OfPoint(pt)
if room.IsPointInRoom(locationPoint):
elem.append(e)
result.append(elem)

if isinstance(IN[0], list): OUT = result
else: OUT = result[0]

Are you using the latest version?

yes Sir, I am.

And which build of Revit?

it is the revit 2022.0.2,
however, yesterday i’ve tried it on 2022.1.5 and didn’t work either :frowning:

Cnan you try using the genius loci package instead and ensure you have ironpython installed.

Hi @sahawneh_majdi try set your lacing to longest…

1 Like

Hello @sovitek it actually Worked :slight_smile:
Appreciated :slight_smile: