Last active
September 1, 2016 01:04
-
-
Save gtalarico/ff475ea250337fc0c45727e19829a395 to your computer and use it in GitHub Desktop.
RevitAPI::Code Snippets::Create Text Function
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' 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