lisp program to find out text heights used in drawing

lisp program to find out text heights used in drawing

Anonymous
Not applicable
1,724 Views
5 Replies
Message 1 of 6

lisp program to find out text heights used in drawing

Anonymous
Not applicable

I am new autolisp. I am glad to you if anyone helps resolve the following:

 

I need a lisp program to find out the various text heights used in my drawing. Usually, we keep our standard text heights of 2.5mm, 3mm and 4mm for the drawing scale 1:1. Our sheet size used for drawings will be 1:50, 1:75 or 1:100.

 

 

My requirement is if I pick two points ( lower left corner to upper right corner) in the drafting area. the lisp program has to give me the text heights used in the drawing.

 

0 Likes
Accepted solutions (1)
1,725 Views
5 Replies
Replies (5)
Message 2 of 6

Anonymous
Not applicable

Hello s.hariharan_43, welcome to the forum.

 

This isn't exactly what you asked for but it will change the text, 'loose' attributes & multiline height(s) to whatever you like:

 

 

(defun c:thc (/ counter entlist1 sstxt textsize)
(princ "\nSelect text to change height")
(setq sstxt (ssget '((-4 . "<OR")(0 . "TEXT")(0 . "MTEXT")(0 . "attdef")(-4 . "OR>"))))
(if (not sstxt)
(princ "\nNo text objects selected.")
(progn
(setq textsize (getreal "Enter new text height: "))
(setq counter 0)
(repeat (sslength sstxt)
(setq entlist1 (entget (ssname sstxt counter)))
(entmod (subst (cons 40 textsize)(assoc 40 entlist1) entlist1))
(setq counter (1+ counter))
);repeat
);progn
);end if
(princ)
);end defun
0 Likes
Message 3 of 6

Anonymous
Not applicable

The above lisp is not working sir. Its displaying malformed error.

I expect the program would calculate the text height with respect to the sheet scale. For ex. 100 scale sheet ,3x100=300mm text height. Moreover the program I need for only provide the information about varieties of text heights used in the drawing and don't want to change the text height.

0 Likes
Message 4 of 6

ВeekeeCZ
Consultant
Consultant

@Anonymous wrote:

The above lisp is not working sir. Its displaying malformed error.


Sir, sbanister's code is working fine. But it presumes copy-pasting a loading the entire code.

 

(Noted, it's not what you want.)

0 Likes
Message 5 of 6

Kent1Cooper
Consultant
Consultant
Accepted solution

@Anonymous wrote:

....

I expect the program would calculate the text height with respect to the sheet scale. For ex. 100 scale sheet ,3x100=300mm text height. ....


Assuming that your drawing scale is in the DIMSCALE System Variable, here's a basic way to do it [minimally tested]:

 

(defun C:THR (/ tss n ht htlist); = Text Height Report
  (if (setq tss (ssget '((0 . "*TEXT"))))
    (progn ; then
      (repeat (setq n (sslength tss))
        (setq ht (/ (cdr (assoc 40 (entget (ssname tss (setq n (1- n)))))) (getvar 'dimscale)))
        (if (not (member ht htlist)) (setq htlist (cons ht htlist)))
      ); repeat
      (prompt "\nText heights [as plotted] used: ")
      (princ (vl-sort htlist '<))
    ); progn
    (prompt "\nNo Text object(s) selected."); else
  ); if
  (princ)
); defun

 

 

That reports on Text and Mtext [and also Rtext, if you ever use that] among the selection, but could be made to also report on Attribute Definition objects and/or Dimensions.  For Mtext, it reports the height assigned to the overall object, ignoring any height overrides within the content.

 

It could be made more sophisticated, e.g. to report in some way other than a raw AutoLisp list [for example, an (alert) box], or to account for annotative Text sizes in Paper Space, or to send the information out to a file of some kind, etc.

Kent Cooper, AIA
0 Likes
Message 6 of 6

Anonymous
Not applicable

Great job. Its solving my purpose. Thank you

0 Likes