Author Topic: lisp to select all mtext by override height and change to something else  (Read 1655 times)

0 Members and 1 Guest are viewing this topic.

tdeleske

  • Mosquito
  • Posts: 20
Hello, we are going through cad standards changes because of a merger, changing all text style names and in some cases the heights too in all Templates and Titleblock layouts (many).
I had built a routine to rename the styles and fix heights by style, but not if the mtext used a style name that was intended for smaller height and had the height set to an override value, the mtext override heights I am looking for are unique. For example, the style name used is called ML 2.0 (Ht.2) but the override height is set to 5.1, We need something to select all instances of text or Mtext in the drawing where it's set to 5.1 and change the style to ML 5.0 Bold which should fix the height to the style height because it's been set to a different style.
any assistance would be appreciated!

Lee Mac

  • Seagull
  • Posts: 12912
  • London, England
You could use an ssget filter list such as the following:
Code - Auto/Visual Lisp: [Select]
  1. (defun c:test ( / hgt sty )
  2.    
  3.     (setq sty "ML 2.0")
  4.  
  5.     (if (setq hgt (cdr (assoc 42 (tblsearch "style" sty))))
  6.         (sssetfirst nil
  7.             (ssget "_X"
  8.                 (list
  9.                    '(0 . "MTEXT")
  10.                     (cons 7 sty)
  11.                    '(-4 . "<OR")
  12.                        '(-4 . "<")
  13.                         (cons 40 (- (/ hgt (getvar 'cannoscalevalue)) 1e-3))
  14.                        '(-4 . ">")
  15.                         (cons 40 (+ (/ hgt (getvar 'cannoscalevalue)) 1e-3))
  16.                    '(-4 . "OR>")
  17.                     (if (= 1 (getvar 'cvport))
  18.                         (cons 410 (getvar 'ctab))
  19.                        '(410 . "Model")
  20.                     )
  21.                 )
  22.             )
  23.         )
  24.         (princ (strcat "\nThe Text Style \"" sty "\" is not defined in the active drawing."))
  25.     )
  26.     (princ)
  27. )

Here, the code acquires the Paperspace text height as defined within the Text Style and selects any MText object within the current layout whose text height does not fall within +/-0.001 of the Text Style height based on the current Annotation Scale (CANNOSCALEVALUE). You can then change the appopriate properties through the Properties Palette (or the code could be modified to change such properties).

tdeleske

  • Mosquito
  • Posts: 20
Hi Lee, thank you so much! it works well for this purpose.