Custom keyboard shortcut for layer management
I know this will be a snap for someone out there:
I would like a keyboard shortcut that will turn off[or turn on with another key combination] a specific layer. That layer is named '_watermark'.
I have written one for when I want to change my snap points to tan only [^C^C_osmode;256;] but I just cannot figure out how to control layers with keyboard shortcuts. All help is greatly appreciated.
Re: Custom keyboard shortcut for layer management
I use a lisp by Jimmy Bergmark https://jtbworld.com/autocad-layer-toggle-freeze-lsp
Save the lisp anywhere in your support file search path and this macro should work:
Code:
^P(or layer-toggle-freeze(load "layer-toggle-freeze.lsp"))(layer-toggle-freeze '("_watermark"))
Re: Custom keyboard shortcut for layer management
Sorry for the delay in getting back but we had a customer that wanted to push up their project.
I couldn’t get your code to run without errors & wasn’t able to get time to debug. I ended up using a snip from the lee-mac site. Just a quick & dirty code - if unfrozen then freeze, and vica versa. Yes, there isn’t any error checking to see if the layer is there but I’m willing to live with it throwing a fit if I use it in a drawing without the layer.
Here what I use:
Code:
(defun FreezeThawLayer ( layer / dx en )
(setq en (tblobjname "LAYER" layer))
(setq en (entget en)
dx (assoc 70 en)
en (entmod (subst (cons 70 (boole 6 1 (cdr dx))) dx en))
)
(princ)
)
;and my keyboard shortcut macro
;^C^C^P(FreezeThawLayer "__watermark")
Re: Custom keyboard shortcut for layer management
Quote:
Originally Posted by
lynx_20
Sorry for the delay in getting back but we had a customer that wanted to push up their project.
I couldn’t get your code to run without errors & wasn’t able to get time to debug.
Did you save Jimmy Bergmark's code in a folder in the Support path? I use his code since it will toggle a list of layers at one time. I've modified it to import (using Lee's Steal From Drawing) or create layers as needed if they're not in the drawing.
Glad Lee Mac's Code worked for you. I use a lot of his code on a daily basis.
Code:
;;; toggle the freeze state of layer
;;; and regens only the objects on the layer
;;; but if layer is xref dependant it regens
;;;
;;; By Jimmy Bergmark
;;; Copyright (C) 1997-2006 JTB World, All Rights Reserved
;;; Website: www.jtbworld.com
;;; E-mail: info@jtbworld.com
;;; 2000-03-05 - First release
;;;
;;; Tested on AutoCAD 2000
;;; Argument: layer {list of layers}
;;; Example: (layer-toggle-freeze '("Layer1" "Layer2"))
(defun layer-toggle-freeze (layer / en f ss ent i fg)
(foreach la layer
(setq en (entget (tblobjname "layer" la)))
(setq f (cdr (assoc 70 en)))
(setq f (boole 6 f 1))
(if (and (wcmatch la "*|*") (eq 0 (logand 1 f))) (setq rg T))
(setq en (subst (cons 70 f) (assoc 70 en) en))
(entmod en)
(setq ss (ssget "X" (list (cons 8 la))))
(setq i 0)
(if ss
(while (setq ent (ssname ss i))
(entupd ent)
(setq i (1+ i))
)
)
)
(setq sset nil)
(if rg (command "._regenall"))
(princ)
)