ahyin Posted August 11, 2010 Posted August 11, 2010 Dear all, I would like to freeze all layers but I don't the code is, I know if I turn off all layer by this, (vlax-for item theLayers (vlax-put-property item "LayerON" ':vlax-false)) but when I try to use (vlax-for item theLayers (vla-put-freeze item :vlax-true)) it got error. Regards Quote
MSasu Posted August 11, 2010 Posted August 11, 2010 Please don't forget that you cannot freeze the current layer. So you should filter it out from that list - may list it by CLAYER system variable. Regards, Quote
David Bethel Posted August 11, 2010 Posted August 11, 2010 Why not use the standard command? (command "_.LAYER" "_Freeze" (strcat "~" (getvar "CLAYER')) "") I'm seeing more and more of avoiding a command for no real reason. My $0.02 -David Quote
ahyin Posted August 11, 2010 Author Posted August 11, 2010 thanks ! msasu. but how to write this code, forgive me I'm new in lisp. I got the following error message. Command: (vlax-for item theLayers (vla-put-freeze item :vlax-true)) *Cancel* Automation Error. Invalid layer Quote
MSasu Posted August 11, 2010 Posted August 11, 2010 I suppose that the theLayers variable is a list holding layers entities, so you should ensure that skip current layer by comparing his name with the one stored in CLAYER system variable: (vlax-for item theLayers (if (not (equal (vla-get-name item) (getvar "CLAYER"))) (vla-put-freeze item :vlax-true))) Regards, Quote
Tharwat Posted August 11, 2010 Posted August 11, 2010 Try the following in sequence with no Lisp at all, and what's more. It will freeze all layers except the current one ; -layer F<enter> *<enter> <enter> <enter> Very simple ..... Regards, Tharwat Quote
ahyin Posted August 11, 2010 Author Posted August 11, 2010 Thanks ! msasu. I suppose that the theLayers variable is a list holding layers entities, so you should ensure that skip current layer by comparing his name with the one stored in CLAYER system variable: (vlax-for item theLayers (if (not (equal (vla-get-name item) (getvar "CLAYER"))) (vla-put-freeze item :vlax-true))) Regards, Quote
Se7en Posted August 11, 2010 Posted August 11, 2010 Why not use the standard command? (command "_.LAYER" "_Freeze" (strcat "~" (getvar "CLAYER')) "") I'm seeing more and more of avoiding a command for no real reason. My $0.02 -David *hehe* yeah i noticed the same thing. But David, dont you know that the other stuff is fancy!? Its just `clean' and `good-er' and `cooler'. I mean come on man, get with the times! *lol* Quote
Se7en Posted August 11, 2010 Posted August 11, 2010 Here is a quickie ( (lambda (/ layer) ;; ;; (ex) Freeze all layers in drawing using Visual Lisp. ;; ;; NOTE: This will be slower then other methods i would use. ;; I would not use this in my code. ;; ;; By: Se7en ;; 08.11.10 08:18:00 AM ;; (vlax-for layer (vla-get-layers (vla-get-activedocument (vlax-get-acad-object))) (if (and (vlax-get-property layer 'Freeze) (not (eq (vlax-get-property layer 'Name) (getvar 'clayer))) ) (vlax-put-property layer 'Freeze :vlax-true)))) ) Quote
Lee Mac Posted August 11, 2010 Posted August 11, 2010 My offering: (defun c:FreezeAll ( / def ) ;; © Lee Mac 2010 (while (setq def (tblnext "LAYER" (not def))) ( (lambda ( elist ) (if elist (entupd (cdr (assoc -1 (entmod (subst (cons 70 (boole 7 1 (cdr (assoc 70 elist) ) ) ) (assoc 70 elist) elist ) ) ) ) ) ) ) (cond ( (eq (getvar 'clayer) (cdr (assoc 2 def))) nil ) ( (entget (tblobjname "LAYER" (cdr (assoc 2 def) ) ) ) ) ) ) ) (princ) ) Quote
David Bethel Posted August 11, 2010 Posted August 11, 2010 *hehe* yeah i noticed the same thing. But David, dont you know that the other stuff is fancy!? Its just `clean' and `good-er' and `cooler'. I mean come on man, get with the times! *lol* We must just be showing our age..... and I get in trouble every time I try to be fancy -David Quote
KRBeckman Posted August 16, 2010 Posted August 16, 2010 Why not use the standard command? (command "_.LAYER" "_Freeze" (strcat "~" (getvar "CLAYER')) "") I'm seeing more and more of avoiding a command for no real reason. My $0.02 -David K.I.S.S., I like this one. Quote
Tharwat Posted August 16, 2010 Posted August 16, 2010 Why not use the standard command? (command "_.LAYER" "_Freeze" (strcat "~" (getvar "CLAYER[color="red"]'[/color])) "") I'm seeing more and more of avoiding a command for no real reason. My $0.02 -David Please notice the quote which highlighted above. Quote
racs007 Posted August 8, 2014 Posted August 8, 2014 Why not use the standard command? (command "_.LAYER" "_Freeze" (strcat "~" (getvar "CLAYER')) "") I'm seeing more and more of avoiding a command for no real reason. My $0.02 -David You save my life this sequence its perfect for my macro Thanks 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.