Author Topic: Get all Xrefs  (Read 2118 times)

0 Members and 1 Guest are viewing this topic.

Shade

  • Guest
Get all Xrefs
« on: April 01, 2008, 10:20:33 AM »
Is there a quick way to get all the xrefs in a drawing?

I have this so far

Code: [Select]
(setq  XREFS (vla-get-filedependencies
                         (vla-get-activedocument
                                  (vlax-get-acad-object)
)                 )     );

But I am a little lost on where to go from there?
I have the number of xrefs in a drawing, but how do i get their names?

Any help would be appreciated :mrgreen:

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Get all Xrefs
« Reply #1 on: April 01, 2008, 10:50:25 AM »
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

daron

  • Guest
Re: Get all Xrefs
« Reply #2 on: April 01, 2008, 11:40:31 AM »
This ought to get you what you're looking for. It creates a list of vla-objects  based on your collection.
vla-collection = XREFS <your variable
string = "ACAD:XRef"
BTW, that's seems like a nice way to get the xrefs. I would've thought to go the the blocks collection.
Code: [Select]
(defun getobject (vla-collection string / item xlist cnt)
   (setq cnt 1)
   (repeat (vla-get-count xrefs)
      (and (= (vla-get-feature (setq item (vla-item xrefs cnt))) string)
   (setq xlist (append xlist (list item)))
      )
      (setq cnt (1+ cnt))
   )
   xlist
)

daron

  • Guest
Re: Get all Xrefs
« Reply #3 on: April 01, 2008, 11:42:59 AM »
From there you're looking for vla-get-filename or vla-get-fullfilename.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Get all Xrefs
« Reply #4 on: April 01, 2008, 01:13:11 PM »
From my stash.
Code: [Select]
;;A simpler version of getxrefs:
;;D. C. Broad, Jr. - 2002
(defun getxrefs( /  b bl)
  (while (setq b (tblnext "block" (not b)))
    (and
      (assoc 1 b) ;xr path
      (setq bl (cons (cdr (assoc 2 b)) bl))))
   bl)


;;A version that gets only resolved xrefs
;;(Only resolved xrefs appear in drawing)
;;D. C. Broad, Jr. - 2002
(defun GetResXrefs( /  b bl)
  (while (setq b (tblnext "block" (not b)))
    (and
      (= 32 (logand 32(cdr(assoc 70 b)))) ;xr path resolved
      (setq bl (cons (cdr (assoc 2 b)) bl))))
   bl)


;;A version that gets only unresolved xrefs
;;Won't report problems as long as the xref
;;is visible on the screen
;;D. C. Broad, Jr. - 2002
(defun BitSetDXF (bit key alist)
   (= bit (logand bit (cdr(assoc key alist)))))
(defun GetLostXrefs ( / b bl)
 (while (setq b (tblnext "block" (not b)))
    (and
      (BitSetDXF 4 70 b) ;xref
      (not (BitSetDXF 32 70 b));path not resolved
      (setq bl (cons (cdr (assoc 2 b)) bl))));add to list
   bl)


PS
Took me awhile but here is the link
« Last Edit: April 01, 2008, 01:26:44 PM by CAB »
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Shade

  • Guest
Re: Get all Xrefs
« Reply #5 on: April 02, 2008, 01:37:35 PM »
Thanks for all the help.
I was able to complete my lisp based on the info provided.
 :lol:

daron

  • Guest
Re: Get all Xrefs
« Reply #6 on: April 02, 2008, 01:39:17 PM »
No problem. It gave me something to think about.