We have this Lisp Routine at our work, there's several variations of this routine we have, including lock, unlock and layer off.. the only problem i have with it is that it needs a selected object and cannot take a window or a crossing as an input type.
Code:
(defun c:LAYER-FREEZE (/ obj-source lay-name lay-lst lay-name)
(setvar "cmdecho" 0)
(while (setq obj-source
(entsel "\nPick an object on the layer to be freezed: ")
)
(setq obj-source (car obj-source))
(setq lay-name (cdr (assoc 8 (entget obj-source))))
(setq lay-lst (tblsearch "layer" lay-name))
(setq lay-name (cdr (assoc 2 lay-lst)))
(if (= lay-name (getvar "clayer"))
(alert (strcat "Cannot freeze layer" lay-name ". It is the CURRENT layer."))
(command "-layer" "f" lay-name "")
)
)
(setvar "cmdecho" 1)
(princ)
)
[ Moderator Action = ON ] What are [ CODE ] tags... [ Moderator Action = OFF ]