dnovember99 Posted November 17, 2017 Posted November 17, 2017 ok so i have a lisp that i use all the time and i wanted to see if someone would be able to help me out. i am wanting to add an additional part to this, if that is possible. when we run ELA - i can select a layer and everything on that layer will be isolated. you then can choice to delete either T-text S-select A-all on layer (or space bar) H-hatch. i wanted to find out if i can also have, the following: if everything has been deleted on the last layer you choose. to have it automatically purge that layer from the system? or should this just be something that i run purge once i am done using the command? thank you in advance for your help (defun c:ELA () (elay) (princ) );end ela (defun-q elay () ;;standard error handler ; (defun *Error*(msg / flag) ; (command "._undo" "end") ; (cond ; ((not msg)) ; ((member (strcase msg t) '("console break" "function cancelled" "quit / exit abort")) ; (setq flag t) ; ) ; ((princ (strcat "\nError: " msg)) ; (setq flag t) ; ) ; ) ; (setvar "clayer" clayOld);;restore system variable ; (if flag (fixelalayerstate)) ; (princ) ; );;end error handler (setq clayOld (getvar "clayer"));;capture system variable (load "lman") (setvar "cmdecho" 0) (setvar "menuecho" 3) (SetLayer1) (command "._undo" "end") ; (*Error* nil);;call error handler to restore environment (moder) );end elay (defun-q SetLayer1 () (setq elalayerstate "elalayerstate") (bns_sl elalayerstate) ; save layerstate (setq e (car (entsel "\Pick an object on the desired LAYER: "))) (if e (progn (setq e (entget e) n (cdr (assoc 8 e)) );close setq (command "layer" "s" n "") (princ (strcat "\nSelected item is on layer " n ": ")) (terpri) (LayerOff) ) ) );end setlayer1 (defun-q LayerOff () (command ".expert" "0" "layer" "off" "*" "" "") (SelectChoice) );end layeroff (defun-q SelectChoice () (setq killlist nil) (initget "All Select None Text Hatch") (setq ANS (getkword "What to erase? (A)ll on layer, (S)elect, (H)atch, (T)ext, or (N)one on layer : ")) (cond ((or (= ANS nil)(= ANS "All")) (command "layer" "lo" "*" "" "layer" "u" n "" "erase" "all" "") ) (( = ANS "Select") (command "select" pause "erase" "p" "") ) (( = ANS "None") (command "layer" "s" "0" "on" "*" "") ) (( = ANS "Text") (setq SStxt (ssget "X" (list (cons 0 "TEXT")(cons 8 n))))(princ) (command "erase" SStxt "") (setq SSmtxt (ssget "X" (list (cons 0 "MTEXT")(cons 8 n))))(princ) (command "erase" SSmtxt "") ) (( = ANS "Hatch") (setq SShtch (ssget "X" (list (cons 0 "HATCH")(cons 8 n))))(princ) (command "erase" SShtch "") (setq SSsold (ssget "X" (list (cons 0 "SOLID")(cons 8 n))))(princ) (command "erase" SSsold "") ) ) (ResetLay) );end Selectchoice (defun-q ResetLay () (fixelalayerstate) (SetLayer1) );end resetlay (defun-q fixelalayerstate () (bns_rl elalayerstate) ; restore layerstate (bns_dl elalayerstate) ; delete layerstate );defun Quote
Aftertouch Posted November 17, 2017 Posted November 17, 2017 In this part: (cond ((or (= ANS nil)(= ANS "All")) (command "layer" "lo" "*" "" "layer" "u" n "" "erase" "all" "") ) Add: (setvar "CLAYER" "0") (command "_PURGE" <add variables for layer 'n'>) <- I got no acces to CAD at the moment... Asuming layer 0 is not frozen. Since you cannor purge the current layer. :-) Quote
SLW210 Posted November 20, 2017 Posted November 20, 2017 Please read the Code Posting Guidelines and edit your Code to be included in Code Tags.[NOPARSE] Your Code Here[/NOPARSE] = Your Code Here Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.