Jump to content

Recommended Posts

Posted

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

Posted

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,

Posted

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

Posted

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

Posted

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,

Posted

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

Posted

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,

Posted
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*

Posted

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)))) )

Posted

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)
)

Posted
*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

Posted
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.

Posted
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.

  • 3 years later...
Posted
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

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...