Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

selecting only loaded xrefs

6 REPLIES 6
Reply
Message 1 of 7
TherealJD
1553 Views, 6 Replies

selecting only loaded xrefs

i want to know what i need to modify to select only x-refs that are loaded. TIA 🙂

 

 

(>= (cdr (assoc 70 (tblsearch "BLOCK" (cdr (assoc 2 entl))))) 4)

 

 

 

 

6 REPLIES 6
Message 2 of 7
scot-65
in reply to: TherealJD

Unfortunately I was never able to *grab* xrefs using tblsearch.

Even though the xref is a block, it is not recognized as an item

that can be searched using tblsearch.

 

Here is a snippet of code that will gather all xrefs.

 

   (while (setq d (tblnext "BLOCK" (not d)))
    (if (assoc 1 d)...
 

There is a VL* equivalent out there as well...

 

scot-65


Scot-65
A gift of extraordinary Common Sense does not require an Acronym Suffix to be added to my given name.


Message 3 of 7
pbejse
in reply to: TherealJD

With code will give you a list of XREF and its status

 

(defun c:SelXref  (/ Xr_lst)
  (vlax-for
     blk  (vla-get-blocks
            (vla-get-activedocument (vlax-get-acad-object)))
    (if (eq (vla-get-isXref blk) :vlax-true)
      (setq Xr_lst
         (cons
           (cons
             (vla-get-name blk)
             (if (> (vla-get-count blk) 0)
               "Loaded" "Unloaded"))
           Xr_lst))))
  (foreach n Xr_lst (print n))
  (princ))

 USAGE:

command: SelXref

("XREFDrawing1" . "Loaded")

("XREFDrawing2" . "Unloaded")

 

I thik you already know what to do next

 

Smiley Happy

Message 4 of 7
pbejse
in reply to: pbejse

You can do it this way if you need to have a selection set

 

(defun c:SelXref  (/ adoc blks objs vl_ob xr)(vl-load-com)
  (setq adoc (vla-get-activedocument (vlax-get-acad-object))
    	blks (vla-get-blocks adoc))
  (if (setq objs (ssget "_x" '((0 . "INSERT"))))
    (mapcar
      '(lambda (nm)
         (setq vl_ob (vlax-ename->vla-object nm))
         (if (eq (vla-get-isXref
                   (setq xr (vla-item blks
                          (vla-get-effectivename vl_ob))))
                 :vlax-false)
           (ssdel nm objs)
           (if (= (vla-get-count xr) 0)
             (ssdel nm objs))))
      (vl-remove-if 'listp (mapcar 'cadr (ssnamex objs)))))
  ;(....)<-- put your routine here  (sssetfirst nil objs)
  (princ)
  )

 

Hope this helps

 

Message 5 of 7
TherealJD
in reply to: pbejse

This looks promising. I'll try it out. Thanks! Smiley Happy

Message 6 of 7
msarqui
in reply to: pbejse

Sorry but I don't get it.

What I need to do if, for exemple, I would like to detach all unreferenced PDF?

Thanks!

Message 7 of 7
Moshe-A
in reply to: msarqui

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

”Boost