Hello guys , thank you so much for your big effort and amazing script and also for your time to help the beginner in dynamo like me can i ask question please ,!!! i tried to use this script in dynamo 1.1.02094 revit 2016 and i got this error as shown in the photo below
Hi @de_tarek2
the information you provide is too partial … it’s hard to tell for sure.
From what I see it looks like the “out” output of filter.byboolmask is a function, which is probably not what you want.
Can you share a screenshot of the whole script and also show us the code inside the python script node ?
Thanks a lot for replay
I’m trying to renumber the doors with the same room number
and this the python
import clr
Import RevitAPI
clr.AddReference(“RevitAPI”)
import Autodesk
from Autodesk.Revit.DB import *
Import DocumentManager and TransactionManager
clr.AddReference(“RevitServices”)
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
Import ToDSType(bool) extension method
clr.AddReference(“RevitNodes”)
import Revit
clr.ImportExtensions(Revit.Elements)
Start Transaction
doc = DocumentManager.Instance.CurrentDBDocument
fam_inst = IN[0]
elements =
for i in IN[0]:
elements.append(UnwrapElement(i))
def TryGetToRoom(Room, phase):
try:
toRoom = Room.get_ToRoom(phase)
except:
toRoom = None
pass
return toRoom
def TryGetFromRoom(Room, phase):
try:
fromRoom = Room.get_FromRoom(phase)
except:
fromRoom = None
pass
return fromRoom
Room_Number, Room_Name, Doors, Room = , , ,
for i in elements:
for phase in doc.Phases:
if i.CreatedPhaseId == phase.Id:
for phase2 in doc.Phases:
if TryGetToRoom(i, phase2) != None:
to_Room = TryGetToRoom(i, phase2)
break
else:
to_Room = None
for phase3 in doc.Phases:
if TryGetFromRoom(i, phase3) != None:
from_Room = TryGetFromRoom(i, phase3)
break
else:
from_Room = None
if from_Room == None and to_Room == None:
Room_Number.append("No to or from Room")
Room_Name.append("No to or from Room")
Doors.append("No to or from Room")
elif to_Room != None:
Numbers = to_Room.GetParameters("Number")
Names = to_Room.GetParameters("Name")
for n in range(len(Numbers)):
Room_Number.append(Numbers[n].AsString())
Room_Name.append(Names[n].AsString())
Doors.append(i)
Room.append(to_Room)
#Assign your output to the OUT variable
OUT = Room_Number, Room_Name, Doors, Room
you can post the code with propper formatting like shown in this post: Making rebar solid (it’ll make it easier to collect and debug)
In the mean time, would something like this work for you? :
import clr
# Import RevitAPI
clr.AddReference("RevitAPI")
import Autodesk
from Autodesk.Revit.DB import *
# Import DocumentManager and TransactionManager
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
# Import ToDSType(bool) extension method
clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)
# Start Transaction
doc = DocumentManager.Instance.CurrentDBDocument
fam_inst = IN[0]
elements = []
for i in IN[0]:
elements.append(UnwrapElement(i))
def TryGetToRoom(Room, phase):
try:
toRoom = Room.get_ToRoom(phase)
except:
toRoom = None
pass
return toRoom
def TryGetFromRoom(Room, phase):
try:
fromRoom = Room.get_FromRoom(phase)
except:
fromRoom = None
pass
return fromRoom
Room_Number, Room_Name, Doors, Room = [], [], [], []
for i in elements:
for phase in doc.Phases:
if i.CreatedPhaseId == phase.Id:
for phase2 in doc.Phases:
if TryGetToRoom(i, phase2) != None:
to_Room = TryGetToRoom(i, phase2)
break
else:
to_Room = None
for phase3 in doc.Phases:
if TryGetFromRoom(i, phase3) != None:
from_Room = TryGetFromRoom(i, phase3)
break
else:
from_Room = None
if from_Room == None and to_Room == None:
Room_Number.append("No to or from Room")
Room_Name.append("No to or from Room")
Doors.append("No to or from Room")
elif to_Room != None:
Numbers = to_Room.GetParameters("Number")
Names = to_Room.GetParameters("Name")
for n in range(len(Numbers)):
Room_Number.append(Numbers[n].AsString())
Room_Name.append(Names[n].AsString())
Doors.append(i)
Room.append(to_Room)
#Assign your output to the OUT variable
OUT = Room_Number, Room_Name, Doors, Room
I think things get a little out of hand when you try to iterate through the project phases …
here’s a simplified version of your code :
import clr
# Import RevitAPI
clr.AddReference('RevitAPI')
import Autodesk
from Autodesk.Revit.DB import *
# Import DocumentManager and TransactionManager
clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
# Import ToDSType(bool) extension method
clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.Elements)
doc = DocumentManager.Instance.CurrentDBDocument
fam_inst = IN[0]
elements = []
for i in IN[0]:
elements.append(UnwrapElement(i))
def TryGetToRoom(Room, phase):
if Room.get_ToRoom(phase) != None:
toRoom = Room.get_ToRoom(phase)
else :
toRoom = 'No to room'
return toRoom
def TryGetFromRoom(Room, phase):
if Room.get_FromRoom(phase) != None:
fromRoom = Room.get_FromRoom(phase)
else:
fromRoom = 'No from room'
return fromRoom
output = []
for i in elements:
to_Room = TryGetToRoom(i, doc.GetElement(i.CreatedPhaseId))
from_Room = TryGetFromRoom(i,doc.GetElement(i.CreatedPhaseId))
output.append([to_Room,from_Room])
OUT = output
it gives toroom and fromroom of your list of doors. You can enrich the code and get room numbers etc.
also, when there is no toromm or fromroom, it’s not a exception. It just returns a null value. So I don’t think the try / except syntax willdo what you’re expecting here. An if / else seems more appropriate .
Thank you so much, thanks for your help man , i really appreciate it
i will try it , i will post here
Hi man ,
if i have 3 doors swing inside the same room (e.g room number is L1-015, so the doors will have the same room number “L-015”)
but they should have L1-015-01, L1-015-02, L1-015-03
how i can do it
Hi de_Tarek2 are you looking for like this script:
I’m sorry man you are so professional , I’m still beginner
I appreciate all of your efforts , but I tried to understand why we have “phase”?
this what I tried to do to renumber the doors but I still didn’t solve the issue in the last comment (Renumbering the door as room number)
thanks a lot Memet, what’s the name of this package ??
The ToRoom and FromRoom methods require a phase… It probably has something to do with the fact that a room can exist in one phase only.
You can do it like this :
or use your “get to from room” node instead of the python code , it will work exactly the same
There is costum node, you can mark the doors with this node.
Bold-Door_Mark.dyf (7.5 KB)
Count with a capital C
Memet_Akcan , thanks a lot , I tried to run it but there is one node need to download (Bold-to_from Room node ) but I tried to search to which package belong I didn’t find it
thanks again
Mostafa_El_Ayoubi
thanks man, I’m sorry for a headache