Jump to content

Xref Draworder


Shoey

Recommended Posts

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

Link to comment
Share on other sites

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)

Link to comment
Share on other sites

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