Jump to content

Recommended Posts

Posted

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))

  • Replies 30
  • Created
  • Last Reply

Top Posters In This Topic

  • Lee Mac

    13

  • migs

    5

  • CAB

    4

  • ReMark

    3

Top Posters In This Topic

Posted

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)
)

Posted

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

Posted

The problem is using subst which requires 3 arguments.

Using Mapcar without lambda does not lend itself to this application.

Posted

I see, just need to choose the correct tool for the job :)

 

Thanks CAB.

Posted

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.

Posted

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~

Posted

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

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...