Does anyone know any alternative package for this Genius Loci node? or a working code in revit 2025?
Hi @rajeshjamariya16 try set the node to cpython 3, guess it will work then
import clr
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.GeometryConversion)
clr.AddReference('RevitServices')
from RevitServices.Persistence import DocumentManager
doc = DocumentManager.Instance.CurrentDBDocument
import System
from Autodesk.Revit.DB import ElementId
def unwrap_and_flatten(obj):
if hasattr(obj, "__iter__") and not isinstance(obj, Element):
flat = []
for sub in obj:
flat.extend(unwrap_and_flatten(sub))
return flat
else:
return [UnwrapElement(obj)]
# Get a clean flat Python list of unwrapped Revit elements
items = unwrap_and_flatten(IN[0])
location_points = []
ref_array = ReferenceArray()
for item in items:
if item is None:
ref_array.Append(None)
location_points.append(None)
continue
# Use the global doc
current_doc = doc
if isinstance(item, FamilyInstance):
# Build stable representation for the face of the family instance
stable_ref_str = "{0}:0:INSTANCE:{1}:1:SURFACE".format(
item.UniqueId,
item.Symbol.UniqueId
)
ref = Reference.ParseFromStableRepresentation(current_doc, stable_ref_str)
ref_array.Append(ref)
loc = item.Location
if isinstance(loc, LocationPoint):
location_points.append(loc.Point.ToPoint()) # Dynamo Point
elif isinstance(loc, LocationCurve):
# optionally take start or midpoint
curve = loc.Curve
location_points.append(curve.Evaluate(0.5, True).ToPoint())
else:
location_points.append(None)
else:
ref_array.Append(None)
location_points.append(None)
if isinstance(IN[0], list) or hasattr(IN[0], "__iter__"):
OUT = ref_array, location_points
else:
OUT = ref_array[0] if ref_array.Size > 0 else None, location_points[0] if location_points else None
Managed to create an alternative code in the process!

