Change text height via lisp

Discussion in 'AutoCAD' started by ajm, Aug 2, 2004.

  1. ajm

    ajm Guest

    After securing the following list
    (setq ss1 (ssget "X" '((0 . "TEXT") (-4 . "=") (40 . 250.0)))) ;selects ALL text 250 high
    How would I change the entities in the list to a new text style "notes", 0.8 width & left justified.
    Any help appreciated.
    T.I.A.
    Andrew McDonald
     
    ajm, Aug 2, 2004
    #1
  2. ajm

    Jürg Menzi Guest

    Hi Andrew

    This sample should give you an idea to start (text style 'notes' must exist
    before you start the program):

    Code:
    (defun C:Test ( / CurEnt CurObj CurSet)
    (vl-load-com)
    ;if you want automate text style creation, do it here:
    ;(if (not (tblsearch "STYLE" "notes"))
    ;create text style 'notes'
    (setq CurSet (ssget "X" '((0 . "TEXT") (-4 . "=") (40 . 250.0))))
    (if CurSet
    (while (setq CurEnt (ssname CurSet 0))
    (setq CurObj (vlax-ename->vla-object CurEnt))
    (ssdel CurEnt CurSet)
    (vla-put-alignment CurObj acAlignmentLeft)
    (vla-put-StyleName CurObj "notes")
    (vla-Update CurObj)
    )
    )
    (princ)
    )
    Cheers
     
    Jürg Menzi, Aug 2, 2004
    #2
  3. ajm

    Fatty Guest

    Try like this:

    (defun C:TX_RAM ()
    (setvar "CMDECHO" 0)
    (prompt "\nSelection window")
    (setq p1 (getpoint "\nFirst Corner: "))
    (setq p2 (getcorner p1 "\nOpposite Corner: "))
    (setq XTX (ssget "W" p1 p2))
    (setq i -1)
    (setq TSZ (getreal "\nCommon text size in dwg :"))
    (repeat (sslength XTX)
    (setq i (1+ i))
    ;;;Changing textsize:
    (setq SZ (cons 40 TSZ))
    (setq ed (entget (ssname XTX i)))
    (setq ed (subst SZ (assoc 40 ed) ed ))
    (entmod ed)
    );repeat
    (princ)
    );eof
     
    Fatty, Aug 2, 2004
    #3
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.