Skip to content

Instantly share code, notes, and snippets.

@gtalarico
Last active September 1, 2016 01:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gtalarico/ff475ea250337fc0c45727e19829a395 to your computer and use it in GitHub Desktop.
Save gtalarico/ff475ea250337fc0c45727e19829a395 to your computer and use it in GitHub Desktop.
RevitAPI::Code Snippets::Create Text Function
''' Create a text annotation element.
Does not include start/commit transaction.'''
def create_text(view, text, point, align):
"""Creates a Revit Text.
create_test(view, text_string, point)
view: view object to insert text
text: text to be inserted
point: insertion point - XYZ() instance
align: 'left', 'right', or 'center'
"""
baseVec = XYZ.BasisX
upVec = XYZ.BasisZ
text_size = 10
text_length = 0.5
text = str(text)
align_options = {'left': TextAlignFlags.TEF_ALIGN_LEFT |
TextAlignFlags.TEF_ALIGN_MIDDLE,
'right': TextAlignFlags.TEF_ALIGN_RIGHT |
TextAlignFlags.TEF_ALIGN_MIDDLE,
'center': TextAlignFlags.TEF_ALIGN_CENTER |
TextAlignFlags.TEF_ALIGN_MIDDLE,
}
text_element = doc.Create.NewTextNote(view, point, baseVec, upVec,
text_length,
align_options[align],
text)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment