Print Page | Close Window

Audit Blocks

Printed From: CAD Forum
Category: EN
Forum Name: AutoCAD
Forum Description: Discussion about AutoCAD and AutoCAD LT, viewers, DWG and DWF formats, Design Review, AutoCAD 360, add-ons
URL: https://www.cadforum.cz/forum_en/forum_posts.asp?TID=1866
Printed Date: 20.Apr.2026 at 23:52


Topic: Audit Blocks
Posted By: ISElation
Subject: Audit Blocks
Date Posted: 31.Mar.2009 at 21:59
Is there a way to find out exactly what blocks are in a drawing and how many of each block there are?



Replies:
Posted By: msplcdykee69
Date Posted: 31.Mar.2009 at 22:12
Easiest way is to select one of the blocks right click your mouse select similar and then look at your properties window and it will tell you how many selected.

-------------
Engineering Manufacturing Medical Cables/Adjunct Instructor Engineering Graphics/Engineering Computations and Careers

msplcdykee69@yahoo.com

Shawn


Posted By: ISElation
Date Posted: 31.Mar.2009 at 22:27
I do not have that "similar selection" option. Running the "ssx" command is way faster, but then i have the problems with the blocks being on different layers and having to add them up. I was just wondering if there is a way to export all the block names in a dwg and give me the number of each? AS QUICK AS POSSIBLE


Posted By: msplcdykee69
Date Posted: 01.Apr.2009 at 04:25
here is a lisp program use this to count your blocks.  when you type BLK in the command prompt select one of the blocks you wish to know the number of, then window over the area it will give you a count of total number of that particular block in that dwg.
 
 
(defun c:BLK ()
  (SETQ LAY (CDR (ASSOC 2 (ENTGET (CAR (ENTSEL))))))
  (setq sel (ssget (list (cons 0 "insert") (cons 2 lay))))
  (setq sle (itoa (sslength sel)))
  (alert (strcat LAY " : " sle))
)


-------------
Engineering Manufacturing Medical Cables/Adjunct Instructor Engineering Graphics/Engineering Computations and Careers

msplcdykee69@yahoo.com

Shawn


Posted By: ISElation
Date Posted: 01.Apr.2009 at 16:27
That lsp works great, but it would be nice to be able to select all the blocks in a drawing and display how many their are. With this lsp i dont really know if i get every block unless i get a list of all the blocks in the drawing first, and if i am doing this i might as well use the quick select command to find out the total for each. Thanks for all the help.


Posted By: msplcdykee69
Date Posted: 01.Apr.2009 at 16:43
You can try to do a web search for lisp routines. someone out there may have written one to do exactly what your looking for.  If I should happen to find one I will post it here.

-------------
Engineering Manufacturing Medical Cables/Adjunct Instructor Engineering Graphics/Engineering Computations and Careers

msplcdykee69@yahoo.com

Shawn


Posted By: ISElation
Date Posted: 01.Apr.2009 at 18:01

I found this to work perfect.

(defun c:blkcount (/ ss lst itm result)
  (and (setq ss (ssget "x" (list (cons 0 "INSERT"))))
       (setq lst (mapcar '(lambda (x) (cdr (assoc 2 (entget x))))
                         (mapcar 'cadr (ssnamex ss)))
       )
       (setq lst (vl-sort lst '>))
       (while (setq itm (car lst))
         (setq len (length lst))
         (setq lst    (vl-remove itm lst)
               cnt    (- len (length lst))
               result (cons (cons itm cnt) result)
         )
       )
  )
  result
)



Posted By: zhb7
Date Posted: 06.Apr.2009 at 16:22
try  the comand "bcount"


Posted By: msplcdykee69
Date Posted: 07.Apr.2009 at 04:27

I never new about bcount.. Works great Thanks i will know for next time and i have added that to my Company standards.



-------------
Engineering Manufacturing Medical Cables/Adjunct Instructor Engineering Graphics/Engineering Computations and Careers

msplcdykee69@yahoo.com

Shawn


Posted By: ISElation
Date Posted: 07.Apr.2009 at 15:30

bcount works great. Thanks for all the help




Print Page | Close Window