Change Text Style

Discussion in 'AutoCAD' started by jbryant4, Jan 17, 2005.

  1. jbryant4

    jbryant4 Guest

    Need a routine to change all text in a drawing (MTEXT and single line text) to another text style. Using Filter and Properties command only works for MTEXT. Thanks in advance.
     
    jbryant4, Jan 17, 2005
    #1
  2. jbryant4

    TCEBob Guest

    Go to FILTER, select text, apply and say ALL or window an area. Then refer to
    Properties and you will see Text and Mtext in the drop-down. (Assuming you have
    both). You have to change each separately.

    If you need it fully automated:

    (defun c:chtxsty( / ) ;change text or mtext style
    (setq newsty(getstring "\nEnter the new style name: "))
    (setq sset(ssget '((-4 . "<or")(0 . "MTEXT")(0 . "TEXT")(-4 . "or>"))))
    (setq numb -1)
    (repeat (sslength sset)
    (setq numb(1+ numb))
    (setq obj(entget(ssname sset numb)))
    (setq obj(subst (cons 7 newsty) (assoc 7 obj) obj))
    (entmod obj)
    )
    (princ))

    rs
     
    TCEBob, Jan 17, 2005
    #2
  3. jbryant4

    TCEBob Guest

    Oops. The Program Correctness Committee will fine me unless I declare locals:

    (defun c:chtxsty( / newsty sset numb obj ) ;change text or mtext style
    (setq newsty(getstring "\nEnter the new style name: "))
    (setq sset(ssget '((-4 . "<or")(0 . "MTEXT")(0 . "TEXT")(-4 . "or>"))))
    (setq numb -1)
    (repeat (sslength sset)
    (setq numb(1+ numb))
    (setq obj(entget(ssname sset numb)))
    (setq obj(subst (cons 7 newsty) (assoc 7 obj) obj))
    (entmod obj)
    )
    (princ))

    rs
     
    TCEBob, Jan 17, 2005
    #3
  4. jbryant4

    TCEBob Guest

    I forget: do you have a drop-down box in Properties from which you can select
    different types? in any case, the programlet I sent could be expanded to include
    attributes and dimensions. If you're not handy with lisp I will try to find the
    time to adjust it.

    rs
     
    TCEBob, Jan 17, 2005
    #4
  5. jbryant4

    Tom Smith Guest

    (setq sset(ssget '((-4 . "<or")(0 . "MTEXT")(0 . "TEXT")(-4 . "or>"))))

    Or (setq sset (ssget '((0 . "TEXT,MTEXT")))).
     
    Tom Smith, Jan 17, 2005
    #5
  6. jbryant4

    TCEBob Guest

    Not immediately apparent in the help, but sure. Or....
    (setq sset(ssget '((0."*TEXT")))).

    Gotta try that one.

    rs
     
    TCEBob, Jan 17, 2005
    #6
  7. jbryant4

    TCEBob Guest

    Yup, it worked.

    rs
     
    TCEBob, Jan 17, 2005
    #7
  8. jbryant4

    Paul Turvill Guest

    But as it has been previously and repeatedly noted, that will also find
    RTEXT, ARCTEXT, and any other custom objects whose names end in TEXT. Not a
    good choice if you're interested in writing "bulletproof" code.
    ___
     
    Paul Turvill, Jan 17, 2005
    #8
  9. jbryant4

    TCEBob Guest

    Should have thought about rtext -- but didn't know that arctext was a type. I
    thought it was a block, cobbled together of single letters. Wait -- -- Sure
    enuf, there it is (0 . ARCALIGNEDTEXT).

    rs
     
    TCEBob, Jan 17, 2005
    #9
  10. jbryant4

    Adesu Guest

    Hi jbryant4 ,test my script

    ; rasn is stand for replace style alls name of font
    ; Design by Ade Suharna <>
    ; 18 January 2005
    ; program no. 165/01/2005
    ; edit by
    (defun c:rasn (/ ss idx cnt n e en ent opt)
    (vl-load-com)
    (setq ss (ssget "_X" '((0 . "TEXT"))))
    (setq idx 0)
    (setq cnt 0)
    (setq n (sslength ss))
    (setq opt (getstring "\nENTER NEW STYLE NAME: "))
    (repeat n
    (setq e (ssname ss cnt))
    (setq en (vlax-ename->vla-object e))
    (setq ent (vlax-get-property en "StyleName"))
    (vla-put-StyleName en opt)
    (setq cnt (1+ cnt )))
    (princ)
    )

    text) to another text style. Using Filter and Properties command only works
    for MTEXT. Thanks in advance.
     
    Adesu, Jan 18, 2005
    #10
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.