Listing x-refs???

Status
Not open for further replies.

Eric Daem

Usenet Archive
Joined
Jan 10, 2000
Messages
18
Reaction score
0
Is there a way (or lisp) to list all the x-refs included in a drawing AND the amount of each??? For exemple, I'd like to know if "bolt1" is in the drawing and how many...
Thank in advance...

Eric
 
The PRO Menu add-on has a block list command which lists the number of insertions of blocks and xrefs.
 
(defun getxref (xrefname / ss)
(setq ss (ssget "x" (list (cons 0 "insert") (cons 2 xrefname)))) (if ss (princ (strcat "\nNumber of occurences of " xrefname " = " (itoa (sslength ss)))) ) (princ) )
To use... (getxref "bolt1")
 
try this...plucked from the adesk ng's sometime in the past. I haven't used it so I only assume that it does what you want...
Dave

(defun C:count_xref
(setq f (open "xreflog.txt" "a"))
(setq num 0)
(setq ent (tblnext "block" 1))
(if (= (logand 4 (cdr (assoc 70 ent))) 4)
(progn
(setq ent (cdr (assoc 1 ent)))
(setq filename (strcat (vl-filename-base ent)
(vl-filename-extension ent)
)
)
(setq filepath (vl-filename-directory ent)
)
(write-line
(strcase
(strcat (getvar "dwgname") ";" filepath ";" filename) ) f ) (princ (strcase (strcat (getvar "dwgname") ";" filepath ";" filename) ) ) (princ "\n") ) ) (while (/= (setq ent (tblnext "block")) nil) (if (= (logand 4 (cdr (assoc 70 ent))) 4) (progn (setq ent (cdr (assoc 1 ent))) (setq filename (strcat (vl-filename-base ent) (vl-filename-extension ent) ) ) (setq filepath (vl-filename-directory ent) ) vl-filename-directory (write-line (strcase (strcat (getvar "dwgname") ";" filepath ";" filename) ) f ) (princ (strcase (strcat (getvar "dwgname") ";" filepath ";" filename) ) ) (princ "\n") ) ) ) (write-line "" f) (close f) (princ)
)

"Eric Daem" wrote:

Is there a way (or lisp) to list all the x-refs included in a drawing AND the amount of each??? For exemple, I'd like to know if "bolt1" is in the drawing and how many...
Thank in advance...

Eric
 
Thanks but...
I don't know how lisp work...
Could you explain how to use it ???

Thanks again...
 
as it said at the bottom of Jim's post, just type (getxref "xxx") at the command line, where xxx is the name of the XRef you want to count. This assumes that you have properly loaded the routine...This routine only counts the one XRef or Block that you tell it to count. I think that the routine I posted counts all XRef and Block inserts and writes a list of them to a file. Dave "Eric Daem" wrote:

Thanks but...
I don't know how lisp work...
Could you explain how to use it ???

Thanks again...
 
Status
Not open for further replies.

Latest threads

Back
Top