samifox Posted February 23, 2013 Share Posted February 23, 2013 Hello How can i code autolisp script to toggle freeze/thaw specific layer? If x layer is frozen thaw it and vise versa Thanks Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted February 23, 2013 Share Posted February 23, 2013 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) Quote Link to comment Share on other sites More sharing options...
samifox Posted February 23, 2013 Author Share Posted February 23, 2013 Awesome lee can u please explain (I'm a new dummy) Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted February 23, 2013 Share Posted February 23, 2013 Awesomelee can u please explain (I'm a new dummy) You're welcome. Which part of the code are you unsure of? Quote Link to comment Share on other sites More sharing options...
samifox Posted February 23, 2013 Author Share Posted February 23, 2013 all those starting with vlax Quote Link to comment Share on other sites More sharing options...
samifox Posted February 23, 2013 Author Share Posted February 23, 2013 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? Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted February 23, 2013 Share Posted February 23, 2013 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 Quote Link to comment Share on other sites More sharing options...
samifox Posted February 23, 2013 Author Share Posted February 23, 2013 Thanks Lee I'm totally lst with your last paragraph Quote Link to comment Share on other sites More sharing options...
samifox Posted April 28, 2015 Author Share Posted April 28, 2015 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 ? Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted April 28, 2015 Share Posted April 28, 2015 Please see my explanation here. Lee Quote Link to comment Share on other sites More sharing options...
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.