Locks or unlocks a layer.
Supported platforms: Windows only
Read-only: No
Type: Boolean
You cannot edit objects on a locked layer; however, they are still visible if the layer is on and thawed. You can make a locked layer active and you can add objects to it. You can also apply object snap modes to objects on locked layers. You can freeze and turn off locked layers and change their associated colors.
Locking is useful when you want to edit objects that are associated with particular layers but also want to view objects on other layers.
VBA:
Sub Example_Lock() ' This example creates a new layer called "Lock". ' It then displays the status of the Lock property ' for the new layer, toggles the status of the ' Lock property, and again displays its status. ' After running this example, you can check the layer ' control on the Object Properties tool bar. It will ' show the new layer and the latest Lock status. Dim layerObj As AcadLayer ' Create the new layer Set layerObj = ThisDrawing.Layers.Add("Lock") ' Display the Lock status of the new layer GoSub DISPLAYSTATUS ' Toggle the status of the Lock property for the layer layerObj.Lock = Not (layerObj.Lock) ' Display the Lock status of the new layer GoSub DISPLAYSTATUS Exit Sub DISPLAYSTATUS: If layerObj.Lock Then MsgBox "Layer " & layerObj.Name & " is locked.", , "Lock Example" Else MsgBox "Layer " & layerObj.Name & " is unlocked.", , "Lock Example" End If Return End Sub
Visual LISP:
(vl-load-com) (defun c:Example_Lock() ;; This example creates a new layer called "Lock". ;; It then displays the status of the Lock property ;; for the new layer, toggles the status of the ;; Lock property, and again displays its status. ;; After running this example, you can check the layer ;; control on the Object Properties tool bar. It will ;; show the new layer and the latest Lock status. (setq acadObj (vlax-get-acad-object)) (setq doc (vla-get-ActiveDocument acadObj)) ;; Create the new layer (setq layerObj (vla-Add (vla-get-Layers doc) "Lock")) ;; Display the Lock status of the new layer (if (= (vla-get-Lock layerObj) :vlax-true) (alert (strcat "Layer " (vla-get-Name layerObj) " is locked.")) (alert (strcat "Layer " (vla-get-Name layerObj) " is unlocked.")) ) ;; Toggle the status of the Lock property for the layer (vla-put-Lock layerObj (if (= (vla-get-Lock layerObj) :vlax-true) :vlax-false :vlax-true)) ;; Display the Lock status of the new layer (if (= (vla-get-Lock layerObj) :vlax-true) (alert (strcat "Layer " (vla-get-Name layerObj) " is locked.")) (alert (strcat "Layer " (vla-get-Name layerObj) " is unlocked.")) ) )