I want get in my room the lights

That wasn’t in the initial script I downloaded. You still haven’t shared a screenshot of your whole graph. How many points do you get from those categories? Where do they go? This is why we ask for your version of the data via a screenshot rather than having to recreate everything with a test set. Sometimes things can get lost.

1 Like

I’m confused. I thought your initial post was about missing fixtures? Now you’re saying there are too many? What is the exact issue you are having?

1 Like

@Nick_Boyts


PySetCountLights_V1.dyn (35.2 KB)

i have 1000 rooms so actually 800 should have elements…

result can`t be less than 100 rooms

And what does a schedule look like? If you schedule the lights and group them by Room do you get the numbers you’re expecting? If not, then the issue is with your model, not your graph.

1 Like


or should i go for the geometry ? instead so skipping the whole concept ?

And how many unique rooms do you have with fixtures? The 800 you’re expecting or something else? Have you confirmed that all your elements are actually within the bounds of the rooms you’re looking for?

You haven’t really explained what you’re doing besides grouping elements by room by location. Why not use RoomCalculationPoint which is used for exactly this? The location point of many objects tends to be on the edge of a room/space. Anything hosted to a ceiling, floor, or wall could have issues with the “location” being outside the bounds.

Are the lights and rooms in the same model?

After you group the points by the rooms do they look like you would expect in the context of the Revit model? It can help to isolate one group of points at a time.

@Nick_Boyts

1000 rooms , minus shafts i would say 800 rooms.

@jacob.small

the light are linked , the rooms in current document …

weard is these points seems to be anywhere, not located on the linked element.

so i thought it is a issue with units, but now i don`t know

I’m saying schedule the light fixtures by room. Then see if you have lights in ~800 rooms like you expect. Right now we’re going off all these assumptions. You should be checking to see if the total number of lights matches. Then we can move on to why they aren’t getting grouped properly.

1 Like

It sounds as if you have a coordinate system issue.

Take one light where you know the coordinate and room. If they don’t match to what you think the values should be then we can confirm the coordinate system issue.

Even though GetRoomAtPoint() only requires a point argument, it always seems to fail this way. You instead need to include the overload phase argument to get the room at a given phase. You should also use ToXyz() to convert points, as mentioned by @c.poupin.

Something like this should work:

points = [p.ToXyz() for p in DynamoPoints]
output = []
phase = UnwrapElement(IN[1])

for i in points:
    room = doc.GetRoomAtPoint(i,phase)
    if room != None:
        output.append(room)
    else:
        output.append("No Room")
2 Likes

@Draxl_Andreas

Why not create spaces in the electrical model?

Generally, in MEP models, we create spaces that reflect the rooms in the Archi model, then all we need to do create a schedule.

2 Likes

A few comments…
You can use an ElementMulticategoryFilter like this

from System.Collections.Generic import List

cats = [BuiltInCategory.OST_LightingDevices,
    BuiltInCategory.OST_LightingFixtures,
    BuiltInCategory.OST_ElectricalEquipment]

emcf = ElementMulticategoryFilter(List[BuiltInCategory](cats))

light_elec = (
    FilteredElementCollector(doc)
    .WherePasses(emcf)
    .OfClass(FamilyInstance)
    .ToElements()
)

Working from the electrical doc with the room doc linked
Then process with a function, get the link with rooms, process and load into a dictionary.
The function works from least overhead to highest

def GetRoom(elem):
    if hasattr(elem, "Room") and elem.Room:
        return elem.Room
    if hasattr(elem, "Location"):
        pt = elem.Location.Point
        try:
            return room_doc.GetRoomAtPoint(pt, room_phase)
        except:
            for room in rooms:
                if room.IsPointInRoom(pt):
                    return room

links = FilteredElementCollector(doc).OfClass(RevitLinkInstance).ToElements()
room_doc = [l.GetLinkDocument() for l in links if "Archi" in l.Name][0]
rooms = FilteredElementCollector(room_doc).OfCategory(BuiltInCategory.OST_Rooms).ToElements()
room_phase = list(room_doc.Phases)[-1]

room_items = dict()
for rm, item in zip(map(GetRoom, light_elec), light_elec):
    if rm:
        room_items.setdefault(" ".join([str(rm.Id.Value), rm.get_Name()]), []).append(item)

OUT = room_items

image

1 Like

@Alien @Mike.Buttery @c.poupin @jacob.small @Nick_Boyts

Thank you everybody! I filled my schedules. I saved a lot of time and monkey work.

2 Likes