I want get in my room the lights

hello

actually my code workes but i get weard results…

#Template 
#DraxlA
#19.07.2023
import clr
import sys 

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

clr.AddReference('RevitAPIUI')
from Autodesk.Revit.UI import *

clr.AddReference('System')
from System.Collections.Generic import List

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

clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

doc = DocumentManager.Instance.CurrentDBDocument
uidoc=DocumentManager.Instance.CurrentUIApplication.ActiveUIDocument


def convert_f_to_m(value):
	return DB.UnitUtils.Convert(value,UnitTypeId.Feet,UnitTypeId.Meters)

def convert_m_to_f(value):
	return DB.UnitUtils.Convert(value,UnitTypeId.Meters,UnitTypeId.Feet)


DynamoPoints = IN[0]

points = []

for i in DynamoPoints:
	p = DB.XYZ(convert_f_to_m(i.X),convert_f_to_m(i.Y),convert_f_to_m(i.Z))
	points.append(p)
	

output = []

for i in points:
    if doc.GetRoomAtPoint(i) == None:
        output.append("No Room")
    else:
        output.append(doc.GetRoomAtPoint(i))

#for i in output:
    #output.append(i.Id)
    
OUT = output

in some room there are 100 lights that can`t be it should be les …

i have 1000 rooms and 600 lights.
PySetCountLights.dyn (29.8 KB)

Hi,

can you share a sample model to test?
Is the height of the rooms well delimited by the ceiling?
Check with all phases

FYI , you can use toXyz() method extension to convert DynamoPoint to DB.XYZ

1 Like

@c.poupin

its to big… but i can make a demo later… i leave ofice, i have deadline next week, what a hell

1 Like

Have you checked your rooms aren’t overflowing into areas they don’t belong in? Maybe you need some room separation lines?

Have you checked someone hasn’t accidentally duplicated groups with lots of lights in and placed several groups in 1 place?

1 Like

@Alien

i am in a design freeze i can`t touch anything anymore…

You’re not changing the design, you’d be fixing the model.

You know if a wall join isn’t right and the room flows into another room… That you can fix.

And if someone has put 3 identical groups in the same place… That you can also fix.

1 Like

@Alien

i can`t change areas, do you have an example

… i think it is more about coordinates and the real point!

I’d just shut Revit… So you owe me a pint :wink:

I’m wondering if you have gaps (like a bit of wall missing in the green circle) that allows your rooms to go into areas where they should not be…

The Room 1277 should have the blue outline… but it’s got the red one instead.

I mean, I doubt it’d account for 100 lights but you never know. :person_shrugging:

Also check the Revit warnings - see if you’ve got duplicates.

1 Like

@Alien the duplicates are the rooms and that is fine

it means i have 5 lights in a room! 10 lights a.s.o.

@c.poupin

in general it goes to concrete… so it should be fine

It seems like you’re just assigning room names to fixture locations at that point. Where are you getting the points from? That seems to be your issue.

@Nick_Boyts

from the linked Outlets and lights

Can you show the code and results for that then?

@Nick_Boyts @c.poupin

E_.rvt (748 KB)
AR_.rvt (440 KB)

thats the result form the orginal file

at least there should be more rooms not only 24, around 700

Sharing a screenshot of your code would have been way faster and easier to troubleshoot but it looks like you’re collecting the LightingDevices instead of the LightingFixtures. Is that your issue?

1 Like


@Nick_Boyts

thats are the 2 codeblocks

the script by the way is uploaded…

@Nick_Boyts

both

and electrical equipment

But you’re claiming the issue is that you’re not returning as many lights as you’re expecting. Those nodes all deal with the points (light fixture locations) after they’ve already been determined. If the issue is missing fixtures then you should be looking at how you’re collecting those points.

The first node in your graph is the python node getting the elements (points) from the linked document. It sounds like you want light fixtures, but in your FilteredElementCollector you’re collecting the LightingDevices instead of the LightingFixtures.

You only have 3 FECs. If you want LightingDevices, ElectricalEquipment, and LightingFixtures then you need collectors for all 3.

1 Like

@Nick_Boyts

@Nick_Boyts

but look the numbers are creazy… it looks like in any room is a crismas party