Unable to get Names of TextNoteType objects

I’m trying to retrieve the TextNoteType matching a desired name string so that I can then change the style of a text note using my_text_note.ChangeStyleId(text_note_type.Id). Unfortunately, it seems like I can’t access the Name property which the TextNoteType class inherits from ElementType. Any workarounds?

from pyrevit import DB
from Autodesk.Revit.DB import FilteredElementCollector
text_note_types = FilteredElementCollector(doc).WhereElementIsElementType().OfClass(DB.TextNoteType).ToElements()

for text_note_type in text_note_types:
    print text_note_type.Name

are you looking for something along the line of this?

text_note_type.LookupParameter("Type Name").AsString()

That appears to do the trick, thank you! Any idea why the Name property can’t be accessed directly for ElementTypes? Seems almost like an API bug.

Not too sure actually. I’m pretty certain it’s not a bug by the way it seems to be structured.

An element has a .Name property that gives us a Type Name
An element type has a .FamilyName property that gives us the family.Name

if we consider the hierarchy:
family > type > instance

So there is a level of consistancy there. As if a child always has some property directly relating to a parent’s parameter. But it’s weird then that the parent does not have that same property available for ease of acces.

Perhaps it’s to prevent people from getting confused when dealing with .Name properties. And hence mixing elemnttype and element in the process?

It’s a bit hazy for me too, never really thought about it tbh.

Interesting, I hadn’t thought about it like that. Thanks for the insight!

It is related to IronPython AFAIK, here is the suggested method: