Shoey Posted November 27, 2017 Share Posted November 27, 2017 Hi All I was recently scouting usual Lisp forums for code that would display a dialog box with a list of Xrefs in the current drawing. And within the dialog box, there would be a 'Move Up' , 'Move down' option to arrange the order of Xrefs. I was not succesfull in finding one so if anybody is aware of one, that would be appreciated. What i have done using code (created by others) and Doslib (so you need this loaded), is to have a go at the program myself. See below: ;;ronjonp October 2009 (defun xrb (name / doc e ms n o sorttbl ss xdic) (vl-load-com) (setq xdic (vla-getextensiondictionary (setq ms (vla-get-modelspace (setq doc (vla-get-activedocument (vlax-get-acad-object))) ) ) ) ) (if (vl-catch-all-error-p (setq sorttbl (vl-catch-all-apply 'vla-getobject (list xdic "ACAD_SORTENTS"))) ) (setq sorttbl (vla-addobject xdic "ACAD_SORTENTS" "AcDbSortentsTable")) ) (setq n -1) (if (setq ss (ssget "_X" (list (cons 2 name)))) (progn (while (setq e (ssname ss (setq n (1+ n)))) (vlax-invoke sorttbl 'movetobottom (list (vlax-ename->vla-object e))) ) (vla-regen doc acallviewports) ) ) (princ) ) ;;http://www.afralisp.net/archive/Tips/code66.htm (vl-load-com) (setq activedocument (vla-get-activedocument (vlax-get-Acad-Object))) (setq theblocks (vla-get-blocks activedocument)) (setq theList '()) (vlax-for item theblocks ;check if it's an Xref (setq yesxref (vlax-get-property item 'isXref)) ;if it is (if (= yesxref :vlax-true) ;do the following (progn ;get the Xref name (setq ablock (vlax-get-property item 'Name)) ;store it in the list (setq theList (append (list ablock) theList)) );progn );if );vlax-for (setq xreflist (dos_orderlist "Xrefs" "Drag to reorder Xrefs" theList)) (foreach xf xreflist (xrb xf)) This seems to work ok, however the list of xrefs created contains unloaded, nested and not found xrefs. Is it possible to obtain only a list of 'loaded' xrefs? Also does anyone know if it is possible to get the xrefs in an existing draworder list? So that the xref list shows the loaded Xrefs and the current draworder that each Xref is in the drawing? Many thanks Quote Link to comment Share on other sites More sharing options...
Shoey Posted November 27, 2017 Author Share Posted November 27, 2017 Sorry - Having problems wrapping tags around the code. I did select the code tags around the code, but it does not appear to have worked. Quote Link to comment Share on other sites More sharing options...
SLW210 Posted November 28, 2017 Share Posted November 28, 2017 You can do them manually. [NOPARSE] Your Code Here[/NOPARSE] = Your Code Here Quote Link to comment Share on other sites More sharing options...
ronjonp Posted November 28, 2017 Share Posted November 28, 2017 Hi All... Is it possible to obtain only a list of 'loaded' xrefs? ... Many thanks This should do what you want: (defun _xrefs (/ n out) (vlax-for b (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object))) (if (minusp (vlax-get b 'isxref)) (if (= 32 (logand 32 (cdr (assoc 70 (entget (tblobjname "block" (setq n (vla-get-name b)))))))) (setq out (cons n out)) ) ) ) (vl-sort out '<) ) (_xrefs) Quote Link to comment Share on other sites More sharing options...
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.