Trying to hide all text via type name but I get a error/message:
Blockquote
Traceback (most recent call last):
File “”, line 64, in
File “”, line 37, in ProcessListArg
File “”, line 37, in <lambda$149>
File “”, line 47, in HideElements
Exception: The set of elements to be hidden is empty.
Parameter name: elementIdSet
Merely guessing - but is the node struggling to handle the lists correctly? Try adjusting the @levels on the HideElements node and see if you get anywhere.
It can also be worth editing the node and seeing which lines of code of causing the error. Even if you don’t know how to code, knowing the function or variable that is causing the issue can help you resolve your inputs or find a workaround to get things going.
import clr
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 *
clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.Elements)
import System
from System.Collections.Generic import List
ueWrapper = None
wrappers = clr.GetClrType(Revit.Elements.ElementWrapper).GetMethods()
for w in wrappers:
if w.ToString().startswith("Revit.Elements.UnknownElement"):
ueWrapper = w
break
def hideElements(textNotes):
for i in textNotes:
v = doc.GetElement(i.OwnerViewId)
if not i.IsHidden(v) and i.CanBeHidden(v):
v.HideElements(List[ElementId]([i.Id]))
def unHideElements(textNotes):
for i in textNotes:
v = doc.GetElement(i.OwnerViewId)
if i.IsHidden(v):
v.UnhideElements(List[ElementId]([i.Id]))
nameType = IN[0]
hideBool = IN[1]
#filter constuction
pvp = ParameterValueProvider(ElementId(BuiltInParameter.SYMBOL_NAME_PARAM))
evaluator = FilterStringEquals()
rule = FilterStringRule(pvp, evaluator, nameType, True)
filter = ElementParameterFilter(rule)
textNotes = FilteredElementCollector(doc).OfClass(TextNote).WherePasses(filter).ToElements()
TransactionManager.Instance.EnsureInTransaction(doc)
if hideBool:
hideElements(textNotes)
else:
unHideElements(textNotes)
TransactionManager.Instance.TransactionTaskDone()
#by pass the out Wrapper for Dynamo 2.0.4
textNotesUnwrap = [ueWrapper.Invoke(None, (txtN, False)) for txtN in textNotes ]
OUT = textNotesUnwrap
Hello
ElementWrapper class is used to build element wrapper to wrapp Autodesk.Revit.DB.Element types
in Revit.Elements.Element and if possible, wrapp in a DS type.
UnknownElement class allows to force the use of the unknown element wrapper instead, and to use it we use Reflection (with Invoke)
there is another example here
Note with higher versions (beyond Dynamo 2.0.4) the bug is fixed for TextNotes