DuanJinHui Posted August 15, 2016 Posted August 15, 2016 Hello ! I see a lisp about reload xref , I find a question. (Defun C:xref_reload ( / rnames i e elist rname) (setvar "cmdecho" 0) (princ "\nSelect objects on the reference file to be Reloaded:") (if (setq SS (ssget)) (progn (setq Rnames "") (repeat (setq I (sslength SS)) (setq E (ssname SS (setq I (1- I)))) (setq ELIST (entget E)) (setq Rname (cdr (assoc 2 ELIST))) (command "-xref" "R" Rname) (setq Rnames (strcat Rname ", " Rnames)) );end repeat (prompt "\nFiles have been Reloaded:") (princ Rnames) );end progn );end if (princ) ) Question is : If this xref has unload . I can't see this xref in drawing. So, How do I do “Select objects on the reference file” ? I think need a dialog show unload reference file list , select item reload from dialog. I think can use Lee's listbox function to do. Who can help me? Thanks a million. Quote
Roy_043 Posted August 15, 2016 Posted August 15, 2016 This may be useful: (defun ListUnloadedXrefs ( / ret) (vlax-for blk (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object))) (if (and (= :vlax-true (vla-get-isxref blk)) (not (vla-get-xrefdatabase blk)) ) (setq ret (cons (vla-get-name blk) ret)) ) ) (reverse ret) ) Quote
Lee Mac Posted August 15, 2016 Posted August 15, 2016 Another, using Vanilla: (defun unloadedxrefs ( / r x ) (while (setq x (tblnext "block" (not x))) (if (= 4 (logand (cdr (assoc 70 x)) 36)) (setq r (cons (cdr (assoc 2 x)) r)) ) ) (reverse r) ) _$ (unloadedxrefs) ("xref") Quote
DuanJinHui Posted August 16, 2016 Author Posted August 16, 2016 This may be useful: (defun ListUnloadedXrefs ( / ret) (vlax-for blk (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object))) (if (and (= :vlax-true (vla-get-isxref blk)) (not (vla-get-xrefdatabase blk)) ) (setq ret (cons (vla-get-name blk) ret)) ) ) (reverse ret) ) Hi Roy. Thank you ,But I test , not succeed ! I use acad2011 & 2015 test , The same error: ; error: Automation Error. Description was not provided. Quote
DuanJinHui Posted August 16, 2016 Author Posted August 16, 2016 (edited) Another, using Vanilla:(defun unloadedxrefs ( / r x ) (while (setq x (tblnext "block" (not x))) (if (= 4 (logand (cdr (assoc 70 x)) 36)) (setq r (cons (cdr (assoc 2 x)) r)) ) ) (reverse r) ) _$ (unloadedxrefs) ("xref") Lee, Thank you very much! gooooooooood!!! like this ? (defun c:xr ( ) (if (unloadedxrefs) (progn (foreach x (LM:listbox "Select reference file to be Reloaded" (unloadedxrefs) 1) (command "-xref" "R" x) ) (prompt "\nFiles have been Reloaded:") ) (prompt "\nNo reference file need reload.") ) (princ) ) Edited August 16, 2016 by DuanJinHui Edited code Quote
Roy_043 Posted August 16, 2016 Posted August 16, 2016 Hi Roy. Thank you ,But I test , not succeed ! I use acad2011 & 2015 test , The same error: ; error: Automation Error. Description was not provided. Strange. I am not sure why you are getting this. Did you include this in your code?: (vl-load-com) Quote
DuanJinHui Posted August 16, 2016 Author Posted August 16, 2016 Strange. I am not sure why you are getting this. Did you include this in your code?: (vl-load-com) Hi Roy, I did. Quote
Lee Mac Posted August 16, 2016 Posted August 16, 2016 Lee, Thank you very much! gooooooooood!!! You're welcome! like this ? (defun c:xr ( ) (if (unloadedxrefs) (progn (foreach x (LM:listbox "Select reference file to be Reloaded" (unloadedxrefs) 1) (command "-xref" "R" x) ) (prompt "\nFiles have been Reloaded:") ) (prompt "\nNo reference file need reload.") ) (princ) ) Yes, that would work - you could improve the efficiency slightly by storing the list of unloaded xrefs using a local variable, e.g.: (defun c:xr ( / lst ) (if (setq lst (unloadedxrefs)) (progn (foreach x (LM:listbox "Select reference file to be Reloaded" lst 1) < ... > Quote
DuanJinHui Posted August 16, 2016 Author Posted August 16, 2016 You're welcome! Yes, that would work - you could improve the efficiency slightly by storing the list of unloaded xrefs using a local variable, e.g.: (defun c:xr ( / lst ) (if (setq lst (unloadedxrefs)) (progn (foreach x (LM:listbox "Select reference file to be Reloaded" lst 1) < ... > Lee,Thank you again.Very helpful. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.