Jump to content

Question : Select objects on the reference file to be Reloaded


DuanJinHui

Recommended Posts

Posted

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.

 

 

listbox.png

Posted

How get the unload xref list ?

Posted

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)
)

Posted

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")

Posted
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.

Posted (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!!! :D

 

like this ? :lol:

(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 by DuanJinHui
Edited code
Posted
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)

Posted
Strange. I am not sure why you are getting this.

 

Did you include this in your code?:

(vl-load-com)

 

Hi Roy, I did.

Posted
Lee, Thank you very much! gooooooooood!!! :D

 

You're welcome!

 

like this ? :lol:

(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)
               < ... >

Posted
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.

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...