import clr
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
from Autodesk.Revit.DB.Structure import *
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
Elements = UnwrapElement(IN[0])
OUT = []
for i in Elements:
OUT.append(i.Room)
i want to count my poweroutlets i have different ones… and also other stuff, i have to address them to my rooms!
We can’t see what you’re supplying the python node but I think LinkElement is a custom class, not a Revit one, so those objects won’t work with the API.
Yes. Now I think you have to use the Room (Phase) property since these are linked elements. Otherwise it’s probably looking the last phase in the active document.
An element has to have access to a room in order for Revit to know it’s located there. In the active model, that can either be in the same document or a linked one (as long as the rooms are loaded). In a linked document, the elements won’t check the active model for rooms.
In this case, you have to go by geometry/location - something like @newshunhk has suggested.
ok until phase reverse it runs well… but the last part does not work… i am not shure about collecting the rooms…
import clr
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
from Autodesk.Revit.DB.Structure import *
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
outlets = UnwrapElement(IN[0])
#get the location of your outlet:
pt = []
output = []
for i in outlets:
pt.append(i.Location.Point)
#get phases
phases = [p for p in doc.Phases]
phases.reverse() # check last phase first
#check its room:
for p in phases:
room = doc.GetRoomAtPoint(pt, p)
if room:
output.append(p)
break
OUT = output
outlets = UnwrapElement(IN[0])
#get the location of your outlet:
pt = []
output = []
for i in outlets:
pt.append(i.Location.Point)
#get phases
phases = [p for p in doc.Phases]
phases.reverse() # check last phase first
#check its room:
for p in phases:
room = doc.GetRoomAtPoint(pt, p)
if room:
output.append(p)
break
OUT = output