legend = ...
def create_text(view, pt, text, typeId=None):
"""Create a TextNote"""
if not typeId or typeId == ElementId(-1):
typeId = doc.GetDefaultElementTypeId(ElementTypeGroup.TextNoteType)
text_note = TextNote.Create(doc, view.Id, pt, text, typeId)
return text_note
X,Y = 0,0
title = create_text(legend, XYZ(X,Y,0), 'Apartments Legend:')