Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Draw Order Routine

4 REPLIES 4
SOLVED
Reply
Message 1 of 5
nathanwheeler27
877 Views, 4 Replies

Draw Order Routine

Hi,

 

I have two simple routines that do the same thing. It just reorders every layer in my drawing to the order I want them in. The first one works and I found it on this forum. The second one does not work because one of the layers "3 SHEARWALLS" has a space in the name. I am new to LISP and trying to understand why this is an issue in my version and not the other one? 

 

(defun c:BDRAWORDER (/ layerList data ss)
  (foreach layer '( 
        "TEXT" 
        "DIMENSIONS"
        "0"
        "3 SHEARWALLS")
    (if (and (setq data (tblsearch "LAYER" layer)) ; layer exists
             (zerop (logand 4 (cdr (assoc 70 data)))) ; layer unlocked
             (setq ss (ssget "_X" (list (cons 8 layer)))) ; layer has objects
        )
      (command "_.draworder" ss "" "_back")
    )
  )
  (princ)
)

 

My version/attempt:

(defun SETLAYERORDER (sslist)
	(command "_DRAWORDER" sslist "" "_BACK")
)

(defun c:BDRAWORDER ()
	(SETLAYERORDER (ssget "X" '((8 . "TEXT")))) ; TOP LAYER
	(SETLAYERORDER (ssget "X" '((8 . "DIMENSIONS"))))
	(SETLAYERORDER (ssget "X" '((8 . "0"))))
	
	(SETLAYERORDER (ssget "X" '((8 . "3 SHEARWALLS"))))
)

 

4 REPLIES 4
Message 2 of 5

Space is not problem, but

You must use IF function

 

This is your style code....

 

(defun SETLAYERORDER (sslist)
	(command "_.draworder" sslist "" "_back")
)

(defun c:BDRAWORDER1 ()
	(if (setq ss (ssget "_X" '((8 . "TEXT"))))
		(SETLAYERORDER ss)
	)
	
	(if (setq ss (ssget "_X" '((8 . "DIMENSIONS"))))
		(SETLAYERORDER ss)
	)
	
	(if (setq ss (ssget "_X" '((8 . "0"))))
		(SETLAYERORDER ss)
	)
	
	(if (setq ss (ssget "_X" '((8 . "3 SHEARWALLS"))))
		(SETLAYERORDER ss)
	)
	
)

 

 

 

This is same function short method

 

(defun SETLAYERORDER (sslist)
	(command "_.draworder" sslist "" "_back")
)

(defun c:BDRAWORDER2 ()
	(if (setq ss (ssget "_X" (list (cons 8 "TEXT,DIMENSIONS,0,3 SHEARWALLS"))))
		(SETLAYERORDER ss)
	)
)

 

 

Message 3 of 5
Sea-Haven
in reply to: kajanthangavel

Draw order can affect the way the objects appear not sure using lay1,lay2,lay3 may give correct result can do the same using.

 

 

(foreach lay '(lay1 lay2 lay3)
(if (setq ss (ssget "_X" (list (cons 8 lay))))
.....

 

 For a particular situation I had the objects had to be done in a particular order to get the correct stacking effect.

Message 4 of 5
nathanwheeler27
in reply to: Sea-Haven

Thanks for your input. I am going to be using the routine with foreach, and it seems to be working.

Message 5 of 5
Sea-Haven
in reply to: nathanwheeler27

Glad to hear. For me it was image, wipeout, then text. Before after situation.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

AutoCAD Inside the Factory


Autodesk Design & Make Report