0 Members and 1 Guest are viewing this topic.
(command "_.-Layer" "lock" "grid,mark" "freeze" "grid,mark" "")
How do I set one of several layers locked.
Quote from: jlogan02 on December 02, 2019, 07:00:08 PMHow do I set one of several layers locked.MaybeCode - Auto/Visual Lisp: [Select](defun _addlayer (name color flag ltype plot) (cond ((not (tblsearch "layer" name)) (entmakex (list '(0 . "LAYER") '(100 . "AcDbSymbolTableRecord") '(100 . "AcDbLayerTableRecord") (if (> flag 0) (cons 70 flag) '(70 . 0)) ;;;referencing group code 70 here. The flag for a locked layer is 4. (cons 2 name) (cons 62 color) (cons 6 (cond ((tblobjname "ltype" ltype)) ("continuous") ) ) (cons 290 plot) ;;1 = plottable 0 = not=plottable );; end list );; end entmake );; tblsearch ((tblobjname "layer" name)) );; cond );; end _addlayer (_addlayer "layername" 1 4 "continous" 1) ;;indicate flag as 4 )
Example: To lock and freeze the grid and mark layers (if you're not averse to using "command"):Code: [Select](command "_.-Layer" "lock" "grid,mark" "freeze" "grid,mark" "")Separate layer names with commas and no spaces.Steve
Another one:Code - Auto/Visual Lisp: [Select](defun t1 (/ adoc) (vla-startundomark (setq adoc (vla-get-activedocument (vlax-get-acad-object)))) (foreach item '("layer1" "layer2" "layer3") (vl-catch-all-apply (function (lambda () (vla-put-lock (vla-item (vla-get-layers adoc) item) :vlax-true))) ) ;_ end of vl-catch-all-apply ) ;_ end of foreach (vla-endundomark adoc) ) ;_ end of defun
Creating Layer State las files that can easily be imported into any drawing or template is another option. They can be applied to a Viewport to create overrides as well. They can also be imported from DWG's, DWT's & DWS's.