change text style

Discussion in 'AutoCAD' started by yavid, Aug 13, 2004.

  1. yavid

    yavid Guest

    I need a lisp routine that changes all text on a certain style to another pre-defined style.

    ie:
    style 60a changed to style 80a

    Kinda new at this so any ideas or help would be greatly appreciated.
     
    yavid, Aug 13, 2004
    #1
  2. yavid

    T.Willey Guest

    You could use the built-in filter command or you could use lisp. In lisp to get all text of a certain style you could do:
    (setq ss (ssget "x" (list (cons 7 "enterOriginalStylename"))))
    then once you get your selection set, cycle thru it changing it the way you want to.
    Example: (after you have selection set)
    (while (/= (sslength ss) 0)
    (setq ent1 (vlax-ename->vla-object (ssname ss 0)))
    (vlax-put ent1 'StyleName "NewStylename")
    (ssdel (ssname ss 0) ss)
    )

    Tim
     
    T.Willey, Aug 13, 2004
    #2
  3. yavid

    Walt Engle Guest

    Here is one that I have had for 15 years - you can either select (type SE) or use globally for all texts.

    ; CHGSTY.LSP
    ; CHANGES text GLOBALLY
    (defun c:chgsty ()
    (prompt "GLOBAL TEXT STYLE CHANGE.")
    (terpri)
    (setvar "cmdecho" 0)
    (initget 1 "SE ST ")
    (setq G (strcase (substr (getkword "SElection/<STyle>: ")1 2)))
    (cond
    ((= G "SE")
    (setq A (ssget))
    (setq B (sslength A))
    (initget 1) (setq C (getstring "\nEnter new text style: "))
    (extang C)
    (while
    (> B 0)
    (setq B (1- B))
    (setq D (ssname A B))
    (setq D (entget D))
    (setq E (assoc 7 D))
    (setq F (cons 7 C))
    (setq D (subst F E D))
    (setq H (assoc 51 D))
    (setq I (cons 51 J))
    (entmod (subst I H D))
    )
    (setq A nil)
    )
    ((or (= G "ST") (= G ""))
    (initget 1)
    (setq A (strcase (getstring "\nEnter text style to change: ")))
    (initget 1) (setq C (getstring "\nEnter new text style: "))
    (setq D (entnext))
    (extang C)
    (while
    D
    (princ ".")
    (setq E (entget D))
    (if
    (and (= "TEXT" (cdr (assoc 0 E))) (= A (cdr (assoc 7 E))))
    (progn
    (setq F (assoc 7 E))
    (setq G (cons 7 C))
    (setq E (subst G F E))
    (setq H (assoc 51 E))
    (setq I (cons 51 J))
    (entmod (subst I H E))
    )
    )
    (setq D (entnext D))
    )
    )
    )
    (princ)
    )
     
    Walt Engle, Aug 14, 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.