Jump to content

Change all Text


migs

Recommended Posts

Hi Lee, it's wonderful~

Is it possible that the user can selecet the textstyle from dialogue box and keyin to decide the height?

 

Much appreciate~

 

For instance to change all text and mtext to Verdana with height 4.5:

 

(defun txtchng (sNme Ht / ss)
 (vl-load-com)
 (if (and (tblsearch "STYLE" sNme)
      (setq ss (ssget "X" (list (cons 0 "TEXT,MTEXT")
            (if (getvar "CTAB")(cons 410 (getvar "CTAB"))
               (cons 67 (- 1 (getvar "TILEMODE"))))))))
   (progn
     (setq ss (mapcar 'entget (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss)))))
     (foreach e ss    
       (entmod (subst (cons 7 sNme) (assoc 7 e) (subst (cons 40 Ht) (assoc 40 e) e)))))
   (princ "\n<!> No Text Found or Verdana Style Doesn't Exist <!>"))
 (princ))

(defun c:test ()
 (txtchng "VERDANA" 4.5)
 (princ))

Link to comment
Share on other sites

  • Replies 30
  • Created
  • Last Reply

Top Posters In This Topic

  • Lee Mac

    13

  • migs

    5

  • CAB

    4

  • ReMark

    3

Top Posters In This Topic

To answer your question to me.

(defun txtchng (sNme Ht / ss elst_list lst)
 (vl-load-com)
 (if (and (tblsearch "STYLE" sNme)
          (setq ss (ssget "X"
                          (list (cons 0 "TEXT,MTEXT")
                                (if (getvar "CTAB")
                                  (cons 410 (getvar "CTAB"))
                                  (cons 67 (- 1 (getvar "TILEMODE")))
                                ))))
     )
   (progn
     ;; (vl-remove-if 'listp  is only needed when the user selects the ss
     ;; so when not using window to get the ss, don't need to use it
     ;; although its only penalty for using it is time 
     (setq elst_list (mapcar 'entget (mapcar 'cadr (ssnamex ss))))
     (foreach lst elst_list
       (mapcar '(lambda (new old) (setq lst (subst new old lst)))
               (list (cons 7 sNme)(cons 40 Ht))
               (list (assoc 7 e)(assoc 40 e))
       )
       (entmod lst)
     )
   )
   (princ "\n<!> No Text Found or Verdana Style Doesn't Exist <!>")
 )
 (princ)
)

Link to comment
Share on other sites

Ahh, yes - thanks CAB for the advice.

 

I didn't think a lambda function was needed, as I provided the subst with the arguments it needed in LISP form, but obviously this is a better way to do it.

 

Thanks once again

 

Lee

Link to comment
Share on other sites

Thanks Lee~

It's marvelous!

 

Would u please tell me how to add ACAD search path?

It seems to be work only when I put the DCL in C:\Program Files\AutoCAD 2006\Support .

 

Regards~

 

Perhaps something like this?

 

Make sure you put the DCL in ACAD search path and run LISP as normal.

Link to comment
Share on other sites

forgiev my ignorance, I find the answer here:

 

 

http :discussion.autodesk.com/forums/message.jspa?messageID=5533620

 

Go to:

 

Options

Files tab

Support Files Search Path

Add

Browse (select the folder where you installed the program.

 

Re-Load and Re-Run the program and it should work.

 

Thanks Lee~

It's marvelous!

 

Would u please tell me how to add ACAD search path?

It seems to be work only when I put the DCL in C:\Program Files\AutoCAD 2006\Support .

 

Regards~

Link to comment
Share on other sites

No worries, glad you like it :)

 

I normally have a folder in my docs entitled "ACAD Search Path", and locate this in ACAD - then I can quickly just dump dcls and lsps in there with ease. :)

 

Glad you like it - if you have any further questions, just ask :)

 

Cheers

 

Lee

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...