Jump to content

How to generate a report of all the text in a drawing?


Alexv

Recommended Posts

Hi everyone, I hope y'all are having a good New year so far. 

 

I've been wondering if it's possible to generate a report that reports all the texts in the drawing (inside the model space, not the layout space).

 

For example, for a bench icon, I would have a text 'Bench' next to it, or a text description 'RF' next to the roof line, or UP or DN text next to a staircase to show it's elevation direction (going up or down). Is it possible for Autocad/Civil 3d to report all the text being used in the drawing (as a .txt file or something similar) so that I can copy those texts and use them in a legend table. Often times, I would have a few dozen texts and descriptions in a drawing and I would have to manually scan through the drawing (with my eyes) to find all the 'abbreviated text' to put them in the Legend table. It would be good if Autocad/Civil 3d can generate a text report (of all the text in a drawing) that sort the text from shortest to longest. So the abbreviated text (2 to 3 letters) can easily be identified.

 

I have read through the Autocad documentation but I couldn't find anything similar to what i'm after. Any ideas??

 

Thanks y'all and have a good day.

Edited by Alexv
Link to comment
Share on other sites

@SLW210 Thanks for the reply SLW, whatever works, could you please link me to the post with said 'lisp' script for the data extraction?

 

@BIGALHi Bigal, as always, thanks for the reply. The texts are just the standard Autocad text.

Edited by Alexv
Link to comment
Share on other sites

Using ssget with text filter can get all text, then sort, then check string length. NOTE text only at this stage not mtext.

 

; look for short text and replace
; BY AlanH Feb 2022


; By Gile
(defun remove_doubles (lst)
  (if lst
    (cons (car lst) (remove_doubles (vl-remove (car lst) lst)))
  )
)

(defun AH:replacetext (oldtext anstxt / k ent2 extxt num)
(repeat (setq k (sslength ss))
  (setq ent2 (vlax-ename->vla-object (ssname ss (setq k (- k 1)))))
  (setq extxt  (vla-get-textstring ent2))
  (if (= extxt oldtext)
  (vla-put-textstring ent2 anstxt)
  )
)
)


(defun c:shrtxt ( / lst ss ent lst2 ans)

(if (not AH:getvalsm)(load "Multi Getvals.lsp"))

(setq num (atoi (car (AH:getvalsm (list "Num Characters" "less than " 5 4 "3")))))

(setq ss (ssget "X" '((0 . "TEXT"))))

(setq lst '())

(repeat (setq x (sslength ss))
  (setq ent (entget (ssname ss (setq x (1- x)))))
  (setq lst (cons (cdr (assoc 1 ent)) lst))
)

(setq lst2 (remove_doubles lst))
(setq lst2 (vl-sort lst2 '<))

(foreach txt lst2
  (if (< (strlen txt) num)
  (progn
    (setq ans (car (AH:getvalsm (list "Replace text" "New text" 20 19 txt))))
    (AH:replacetext txt ans)
  )
  )
)

(princ)
)

(c:shrtxt)

 

  • Thanks 1
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...