Quantcast
Channel: Scripting - McNeel Forum
Viewing all articles
Browse latest Browse all 5749

Python: Select text with same height

$
0
0

@timglobal wrote:

Hello everyone, I'm fairly new to scripting in python, but so far its cool.
I was working with an urban plan and needed to select some text of specific height. I looked around the forum and managed to find some related info which helped me a lot, but I still have a couple of questions:

code
def SelectTextWithSameHeight():
    # Let user pick a text object with required height
    txtObj = rs.GetObject("Select text", filter=512)
    if rs.IsText(txtObj):
        # Return current text height
        textHeight = rs.TextObjectHeight(txtObj)

    rs.EnableRedraw(False)

    # Select all annotation objects and store them in annotations
    annotations = rs.ObjectsByType(rs.filter.annotation)
    # Go through each annotation
    for annotation in annotations:
        # Check if it's a numeric text
        if rs.IsText(annotation) and rs.TextObjectText(annotation).isdigit():
            # And if yes, get its height
            textHeights = rs.TextObjectHeight(annotation)
            # If its height equals to preselected height,
            if textHeights == textHeight:
                # select it
                rs.SelectObject(annotation)

    rs.EnableRedraw(True)

if __name__=="__main__":
    SelectTextWithSameHeight()
  1. So, there is this filter 512 for annotations, I was wondering if annotations here is just text objects or does it include other stuff like dimensions?
    txtObj = rs.GetObject("Select text", filter=512)

  2. Is there a better way to write this function or do you have any suggestions?

Posts: 3

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 5749

Trending Articles