Message 1 of 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I found a lisp in this thread located here: visual-lisp-autolisp-and-general/possible-lisp that allowes me to switch to the next layer and freeze all the others. The lisp code is:
(defun c:NextLayer (/ ActDoc Layers CurLay OldLay LayList tmpPos) (vl-load-com) (command "cmdecho" (getvar "cmdecho")) (setq ActDoc (vla-get-ActiveDocument (vlax-get-Acad-Object))) (setq Layers (vla-get-Layers ActDoc)) (setq CurLay (getvar "clayer")) (setq OldLay (vla-item Layers CurLay)) (vlax-for Lay Layers (setq LayList (cons (vla-get-Name Lay) LayList)) (if (/= (vla-get-Name Lay) CurLay) (vla-put-LayerOn Lay :vlax-false) ) ) (setq LayList (vl-sort LayList '<)) (setq tmpPos (vl-position CurLay LayList)) (if (= (1+ tmpPos) (length LayList)) (progn (setq tmpPos -1) (prompt "\n Reached end of layers, starting over again.") ) ) (setq CurLay (vla-Item Layers (nth (1+ tmpPos) LayList))) (vla-put-Freeze CurLay :vlax-false) (vla-put-Lock CurLay :vlax-false) (vla-put-LayerOn CurLay :vlax-true) (setvar "clayer" (nth (1+ tmpPos) LayList)) (vla-put-LayerOn OldLay :vlax-false) (vla-Regen ActDoc acActiveViewport) (princ) )
This works great for going to the next layer, but I couldn't find a similiar lisp to go to the previous layer. Does anyone know of a lisp that can do this?
As a note, I have used laywalk, but with this program I can hotkey it to just cycle through layers as I wish.
Thanks!
Dan Nicholson C.I.D.
PCB Design Engineer
PCB Design Engineer
Solved! Go to Solution.