;;;KETIV - Set, turn off, or freeze a layer based upon a seleced entity. ;;; LARBYENT.LSP ;;; ;;; KETIV Technologies, Inc. ;;; 6645 NE 78th Court #C2 ;;; Portland, OR 97218 ;;; ;;; Layer Group: None ;;; ;;; Menu Location: Tablet N1, N2, N3 ;;; ;;; Purpose: To set, turn off, or freeze a layer based upon a seleced entity ;;; ;;; Prompts: Off/Freeze/: ;;; | | | ;;; | | Select entity: ;;; | Select entity: ;;; | [If an entity on the current was selected] ;;; | Cannot freeze layer "name". It is the CURRENT layer. ;;; Select entity: ;;; [If an entity on the current was selected] ;;; Really want layer "name" (the CURRENT layer) off? : ;;; ;;; Assumptions/Limitations: NONE ;;; ;;;------------------------------------------------- ;;; Initialize memory and important system variables ;;; ;;;> Author: Henry C. Francis ;;;> 425 N. Ashe St. ;;;> Southern Pines, NC 28387 ;;;> http://paracadd.com ;;;> All rights reserved. ;;; ;;;> COPYRIGHT: 1986, 1987, 1988, 1989 by KETIV Technologies, Inc. ;;;> EDITED: 04-08-1997 ;;; (defun c:larbyent ( / lars var val typ ent layer test cnt) (setq clayer nil lars '() hdrlst '() ) ;------------------------ ; Store system variables ;------------------------ (mapcar '(lambda (var val) (setq hdrlst (cons (cons var (getvar var)) hdrlst)) (setvar var val) ) '("CmdEcho" "Expert") '(0 3) ) ;------------------------------------ ; Identify type of layer manipulation (setq typ (strcase (getstring "\nOff/Freeze/: "))) (if (= typ "") (setq typ "S")) (if (= typ "O") (setq typ "OFF")) ;------------------------------------- ; Identify objects to determine layers (if (= "S" (substr typ 1 1)) (progn (while (null (setq ent (entsel)))) (setq lars (cons (cdr (assoc 8 (entget (car ent)))) lars)) (command ".layer" "s" (car lars) "") (if (or(eq (strlen (car lars)) 7)(eq (strlen (car lars)) 11)) (progn (setq lar (car lars) mjrg (substr lar 1 1) llt (substr lar 2 1) prod (substr lar 3 4) );setq (if (eq (strlen (car lars)) 11) (setq modf (substr lar 8 4)) (setq modf nil) );if );progn );if ) (progn (while (not (and (not (setq ent (entsel) ) ) lars ) ) ;------------------------------- ; Determine layers to manipulate (if ent (progn (setq layer (cdr (assoc 8 (entget (car ent))))) (if (member layer lars) t (setq lars (cons layer lars))) (prompt (strcat " Layer " layer " selected.")) ) ) ) (setq clayer (getvar "clayer")) ;------------------------- ; Create layer text string (setq cnt 0 layer (nth cnt lars) layers "") (while layer (setq test (if (and (= layer clayer) (= (substr typ 1 1) "O")) (getstring (strcat "\nReally want layer " (strcat layer) " (the CURRENT layer) off? : ")) "Y" ) ) (if (and (= layer clayer) (= (substr typ 1 1) "F")) (progn (setq test "N") (prompt (strcat "\nCannot freeze layer " (strcase layer) ". It is the CURRENT layer.")) ) ) (if (= (substr (strcase test) 1 1) "Y") (setq layers (if (/= (substr layers 1 1) "") (strcat layers "," layer) layer) ) ) (setq cnt (1+ cnt) layer (nth cnt lars)) ) (if (/= (substr layers 1 1) "") (command ".layer" typ layers "")) ) ) ;------------------------------------------- ; Reset system variables and AutoLISP memory (foreach cnt hdrlst (setvar (car cnt) (cdr cnt))) (princ) ) (princ)