SunnyTurtle Posted October 5, 2011 Posted October 5, 2011 Hi i want to have a lisp that will freeze layer batters in the drawing batters but i don't want it to do it any where else. even if i run the lisp Heres what iv got so far (setq dn (getvar 'DWGNAME)) (if (= dn "batters.dwg") (command "-layers" "F" "BATTERS") );if this won't work what am i doing wrong. Quote
paulmcz Posted October 5, 2011 Posted October 5, 2011 (command "-layer"........... not "-layers" Quote
alanjt Posted October 5, 2011 Posted October 5, 2011 The use of command is going to be slower than ent* or vla, but it's more than sufficient. For command usage, here's what I'd do... (if (and (eq (strcase (getvar 'DWGNAME)) "BATTERS.DWG") ;capitalize to ignore case (tblsearch "LAYER" "BATTERS") ;check if layer exists (not really necessary) ) (if (eq (strcase (getvar 'CLAYER)) "BATTERS") ;check if current layer is "BATTERS" (command "_.-layer" "_T" "0" "_S" "0" "_F" "BATTERS" "") ; if so, thaw/set 0 as current and freeze layer (command "_.-layer" "_F" "BATTERS" "") ; freeze layer ) ) Quote
Tharwat Posted October 5, 2011 Posted October 5, 2011 Codes and not command call . (if (and (eq (strcase (getvar 'DWGNAME)) "BATTERS.DWG") (tblsearch "LAYER" "BATTERS") ) (progn (setq l (entget (tblobjname "LAYER" "BATTERS"))) (entmod (subst (cons 70 1) (assoc 70 l) l)) ) ) Tharwat Quote
alanjt Posted October 5, 2011 Posted October 5, 2011 Codes and not command call . (if (and (eq (strcase (getvar 'DWGNAME)) "BATTERS.DWG") (tblsearch "LAYER" "BATTERS") ) (progn (setq l (entget (tblobjname "LAYER" "BATTERS"))) (entmod (subst (cons 70 1) (assoc 70 l) l)) ) ) Tharwat I hope the layer isn't locked, current, etc.You might benefit from reading about the additional properties stored in dxf 70 for layers. Quote
Lee Mac Posted October 5, 2011 Posted October 5, 2011 I hope the layer isn't locked, current, etc.You might benefit from reading about the additional properties stored in dxf 70 for layers. 1+ Read up on the use of such functions as logand / logior / boole etc. Quote
Tharwat Posted October 5, 2011 Posted October 5, 2011 I hope the layer isn't locked, current, etc.You might benefit from reading about the additional properties stored in dxf 70 for layers. 1+ Read up on the use of such functions as logand / logior / boole etc. This is two in one (if (and (eq (strcase (getvar 'DWGNAME)) "BATTERS.DWG") (tblsearch "LAYER" "BATTERS") ) (progn (cond ((eq (strcase (getvar 'clayer)) "BATTERS") (setvar 'clayer "0") ) ) (setq l (entget (tblobjname "LAYER" "BATTERS"))) (if (eq (logand 4 (cdr (assoc 70 l))) 4) (entmod (subst (cons 70 0) (assoc 70 l) l)) ) (entmod (subst (cons 70 1) (assoc 70 l) l)) ) ) Quote
alanjt Posted October 5, 2011 Posted October 5, 2011 This is two in one (if (and (eq (strcase (getvar 'DWGNAME)) "BATTERS.DWG") (tblsearch "LAYER" "BATTERS") ) (progn (cond ((eq (strcase (getvar 'clayer)) "BATTERS") (setvar 'clayer "0") ) ) (setq l (entget (tblobjname "LAYER" "BATTERS"))) (if (eq (logand 4 (cdr (assoc 70 l))) 4) (entmod (subst (cons 70 0) (assoc 70 l) l)) ) (entmod (subst (cons 70 1) (assoc 70 l) l)) ) ) I give up. I'm not sure why the need was felt to over complicate this thread for a beginning LISPER in the first place. Quote
Lee Mac Posted October 5, 2011 Posted October 5, 2011 This is two in one What if the layer is frozen in new viewports? Or XRef dependent? Or indeed if any other Group 70 bit-codes are set? Quote
Tharwat Posted October 5, 2011 Posted October 5, 2011 [ATTACH=CONFIG]30403[/ATTACH][ATTACH=CONFIG]30404[/ATTACH][ATTACH=CONFIG]30403[/ATTACH] I give up. I'm not sure why the need was felt to over complicate this thread for a beginning LISPER in the first place. Were not you the first adviser for all these steps ? Quote
alanjt Posted October 5, 2011 Posted October 5, 2011 Were not you the first adviser for all these steps ? Yes and I kept it simple and as close to his coding as possible. Quote
Tharwat Posted October 5, 2011 Posted October 5, 2011 What if the layer is frozen in new viewports? Or XRef dependent? Or indeed if any other Group 70 bit-codes are set? OMG ........ Quote
Lee Mac Posted October 5, 2011 Posted October 5, 2011 To remove confusion for the OP, here is one way to approach the problem using entmod: (defun c:test ( / e ) (if (and (eq (strcase (getvar 'DWGNAME)) "BATTERS.DWG") (setq e (tblobjname "LAYER" "BATTERS")) ) (progn (if (eq "BATTERS" (strcase (getvar 'CLAYER))) (setvar 'CLAYER "0") ) (setq e (entget e)) (entmod (subst (cons 70 (logior 1 (cdr (assoc 70 e)))) (assoc 70 e) e)) ) ) (princ) ) Quote
alanjt Posted October 5, 2011 Posted October 5, 2011 Don't forget to account for 0 being frozen.....we're are over complicating this. Quote
Lee Mac Posted October 5, 2011 Posted October 5, 2011 Don't forget to account for 0 being frozen.....we're are over complicating this. Good catch. Solution: (defun c:test ( / e l ) (if (and (eq (strcase (getvar 'DWGNAME)) "BATTERS.DWG") (setq e (tblobjname "LAYER" "BATTERS")) ) (progn (if (eq "BATTERS" (strcase (getvar 'CLAYER))) (progn (setq l (entget (tblobjname "LAYER" "0"))) (entmod (subst (cons 70 (boole 4 1 (cdr (assoc 70 l)))) (assoc 70 l) l)) (setvar 'CLAYER "0") ) ) (setq e (entget e)) (entmod (subst (cons 70 (logior 1 (cdr (assoc 70 e)))) (assoc 70 e) e)) ) ) (princ) ) But I agree - "-Layer" is far easier for this task. Quote
SunnyTurtle Posted October 5, 2011 Author Posted October 5, 2011 Thanks guys for your help. But if i wanted to repeat a freeze of multible layer with the condition of drawing name. Is there a way to include an simple user interface like an excel sheet. Sunny P.S this is my completed code ( (if (and (eq (strcase (getvar 'DWGNAME)) "GLRL-01DC-DWG-PW-GE-SMC-0202-A.DWG") ;ADD DWG NAME HERE IN CAPITALS ) (if (eq (strcase (getvar 'CLAYER)) "X_PW_GE_SMC_LS_GINT|DP_BH103") ;ADD LAYER NAME HERE IN CAPITALS (command "_.-layer" "_T" "0" "_S" "0" "_F" "X_PW_GE_SMC_LS_GINT|DP_BH103" "") ;ADD LAYER NAME HERE IN CAPITALS (command "_.-layer" "_F" "X_PW_GE_SMC_LS_GINT|DP_BH103" "") ;ADD LAYER NAME HERE IN CAPITALS ) ) (if (and (eq (strcase (getvar 'DWGNAME)) "GLRL-01DC-DWG-PW-GE-SMC-0210-A.DWG") ;ADD DWG NAME HERE IN CAPITALS ) (if (eq (strcase (getvar 'CLAYER)) "X_PW_GE_SMC_LS_GINT|DP_BH103") ;ADD LAYER NAME HERE IN CAPITALS (command "_.-layer" "_T" "0" "_S" "0" "_F" "X_PW_GE_SMC_LS_GINT|DP_TP17" "") ;ADD LAYER NAME HERE IN CAPITALS (command "_.-layer" "_F" "X_PW_GE_SMC_LS_GINT|DP_TP17" "") ;ADD LAYER NAME HERE IN CAPITALS ) ) (if (and (eq (strcase (getvar 'DWGNAME)) "GLRL-01DC-DWG-PW-GE-SMC-0215-A.DWG") ;;ADD DWG NAME HERE IN CAPITALS ) (if (eq (strcase (getvar 'CLAYER)) "X_PW_GE_SMC_LS_GINT|SB_24") ;ADD LAYER NAME HERE IN CAPITALS (command "_.-layer" "_T" "0" "_S" "0" "_F" "X_PW_GE_SMC_LS_GINT|SB_24" "") ;ADD LAYER NAME HERE IN CAPITALS (command "_.-layer" "_F" "X_PW_GE_SMC_LS_GINT|SB_24" "") ;ADD LAYER NAME HERE IN CAPITALS ) ) ) and yes i relise that i am still using command call just give me a couple of day to look over you code entrys Quote
Lee Mac Posted October 6, 2011 Posted October 6, 2011 and yes i relise that i am still using command call just give me a couple of day to look over you code entrys Don't worry about using the Command call! It is more than sufficient for your purpose 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.