PDA

View Full Version : Routine to place all Xrefs at Back of Draworder


LloydMiller
2006-12-11, 03:24 PM
I would like to create a routine that either when my drawing opens it sets all my xrefs to back, then brings any other objects or certain layers to front. I’m new at putting these together. I have no idea how to start this. Could someone please help assist me with this?

Lions60
2006-12-11, 03:43 PM
Give this a try it may be what you want.


(defun c:dorder ()
(setq cmdecho (getvar "cmdecho"))
(setvar "cmdecho" 0)
(setq xref (ssget "X" '((0 . "INSERT"))))
(command "draworder" xref"" "b")
(setvar "cmdecho" cmdecho)
)

Also note that this program takes all inseted objects and sets the draw order to back. So not only does it do xref's it also does blocks and anything else you insert into a drawing.
If you knew the names of the xref's you wanted the draw order to be set to then the program could be filtered to only do those.

LloydMiller
2006-12-11, 08:41 PM
could it be set to a layer? We put all Xrefs on a BG layer. Also I would want this to run before the job is printed. If it could run by the drawing opening that would be good

Lions60
2006-12-11, 09:25 PM
Give this a try. THis should get everything that is on layer BG and set the draw order to back. To have this run automatically whenever you open a drawing just put the lisp in you Acad support directory. Then (depending on your version of autocad) under autocad2006doc.lsp at the ver bottom of that file insert this text and save it (load "dorder.lsp")(c:dorder). I know there are other ways to do this put this is how i have it load with every drawing.


(defun c:dorder ()
(setq cmdecho (getvar "cmdecho"))
(setvar "cmdecho" 0)
(setq xref (ssget "X" '((8 . "BG"))))
(command "draworder" xref"" "b")
(setvar "cmdecho" cmdecho)
)

Opie
2006-12-11, 09:30 PM
Give this a try. THis should get everything that is on layer BG and set the draw order to back. To have this run automatically whenever you open a drawing just put the lisp in you Acad support directory. Then (depending on your version of autocad) under autocad2006doc.lsp at the ver bottom of that file insert this text and save it (load "dorder.lsp")(c:dorder). I know there are other ways to do this put this is how i have it load with every drawing.


(defun c:dorder ()
(setq cmdecho (getvar "cmdecho"))
(setvar "cmdecho" 0)
(setq xref (ssget "X" '((8 . "BG"))))
(command "draworder" xref"" "b")
(setvar "cmdecho" cmdecho)
)
It is not recommend to edit any of the Autodesk supplied files to load your custom routines. Use the ACADDOC.LSP or ACAD.LSP (user created files) instead. This will reduce your headaches when upgrading from one version to the next.

planview
2006-12-12, 09:26 AM
;;send various items back in forth in the drawing with draw order and filter commands
===================================================================================================================================================
(setvar "cmdecho" 0)


(setq ss1 (ssget "X" '((2 . "floorpln"))))
(cond (ss1 ;if there is a selection set, then proceed
(command ".draworder" ss1 "" "back")
)
(t ;else exit the routine without forcing an error call
)
)
(princ)

===================================================================================================================================================

(setq ss2 (ssget "X" '((-4 . "<or")(0 . "hatch")(0 . "solid")(0 . "mline")(-4 . "or>"))))
(cond (ss2 ;if there is a selection set, then proceed
(command ".draworder" ss2 "" "back")
)
(t ;else exit the routine without forcing an error call
)
)
(princ)


===========================================================================================


(setq ss3 (ssget "X" '((8 . "1MASONRY"))))
(cond (ss3 ;if there is a selection set, then proceed
(command ".draworder" ss3 "" "front")
)
(t ;else exit the routine without forcing an error call
)
)
(princ)

===================================================================================================================================================

(setq ss4 (ssget "X" '((-4 . "<or")(8 . "1text")(8 . "1empty")(-4 . "or>"))))
(cond (ss4 ;if there is a selection set, then proceed
(command ".draworder" ss4 "" "front")
)
(t ;else exit the routine without forcing an error call
)
)
(princ)


===================================================================================================================================================

(command "regenall")
(princ)

[ Moderator Action = ON ] What are [ CODE ] tags... (http://forums.augi.com/misc.php?do=bbcode#code) [ Moderator Action = OFF ]