Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

lisp for changing text globally

2 REPLIES 2
Reply
Message 1 of 3
tracidennis
1984 Views, 2 Replies

lisp for changing text globally

I have a routine that works the way i want but need to add a function that will also change the text  (attributes, mtext, text) style to simplex. I have and old routine that will do that but am not sure how to incorporate it into my lisp.

 

 

 

;;;Routine will rename selected block and edit to change entities to layer 0 and color to bylayer. Would like to add change all text to simplex.

(defun c:RB (/)
  (vl-load-com)
  (setq obj (vlax-ename->vla-object (car (entsel "Select block: ")))
        Eblkname (vlax-get obj 'Effectivename)
        Nblkname (strcat (vlax-get obj 'Effectivename) "-ex")
  )
  (prompt (strcat "\n\nDynamic block " Eblkname "\nhas been renamed to: " Nblkname "\n"))
  (command "_.rename" "b" Eblkname Nblkname)
(command "-bedit" nblkname)                 
(command "change" "all" "" "p" "la" "0" "p" "c" "bylayer" "" "")

;INSERT CHANGE TEXT STYLE HERE

(command "bclose" "s")
  (princ)
)


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;Global Text Change;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun c:GT ()
   (setq S1 nil) (gc)   ; Clear Selection set for use.
   (prompt "\nSelect text objects:") ; Will already be selected
   (setq S1 (ssget))
   (ss-sieve S1 "TEXT") ; Utility routine from Listing 2.
   (setq User "Go")
   (while (/= User "Exit")
      (setq User
 (strcase
  (getstring "\nChange: Style/Height/Oblq angle/Rot angle/ <eXit>:"))) ;All I need is Style
      (if (> (strlen User) 1) (setq User (substr User 1 1)))
      (cond
 ((and (/= User "X") (/= User ""))
   (setq Code


      (cond
        ((= User "S") 7)
        ((= User "H") 40)
        ((= User "O") 51)
        ((= User "R") 50)
        (t nil)))
   (cond
      ((boundp 'Code)
        (setq New (getstring "\nNew value:")); simplex
        (if (> Code 20) (setq New (atof New)))
        (if (and (> Code 49) (< Code 60))
      (setq New (* (/ New 180.0) pi)))
        (setq CNT -1)
        (repeat (sslength S1)
    (setq Elist (entget (ssname S1 (setq CNT (1+ CNT)))))
    (entmod
      (cond
         ((null (assoc Code Elist))
     (append Elist (list (cons Code New))))
         (t
     (subst (cons Code New) (assoc Code Elist) Elist)
         )))))(t (prompt "\nEntry invalid:"))))(t
    (setq User "Exit")))))
(defun ss-sieve (S1 Screen)
   (setq CNT (sslength S1))
   (while (> CNT 0)
      (setq Elist (entget (ssname S1 (setq CNT (1- CNT)))))
      (cond
 ((/= (cdr (assoc 0 Elist)) Screen)
   (ssdel (ssname S1 CNT) S1)))))

2 REPLIES 2
Message 2 of 3
Balaji_Ram
in reply to: tracidennis

Hi Traci,

 

You will need the "vla-put-stylename" to update the text style of the attribute.

 

Have you tried the code from this discussion thread ?

http://forums.autodesk.com/t5/Visual-LISP-AutoLISP-and-General/Attribute-Text-Style-Change/td-p/2123...

 

Regards,

Balaji

 



Balaji
Developer Technical Services
Autodesk Developer Network

Message 3 of 3
tracidennis
in reply to: tracidennis

Thanks, I found an old command called _optchprop that does what I want without any "real" code.

 

Thanks.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost