Hide/Unhide Text via Type Name

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

Blockquote

Any help would be great.

Hide all mark-ups.dyn (23.4 KB)

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.

Hello
a Python solution (specific to TextNote elements)

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
7 Likes

Hello,

is it just for active view, right?

PS: Many respect to your code! Amazing functions!

1 Like

Hello Deniz
it’s for all TextNotes, TexteNote is an element that depends on a view,
the view can therefore be found via the property OwnerViewId

1 Like

Thank you very much Cyril! Could you please explain what you here have done? What do wrappers mean?

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

2 Likes

This is awesome, thank you very much.
Could this also be adapted to hide detail lines with the same name?

Hello
This is another request please start a new topic.

1 Like