Get all text note types

Kevin.Bell
Advisor

Get all text note types

Kevin.Bell
Advisor
Advisor

Hi,

 

I'm trying to create a text note to add information to a view. I can easily create the text note, but I can't seem to get a list of all of the 2D annotation Text types within a project.

 

I've tried:

 

IList<Element> getTextStyles = new FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_TextNotes).WhereElementIsElementType().ToElements();

 

and

 

IList<Element> getTextStyles = new FilteredElementCollector(doc).OfClass(typeof(TextNote)).WhereElementIsElementType().ToElements();

 

Both return no results.

 

Is there a way to do this?

Thanks!

0 Likes
Reply
Accepted solutions (1)
380 Views
3 Replies
Replies (3)

RPTHOMAS108
Mentor
Mentor
Accepted solution

No they don't have a category and the class they belong to is TextNoteType not TextNote.

 

So I would try ElementClassFilter with TextNoteType.

 

When you use ElementClassFilter you don't have to also use further filters to get instance or type because API classes are often (if not always) specific to instance or type e.g. TextNote = instance, TextNoteType = type

0 Likes

Kevin.Bell
Advisor
Advisor

Excellent!, that worked:

 

IList<Element> getTextStyles = new FilteredElementCollector(doc).OfClass(typeof(TextNoteType)).WhereElementIsElementType().ToElements();

 

Thanks!

0 Likes

RPTHOMAS108
Mentor
Mentor

IList<Element> getTextStyles = new FilteredElementCollector(doc).OfClass(typeof(TextNoteType)).WhereElementIsElementType().ToElements();

 

The above should also work the same.

0 Likes