Creating Lighting Fixtures from a DWG File

Hello everyone. I am working on a Dynamo project for Revit 2027 that involves automatically placing lighting fixtures from a DWG file.

I have linked the DWG into Revit and used Dynamo to extract the points where the lighting fixtures should be placed. As a temporary measure, I have applied a Z offset to move the points up to the ceiling level. However, the lighting fixtures are still being placed on the floor and oriented upward, as if they were illuminating the ceiling.

I have tried the Family Instances by Face and Family Instances by Host and Point nodes, but I have not been able to solve the problem.

I would appreciate any help or suggestions. Thank you!

It depends whether the family is ceiling, wall or face hosted.
It’s usually best practice (opinions will differ) to host the family onto the element that it is physically attached to i.e normally ceiling

It sounds like your family is face-hosted. Many families will have a ‘flip’ parameter

Best to post your Dynamo graph and the family

I agree with @Andrew_Hannell

To add; What i sometimes do is make a non-hosted light and just give it an offset from the floor.

PS
Question for all the Dynamo guru’s here.
Is it possible to check what is right above a point?
Because there isn’t allways a ceiling.
i.e;

  • Celing
  • Beam
  • Exposed ceiling (so the bottom of a Floor)

Not want to hijack OPs topic, but i think the question is also helpful for OP. :innocent:

Raybounce nodes will return the projected point and the element it hits.

Use rayboune
you can find previous posts considering the same topic

Thank you for your suggestions. Unfortunately, the forum does not allow me to upload the .dyn file, so I will share a screenshot of the final part of my Dynamo graph instead.

As you can see, the points are correctly positioned at the ceiling level, but the lighting fixtures are still being placed on the floor and facing upward.

I would appreciate any suggestions on how to fix this.

What kinda Family is it?

here a solution with Python to get directly the Face Reference (ReferenceIntersector)

import clr
import sys
import System

clr.AddReference("RevitAPI")
import Autodesk
from Autodesk.Revit.DB import *
import Autodesk.Revit.DB as DB

clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *

clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
from System.Collections.Generic import *
doc = DocumentManager.Instance.CurrentDBDocument

clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.GeometryConversion)

def decoTransactions(func):
    def wrapper(*args, **kwargs):
        TransactionManager.Instance.EnsureInTransaction(doc)
        returnfun = func(*args, **kwargs)
        TransactionManager.Instance.TransactionTaskDone()
        return returnfun
    return wrapper
    
    
@decoTransactions
def new_instance_byface(dyn_pt, ref1, ftype):
    inst1 = None
    try:
        if not ftype.IsActive :
            ftype.Activate()
        #
        dir1 = XYZ(1,0,0)
        inst1 = doc.Create.NewFamilyInstance(ref1, dyn_pt.ToXyz(), dir1, ftype)
    except Exception as ex: 
        print(traceback.format_exc())        
    TransactionManager.Instance.TransactionTaskDone()
    return inst1
    
def getclosestfaceCeilling3(ds_pt): 
    global riCeiling
    global riFloor
    #
    point = ds_pt.ToXyz() - XYZ(0, 0, 3.28084) # move down to allow process ray
    vectorDirection = XYZ(0, 0, 1)
    referenceWithContext_C = riCeiling.FindNearest(point, vectorDirection) 
    referenceWithContext_F = riFloor.FindNearest(point, vectorDirection) 
    #
    result_clashs = [] 
    #
    for refContext in [referenceWithContext_C, referenceWithContext_F]:
        if refContext is not None:
            ref = refContext.GetReference()
            prjPoint = ref.GlobalPoint  
            result_clashs.append([prjPoint.ToPoint(), ref, point.DistanceTo(prjPoint)])
                    
    result_clashs.sort(key = lambda x : x[2]) 
    if len(result_clashs) > 0: 
        if referenceWithContext_C is not None:
            referenceWithContext_C.Dispose()
        if     referenceWithContext_F is not None:
            referenceWithContext_F.Dispose()    
        return result_clashs[0]
    else:
        return [None, None, None]
    
    
@decoTransactions
def create3D_ViewContext(): 
    global threeDview
    global riCeiling
    global riFloor
    # create 3D view for Raybounce
    viewFamilyType = FilteredElementCollector(doc).OfClass(ViewFamilyType)\
            .FirstOrDefault(System.Func[DB.Element, System.Boolean](lambda x : x.ViewFamily == ViewFamily.ThreeDimensional))
    fecMepSpaces = FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_MEPSpaces).ToElements()
    threeDview = View3D.CreateIsometric(doc, viewFamilyType.Id)
    #
    filterCeil = ElementCategoryFilter(BuiltInCategory.OST_Ceilings)
    riCeiling = ReferenceIntersector(filterCeil, FindReferenceTarget.All, threeDview)
    riCeiling.FindReferencesInRevitLinks = True
    #
    filterFloor = ElementCategoryFilter(BuiltInCategory.OST_Floors)
    riFloor = ReferenceIntersector(filterFloor, FindReferenceTarget.All, threeDview)
    riFloor.FindReferencesInRevitLinks = True    
    
@decoTransactions
def clear3D_ViewContext():
    global threeDview
    if threeDview is not None:
        doc.Delete(threeDview.Id)
        
toList = lambda x : x if hasattr(x, "__iter__") and not isinstance(x, (str, System.String)) else [x]
padded = lambda l, max_len: l + [l[-1]] * (max_len - len(l)) if l else []

        
threeDview = None 
riCeiling = None 
riFloor = None 
vectorDirection = XYZ(0, 0, 1)
out = []

lst_dyn_pts = toList(IN[0])
lst_ftype = padded(toList(UnwrapElement(IN[1])), len(lst_dyn_pts) )

create3D_ViewContext()

for dyn_pt, ftype in zip(lst_dyn_pts, lst_ftype):
    newpt, closest_ref, distace = getclosestfaceCeilling3(dyn_pt)
    if newpt is not None:
        newinstance = new_instance_byface(newpt, closest_ref, ftype)
        out.append(newinstance)
        
clear3D_ViewContext()

OUT = out