LISP for Xref Draw order

LISP for Xref Draw order

nichkherbsman
Advocate Advocate
1,655 Views
2 Replies
Message 1 of 3

LISP for Xref Draw order

nichkherbsman
Advocate
Advocate

Hi,

I need help, I need lisp that arrange the draw order of xref in a dwg file. File that has multiple xref.

What I need is :

Xref 1 will be at the back of Xref 2

Xref 2 will be at the back of Xref 3

Xref 3 will be at the back of Xref 4

that,

Xref 4 will be in front of  Xref 3, 2 & 1

Xref 3 will be in front of Xref 2 & 1

Xref 2 will be in front of Xref 1

 

And I will just re-arrange the Xref file name in code if I want to change the draw order of Xref or if I attach new xref. 

 

Thank you.

 

drawoderXref.PNG

NiCHKCiD
BIM Modeler
Technical Officer
Technical Designer
Sr. Draftsman
0 Likes
Accepted solutions (1)
1,656 Views
2 Replies
Replies (2)
Message 2 of 3

ВeekeeCZ
Consultant
Consultant
Accepted solution

Perhaps like this.

 

(defun c:XrefDraworder ( / :Move1stXrefUnder2nd :SSXref)

  (defun :SSXref (name / ) (ssget "_A" (list '(0 . "INSERT") (cons 2 name))))

  (defun :Move1stXrefUnder2nd (mov ref / ss-ref ss-mov eco)
    (setq eco (getvar 'cmdecho)) (setvar 'cmdecho 0)
    (or (and (setq ss-ref (:SSXref ref))
	     (setq ss-mov (:SSXref mov))
	     (initcommandversion)
	     (vl-cmdf "_.DRAWORDER" ss-mov "" "_U" ss-ref "")
	     (princ (strcat "\nMoving '" mov "' under '" ref "' done."))
	     )
	(prompt (strcat "\nMoving '" mov "' under '" ref "' failed.")))
    (setvar 'cmdecho eco))

  ; -------------------------------------------------------------------------------------------------
  
  (:Move1stXrefUnder2nd "Xref3" "Xref4")
  (:Move1stXrefUnder2nd "Xref2" "Xref3")
  (:Move1stXrefUnder2nd "Xref1" "Xref2")

  (princ)
  )
0 Likes
Message 3 of 3

nichkherbsman
Advocate
Advocate

Thank you. I will try this lisp.

NiCHKCiD
BIM Modeler
Technical Officer
Technical Designer
Sr. Draftsman
0 Likes