PDA

View Full Version : lisp routine which will pick specific layers & bring to front


VBOYAJI
2006-07-13, 05:43 PM
Hello,

I need your help with a lisp routine.

Currently in my drawing i have to goto Qselect,
1. Apply to "Entire drawing"
2. Object type "Multiple"
3. Properties "layer"
4. Value " layer name"
5. Bring to front

I would like to accomplish this task automatically. I am working with shape map files which the text layers go behind the map. So, i would have to use qselect to pick the text layers and bring to front. I am trying to do this automatically. I would appreciate it if someone can help me with this situation.

thanks

CAB2k
2006-07-13, 06:37 PM
I modified one of my selection routines for you.
See if it works for you.
;; 07/13/2006
;; Modified to set selected objects to Front
;; Changed name to Lay2F.lsp


;;=============================================================
;; Sel.lsp by Charles Alan Butler
;; Copyright 2004
;; by Precision Drafting & Design All Rights Reserved.
;; Contact at ab2draft@TampaBay.rr.com
;;
;; Version 1.0 Beta July 23,2004
;; Version 1.1 Beta July 13,2005
;;
;; Creates a selection set of objects on a layer(s)
;; User picks objects to determine the layer(s)
;; Then User selects objects for ss or presses enter to
;; get all objects on the selected layer(s)
;; You may select the selection set before starting this
;; routine. Then select the layers to keep in the set
;;=============================================================

(defun c:lay2f (/ ent lay ss lay:lst lay:prompt ss:first ent:lst)
;; get anything already selected
(setq ss:first (cadr(ssgetfirst))
ss (ssadd))

;; Get user selected layers
(if ss:first
(setq lay:prompt "nSelect the object to choose layers to keep.")
(setq lay:prompt "nSelect object for layer filter.")
)
(while (setq ent (entsel lay:prompt))
(setq ent:lst (cons (car ent) ent:lst))
(setq lay:lst
(cons (setq lay (cdr(assoc 8 (entget (car ent))))) lay:lst))
(prompt (strcat "n*-* Selected Layer -> " lay))
)
;; Un HighLite the entities
(and ent:lst (mapcar '(lambda (x) (redraw x 4)) ent:lst))

(if (> (length lay:lst) 0); got layers to work with
(progn
(setq lay "")
(setq lay:lst (vl-sort lay:lst '<)) ; removes douplicates
(foreach itm lay:lst ; combine lay names into one , del string
(setq lay (strcat lay itm ",")))
(setq lay (substr lay 1 (1- (strlen lay)))); remove the last ,
(if ss:first ; ALREADY GOT SELECTION SET
(while (setq ent (ssname ss:first 0))
(if (member (cdr(assoc 8 (entget ent))) lay:lst)
(ssadd (ssname ss:first 0) ss)
)
(ssdel (ssname ss:first 0) ss:first)
)
(progn ; else get a selection set to work with
(prompt (strcat "nOK >>--> Select objects for Selection set or "
"ENTER for All objects on layer(s) " lay))
;; get objects using filter with user select
(if (null (setq ss (ssget (list (cons 8 lay)))))
;; or get ALL objects using filter
(setq ss (ssget "_X" (list (cons 8 lay))))
)
)
)
(if (> (sslength ss) 0)
(command ".DRAWORDER" ss "" "F")
(prompt "n*** Nothing Selected ***")
)
)
)
(princ)
)
(prompt "nSelect on Layer loaded, Enter Sel to run.")
(princ)

peter
2006-07-13, 11:42 PM
One way is like this.

(command "draworder" (ssget "x" (list (cons 0 "*text")(cons 8 "layer name"))) "" "f")

VBOYAJI
2006-07-13, 11:44 PM
How would execute this.

peter
2006-07-14, 10:34 PM
either cut and paste it into the command line or

Create a lisp test.lsp file from this and load it when you open the drawing

(load "test")

(defun C:Test () (command "draworder" (ssget "x" (list (cons 0 "*text")(cons 8 "layer name"))) "" "f"))