Author Topic: unload loaded xref's then reload only the loaded xrefs (not the unloaded xrefs)  (Read 264 times)

0 Members and 1 Guest are viewing this topic.

damn

  • Mosquito
  • Posts: 15
Hey Guru's,

Damned if I could get this to work.  Trying to unload xref's, preform code, and reload those unloaded xref's without loading the others previous unloaded.  My previous code just unloaded/reloaded *.  That's caused some problems with some of our drawings.

Code - Auto/Visual Lisp: [Select]
  1. (defun c:rxl ()
  2.   (setq loadedXrefs '())
  3.  
  4.   ; Function to unload all xrefs
  5.   (defun unload-all-xrefs ()
  6.       (if (eq :vlax-true (vla-IsExternalReference xref))
  7.         (if (= 1 (vla-get-IsResolved xref))
  8.           (progn
  9.             (vla-unload xref)
  10.             (setq loadedXrefs (cons (vla-get-Name xref) loadedXrefs))
  11.           )
  12.         )
  13.       )
  14.     )
  15.   )
  16.  
  17.   ; Function to reload previously loaded xrefs
  18.   (defun reload-loaded-xrefs ()
  19.       (if (eq :vlax-true (vla-IsExternalReference xref))
  20.         (if (member (vla-get-Name xref) loadedXrefs)
  21.           (vla-reload xref)
  22.         )
  23.       )
  24.     )
  25.   )
  26.  
  27.   (unload-all-xrefs) ; Unload all xrefs
  28.  
  29.   ;;;
  30.   ;;; Main code without Xrefs labouring drawing.
  31.   ;;
  32.  
  33.  
  34.   (reload-loaded-xrefs) ; Reload previously loaded xrefs
  35.   (princ)
  36. )


EDIT (John): Added code tags.
« Last Edit: February 08, 2024, 09:53:47 AM by JohnK »

mhupp

  • Bull Frog
  • Posts: 250
This is every block in the active document.
Code - Auto/Visual Lisp: [Select]

-Edit
one way would to use ssget to selection the xref's you want to reload. adding them to a list.

Code - Auto/Visual Lisp: [Select]
  1. (defun c:rxl (/ ss loadedXrefs)
  2.   (setq ss (ssget '((0 . "INSERT")))) ;user selection
  3.   (foreach xref (mapcar 'vlax-ename->vla-object (vl-remove-if 'listp (mapcar 'cadr (ssnamex SS))))
  4.     (if (eq :vlax-true (vla-IsExternalReference xref))
  5.       (if (= 1 (vla-get-IsResolved xref))
  6.         (setq loadedXrefs (cons (vla-get-Name xref) loadedXrefs))
  7.       )
  8.     )
  9.   )
  10.   (unload-all-xrefs) ;unload all xref's
  11.   (foreach xref loadedXrefs
  12.     (vla-reload xref)
  13.   )
  14.   (princ)
  15. )
  16.  
« Last Edit: February 08, 2024, 05:12:11 PM by mhupp »