Originally Posted by
todw
Now we are talking LISP.
Try this code.
Code:
(defun C:RX (/ BLOCKS NEXTBLOCK N) ;; Reload all "loaded" xref's only
;; Richard Lawrence (c) 2005
;; Revised code to include required function
(defun ASC (ELEMENT ENTITY /) (cdr (assoc ELEMENT ENTITY))) ;;; retrieve assoc data from entity
(setq BLOCKS NIL)
(setq NEXTBLOCK (tblnext "BLOCK" t))
(while (/= NEXTBLOCK NIL)
(if (= (logand (ASC 70 NEXTBLOCK) 4) 4)
(if (= (logand (ASC 70 NEXTBLOCK) 32) 32)
(if BLOCKS
(setq BLOCKS (append BLOCKS (list (ASC 2 NEXTBLOCK))))
(setq BLOCKS (list (ASC 2 NEXTBLOCK)))
)
)
)
(setq NEXTBLOCK (tblnext "BLOCK"))
)
(if blocks
(progn
(foreach N BLOCKS
(command "-XREF" "R" N)
)
(if (= (length blocks) 1)
(princ (strcat "\n"(itoa(length blocks))" reference reloaded."))
(princ (strcat "\n"(itoa(length blocks))" references reloaded."))
)
)
(princ "\nNo xref's found.")
)
(princ)
)
This routine will check to see if the xref is currently loaded, if so it will reload it. if it is not loaded, it will not reload it.
I hope this helps.