Is it possible set the demolished phase of elements to “None” by Dynamo?
Our background: We use a different program for out cost estimations which needs an IFC-file to work with. Because of the limitations in the Revit IFC-Export we need to set up a separate demolition phase, which is obviously not ideal, but no way around that, if we want to distinguish the demolished elements in the calculation program.
To make the phase-management in Revit easier, I want to set the demolished phase automatically with dynamo.
The definition I have so far is fairly simple. I can set the demolished phase to a different phase, but I can’t set it to None. I have tried None, Null, 0, empty list. Any suggestions? Or is this one of those cases that can only by solved by python?
# Copyright(c) 2016, Konrad K Sobon
# @arch_laboratory, http://archi-lab.net
# Import Element wrapper extension methods
import clr
clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)
# Import DocumentManager and TransactionManager
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument
# Import RevitAPI
clr.AddReference("RevitAPI")
import Autodesk
from Autodesk.Revit.DB import *
import sys
pyt_path = r'C:\Program Files (x86)\IronPython 2.7\Lib'
sys.path.append(pyt_path)
#The inputs to this node will be stored as a list in the IN variable.
dataEnteringNode = IN
def ProcessList(_func, _list):
return map( lambda x: ProcessList(_func, x) if type(x)==list else _func(x), _list )
def Unwrap(item):
return UnwrapElement(item)
def SetPhaseToNone(e):
e.get_Parameter(BuiltInParameter.PHASE_DEMOLISHED).Set(ElementId.InvalidElementId)
return e
if isinstance(IN[0], list):
elements = ProcessList(Unwrap, IN[0])
else:
elements = [Unwrap(IN[0])]
try:
errorReport = None
TransactionManager.Instance.EnsureInTransaction(doc)
output = ProcessList(SetPhaseToNone, elements)
TransactionManager.Instance.TransactionTaskDone()
except:
# if error accurs anywhere in the process catch it
import traceback
errorReport = traceback.format_exc()
#Assign your output to the OUT variable
if errorReport == None:
OUT = output
else:
OUT = errorReport
Wow. This forum is incredible. Works like a charm. Thanks a lot.
If someone else has a similar problem, I upload my finished definition: Phase-Mapping.dyn (21.3 KB)
I have similar issue. Because Revit won’t export elements that have “Phase Demolished” set to something to IFC file (logic is that they are demolished and won’t exist). I need to change all of them back to “Phase Demolished: none”. But I’m able to only get it working partially (not for all the elements) - using the same Python script suggested in this topic.
I have tried different ways of selecting items (all in active view and by category). Seems that it’s working in a selecting only couple of times, or in some small demo project…