Apologies that my nodes didn’t work for you as you have expected. I made some changes to them below. Please give this a try:
Here’s the Dynamo Definition: 2_HideUnhide.dyn (31.4 KB)
Code for the IsHidden
node:
# Copyright(c) 2018, Konrad K Sobon
# @arch_laboratory, http://archi-lab.net
import clr
clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)
clr.AddReference("RevitAPI")
from Autodesk.Revit.DB import *
import sys
pyt_path = r'C:\Program Files (x86)\IronPython 2.7\Lib'
sys.path.append(pyt_path)
def process_parallel_lists(_func, *lists):
return map(lambda *xs: process_parallel_lists(_func, *xs) if all(type(x) is list for x in xs) else _func(*xs),*lists)
def IsHidden(e, v):
element = UnwrapElement(e)
view = UnwrapElement(v)
return element.IsHidden(view)
try:
errorReport = None
output = process_parallel_lists(IsHidden, IN[0], IN[1])
except:
import traceback
errorReport = traceback.format_exc()
if None == errorReport:
OUT = output
else:
OUT = errorReport
Code for the improved Hide node:
# Copyright(c) 2018, Konrad K Sobon
# @arch_laboratory, http://archi-lab.net
import clr
clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument
clr.AddReference("RevitAPI")
import Autodesk
from Autodesk.Revit.DB import *
import System
from System.Collections.Generic import *
import sys
pyt_path = r'C:\Program Files (x86)\IronPython 2.7\Lib'
sys.path.append(pyt_path)
def ProcessListArg(_func, _list, _arg):
return map( lambda x: ProcessListArg(_func, x, _arg) if type(x)==list else _func(x, _arg), _list )
def HideElements(v, elements):
view = UnwrapElement(v)
ids = List[ElementId]()
for i in elements:
e = UnwrapElement(i)
if not e.IsHidden(view) and e.CanBeHidden(view):
ids.Add(e.Id)
if ids.Count > 0:
view.HideElements(ids)
return None
if isinstance(IN[0], list):
elements = IN[0]
else:
elements = [IN[0]]
if isinstance(IN[1], list):
views = IN[1]
else:
views = [IN[1]]
if IN[2]:
try:
errorReport = None
TransactionManager.Instance.EnsureInTransaction(doc)
ProcessListArg(HideElements, views, elements)
TransactionManager.Instance.TransactionTaskDone()
except:
import traceback
errorReport = traceback.format_exc()
else:
errorReport = "Set RunIt to True."
if errorReport == None:
OUT = elements, views
else:
OUT = errorReport
Code for the improved Unhide node:
# Copyright(c) 2018, Konrad K Sobon
# @arch_laboratory, http://archi-lab.net
import clr
clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument
clr.AddReference("RevitAPI")
import Autodesk
from Autodesk.Revit.DB import *
import System
from System.Collections.Generic import *
import sys
pyt_path = r'C:\Program Files (x86)\IronPython 2.7\Lib'
sys.path.append(pyt_path)
def ProcessList(_func, _list):
return map( lambda x: ProcessList(_func, x) if type(x)==list else _func(x), _list )
def ProcessListArg(_func, _list, _arg):
return map( lambda x: ProcessListArg(_func, x, _arg) if type(x)==list else _func(x, _arg), _list )
def Unwrap(item):
return UnwrapElement(item)
def UnhideElements(v, elements):
view = UnwrapElement(v)
ids = List[ElementId]()
for i in elements:
e = UnwrapElement(i)
if e.IsHidden(view):
ids.Add(e.Id)
if ids.Count > 0:
view.UnhideElements(ids)
return None
if isinstance(IN[0], list):
elements = IN[0]
else:
elements = [IN[0]]
if isinstance(IN[1], list):
views = IN[1]
else:
views = [IN[1]]
if IN[2]:
try:
errorReport = None
TransactionManager.Instance.EnsureInTransaction(doc)
output = ProcessListArg(UnhideElements, views, elements)
TransactionManager.Instance.TransactionTaskDone()
except:
import traceback
errorReport = traceback.format_exc()
else:
errorReport = "Set RunIt to True."
if errorReport == None:
OUT = elements, views
else:
OUT = errorReport
Good luck!