Get Mtext width formatting value

Get Mtext width formatting value

msarqui
Collaborator Collaborator
886 Views
3 Replies
Message 1 of 4

Get Mtext width formatting value

msarqui
Collaborator
Collaborator

Hi guys,

 

How can I put in a variable the value of a Mtext width formatting?

For exemple, in a Mtext with a width of 1.2, I have this TextString in VLA: "{\\W1.20000000;Example}". in this case it would be the value between "W" and ";".

But, if the Mtext has no width formatting, I have only this TextString "Example"

 

So, regardless all kinds of formatting, how can I extract this value?

 

Thanks for your help

Marcelo

0 Likes
Accepted solutions (1)
887 Views
3 Replies
Replies (3)
Message 2 of 4

ВeekeeCZ
Consultant
Consultant
Accepted solution

Try this...

 

  (if (and (setq txt (cdr (assoc 1 (entget (car (entsel))))))
           (vl-string-search "\W" txt))
    (atof (substr txt (+ 2 (vl-string-search "\W" txt)))))

 

Remember that there could be more than one occurrence.

0 Likes
Message 3 of 4

msarqui
Collaborator
Collaborator
Thanks Bee!
0 Likes
Message 4 of 4

ВeekeeCZ
Consultant
Consultant
You're welcome. Seeing that, you should add 1 as 'else' value. But you probably figured it out yourself 🙂
0 Likes