Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations IDS on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to count the items in the drawings

Status
Not open for further replies.

seaki001

Structural
Sep 3, 2002
1
I'm a formwork designer. I'm drawing a thound of formwork shop drawings and have to count how many items, such as couplings,panels, nuts,bolts...etc, are used in the drawing.
I just count them one by one after finishing the shop drawing. it's not difficult because every item is same size( same bolt size, same coupling size.....) if it is not complicated)
Is there any method or good command that AutoCAD does the job for me if I want the number of special item such as bolt in the plans?
 
Replies continue below

Recommended for you

There is a way to do it. All parts have to be inserted as "block". A lisp-routing (I think it is under the support directory of ACAD) is able to count the "blocks" and write it to an ASCII-file which can be imported by EXCEL. If You add attributes to the blocks like price per piece etc, You will get a ready to use parts list with prices etc.. The completeness of You table does only depend on number of attributes you add to the inserted block.

I didn´t use AUTOCAD for several years, but I can look for the lisp-routine when needed.

Andreas
 
"S"
If you were to put the item on a separate layer OR if it were a specific block .... then I would type in "FILTER".
Specify the item using one of these properites and save the new filter like a "layer" or "view".
Click "apply" while in "filter" and select all.
At the bottom of the command prompt, it should give you a number selected. Hence, an accurate number count.
Later,
Rich
 
seaki001,

I have a small lsp program that counts all blocks. Just drag and drop it into the active dwg then type count. A nice list of all blocks is output with their counts.

All the best,
William
Will also send this program directly to you as well as include it below.

;----------------------------------------------------
; COUNT.LSP Copyright 1991 Tony Tanzillo All Rights Reserved.
; -----------------------------------------------------------------
;
; Adds the COUNT command to AutoCAD, which counts, itemizes, and displays
; in tabular form, the number of insertions of each block in the selected
; objects, or the entire drawing.
;
; Add to ACAD.LSP, or load with (load"count")
;
; First implemented in May of 1990.
;
; Revision history:
;
; 10/13/1991: General revisions for R11:
;
; 1. Now ignores anonymous blocks and Xrefs.
;
; 2. Added console/screen paging, pauses listing
; at each screen-full and waits for a keypress.
;
; Notes on console paging:
;
; 1. To disable console paging, add the following to COUNT.LSP:
;
; (setq *cpage-disable* t)
;
; 2. The number of physical console lines defaults to 25. This
; can be overridden by adding the following to COUNT.LSP
;
; (setq *console-lines* <num> )
;
; Where <num> is the integer number of physical screen lines.
;
; 3. The screen-clear function defaults to (textpage) under R11,
; and (textscr) under R10 (no screen-clearing is performed),
; but it can be redefined by assigning a function that is to
; be called to do a screen-clear to the symbol *clear-screen*.
;
; The following example can be used with R10 if ANSI.SYS or
; any compatible console-driver is installed, to clear the
; display on each screen-page:
;
; (defun *clear-screen* ()
; (textscr)
; (princ &quot;\e[2J&quot;)
; nil
; )
;
; Program listing:

(defun C:COUNT ( / blocks ss)
(princ &quot;\nPress <CR> to select entire drawing or,&quot;)
(cond
( (not (setq ss (cond ((ssget))
(t (ssget &quot;x&quot; '((0 . &quot;INSERT&quot;)))))))
(princ &quot;\nNo objects selected.&quot;))
(t (princ &quot;\nCounting block insertions...&quot;)
( (lambda (i)
(repeat i (count_block (ssname ss (setq i (1- i))))))
(sslength ss))
(cond
( (not blocks)
(princ &quot;\nNo block insertions found.&quot;))
(t (table-print blocks &quot;Block&quot; &quot;Count&quot; &quot;-&quot; 8 &quot;.&quot; nil 'itoa)))))
(princ)
)

(defun table-print (alist title1 title2 headsub coltab padchr
car-form cdr-form / maxlen maxline padstr )
(setq car-form (cond (car-form) (t '(lambda (x) x)))
cdr-form (cond (cdr-form) (t '(lambda (x) x))))
(setq maxlen
(mapcar
'(lambda (pair)
(cons (strlen (car pair))
(strlen (cdr pair))))
(setq alist
(mapcar
'(lambda (pair)
(cons (apply car-form (list (car pair)))
(apply cdr-form (list (cdr pair)))))
alist ))))
(setq maxlen (+ -2 (apply 'max (mapcar 'car maxlen))
(apply 'max (mapcar 'cdr maxlen)))
maxline (+ maxlen coltab)
padstr (repl padchr 70))

(cprinc-init)
(cprinc (strcat title1 &quot; &quot;
(ctab (cons title1 title2)
maxline
(repl &quot; &quot; 70))
&quot; &quot; title2))
(cprinc (repl headsub (+ maxline 2)))
(mapcar
'(lambda (pair)
(cprinc (strcat (car pair) &quot; &quot;
(ctab pair maxline padstr) &quot; &quot;
(cdr pair))))
alist )
)

(defun repl (chr len / res)
(apply 'strcat (repeat len (setq res (cons chr res))))
)

(defun ctab (pair max padstr)
(substr padstr 1 (- max (strlen (car pair) (cdr pair))))
)

(defun cdr++ (key alist)
( (lambda (x)
(cond (x (subst (cons (car x) (1+ (cdr x))) x alist))
(t (cons (cons key 1) alist))))
(assoc key alist))
)

(defun get (k l) (cdr (assoc k l)))

(defun entgetf (k e)
( (lambda (l)
(mapcar '(lambda (x) (cdr (assoc x l))) k))
(entget e))
)

(defun count_block (ename)
(apply
'(lambda (etype name)
(cond
( (and (eq &quot;INSERT&quot; etype)
(or (assoc name blocks)
(zerop (logand 45 (get 70 (tblsearch &quot;block&quot; name)))))
(setq blocks (cdr++ name blocks))))) nil)
(entgetf '(0 2) ename))
)

(defun cprinc-init ()
(setq *console-lines* (cond (*console-lines*) (t 25))
*cprinc-msg* (cond (*cprinc-msg*) (t &quot;--- Press any key ---&quot;))
*cprinc-rubout*
(cond ( (or textpage *clear-screen*) &quot;&quot;)
(t (strcat &quot;\r&quot; (repl &quot; &quot; (strlen *cprinc-msg*)) &quot;\r&quot;)))
*cprinc-line* -1)
(cond (textpage (textpage))
(*clear-screen* (*clear-screen*))
(t (textscr) (terpri)))
)

(defun cprinc-page ()
(princ *cprinc-msg*)
(grread)
(cond (textpage (textpage))
(*clear-screen* (*clear-screen*))
(t (textscr)))
(princ *cprinc-rubout*)
(setq *cprinc-line* 0)
)

(defun cprinc (s)
(cond ( *cpage-disable*)
( (not *cprinc-line*)
(cprinc-init))
( (eq (setq *cprinc-line* (1+ *cprinc-line*))
(1- *console-lines*))
(cprinc-page)))
(write-line s)
)

; ############################ eof COUNT.LSP ################################

(princ &quot;\nC:COUNT.lsp counts the number of each block. Start cmd with COUNT. &quot;)
(princ)

 
Dear seaki001,
The best way is to draw each type of parts in a specific color and count them using the below commands. Keep in mind that the parameter XX in the below commands indicates the color number you used for each type of parts.

(setq a (ssget &quot;x&quot; '((62 . XX))))
(sslength a)

The above commands are autolisp expressions and you can copy and paste them into AutoCAD command prompt to prehibiting syntax errors. Just replace the parameter XX with the desired number. For example the below commands write number of objects in blue color.

(setq a (ssget &quot;x&quot; '((62 . 5))))
(sslength a)

If you use the 3DSolids for parts, you can force the command to count 3DSolids only. The below code counts 3DSolids in blue color.

(setq a (ssget &quot;x&quot; '((62 . 5) (0 . &quot;3DSOLID&quot;))))
(sslength a)

:)
Farzad
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor