Jump to content

Code to change text height


JONTHEPOPE

Recommended Posts

;q
;q
(defun chgtext1()
(setvar "cmdecho" 0)
(setq newht (getreal "\n Enter new text height; "))
(setq ss1 (ssget))
(setq name (ssname ss1 0))
(setq ent (entget name))
(setq oldlist (assoc 40 ent))
(setq conlist (cons (car oldlist) newht))
(setq newlist (subst conlist oldlist ent))
(entmod newlist)
(setvar "cmdecho" 1)
(princ)
)

 

Please use [ CODE ] tags.

Link to comment
Share on other sites

I'm assuming that you are posting this as code for others to use, so I'm moving this thread to the Autolisp Archive forum

 

Allow me to make a few changes for consideration...

 

1. declare variables local

2. restore cmdecho value that was set, not just set it to 1

3. use (getdist) in text height prompt so user can pick height

4. Add c: prefix so the parenthesis are not needed to call this function

 

(defun C:chgtext1 (/ CMDECHO CONLIST ENT NAME NEWHT NEWLIST OLDLIST SS1)
 (setq cmdecho (getvar "cmdecho"))
 (setvar "cmdecho" 0)
 (setq newht (getdist "\n Enter new text height; "))
 (princ "\nSelect text: ")
 (setq ss1 (ssget))
 (setq name (ssname ss1 0))
 (setq ent (entget name))
 (setq oldlist (assoc 40 ent))
 (setq conlist (cons (car oldlist) newht))
 (setq newlist (subst conlist oldlist ent))
 (entmod newlist)
 (setvar "cmdecho" cmdecho)
 (princ)
)

  • Like 1
Link to comment
Share on other sites

  • 8 months later...

Just to elaborate on RKMcSwain's code, this filters out non-text entities and allows for errors in input:

 

(defun c:chgtxt  (/ ht ss)
 (vl-load-com)
 (if (and (setq ht (getdist "\nSpecify New Text Height: "))
          (setq ss (ssget '((0 . "*TEXT")))))
     (foreach x (mapcar 'entget
                  (vl-remove-if 'listp
                    (mapcar 'cadr (ssnamex ss))))
       (entmod (subst (cons 40 ht) (assoc 40 x) x))))
 (princ))

  • Like 1
Link to comment
Share on other sites

  • 12 years later...
On 4/1/2009 at 7:16 PM, Lee Mac said:

Just to elaborate on RKMcSwain's code, this filters out non-text entities and allows for errors in input:

 

 


(defun c:chgtxt  (/ ht ss)
 (vl-load-com)
 (if (and (setq ht (getdist "\nSpecify New Text Height: "))
          (setq ss (ssget '((0 . "*TEXT")))))
     (foreach x (mapcar 'entget
                  (vl-remove-if 'listp
                    (mapcar 'cadr (ssnamex ss))))
       (entmod (subst (cons 40 ht) (assoc 40 x) x))))
 (princ))
 

 

is it possible to change all the text height in block?

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