Jump to content

Recommended Posts

Posted

Hello

 

 

How can i code autolisp script to toggle freeze/thaw specific layer?

 

If x layer is frozen thaw it and vise versa

 

Thanks

Posted

Here is a simple example:

(defun c:ftog ( / layer l )
   (setq layer "0") ;; Layer to Freeze/Thaw
   (cond
       (   (= (strcase (getvar 'clayer)) (strcase layer))
           (princ "\nCannot freeze the current layer.")
       )
       (   (setq l (tblobjname "LAYER" layer))
           (setq l (vlax-ename->vla-object l))
           (vlax-put l 'freeze (~ (vlax-get l 'freeze)))
       )
       (   (princ (strcat "\nLayer " layer " does not exist.")))
   )
   (princ)
)
(vl-load-com) (princ)

Posted

Awesome

lee can u please explain (I'm a new dummy)

Posted
Awesome

lee can u please explain (I'm a new dummy)

 

You're welcome.

Which part of the code are you unsure of?

Posted

and Lee...

 

i excecute your code..

when trying to toggle on i have to regen so the objects re-appear

 

how can i regenerate in the code?

Posted
8) all those starting with vlax

 

The vlax-ename->vla-object function converts the LAYER entity to a VLA-Object which may then be manipulated using its ActiveX Properties & Methods, rather than manipulating the DXF Group codes of the LAYER entity.

 

I am then manipulating the Freeze property of the VLA Layer Object using the undocumented vlax-get / vlax-put functions, since these functions return native AutoLISP data types, rather than the Visual LISP :vlax-true / :vlax-false symbols as returned by vlax-get-property or vla-get-freeze.

 

As for the toggle itself, consider:

_$ (~ 0)
-1
_$ (~ -1)
0

Posted

Thanks Lee

 

I'm totally lst with your last paragraph

  • 2 years later...
Posted
The vlax-ename->vla-object function converts the LAYER entity to a VLA-Object which may then be manipulated using its ActiveX Properties & Methods, rather than manipulating the DXF Group codes of the LAYER entity.

 

 

As for the toggle itself, consider:

_$ (~ 0)
-1
_$ (~ -1)
0

 

what did you mean by that Lee ?

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