锁定或解锁图层。 支持的平台:仅窗口 属性值只读:不 类型:布尔
言论您无法编辑锁定图层上的对象;但是,如果图层打开并解冻,它们仍然可见。您可以激活锁定图层,也可以向其添加对象。您还可以将对象捕捉模式应用于锁定图层上的对象。您可以冻结和关闭锁定的图层并更改其关联颜色。 当您想要编辑与特定图层关联的对象,但又想查看其他图层上的对象时,锁定非常有用。 例子工 务 局: 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."))
)
)
|
|Archiver|CAD开发者社区
( 苏ICP备2022047690号-1 苏公网安备32011402011833)
GMT+8, 2025-10-29 05:58
Powered by Discuz! X3.4
Copyright © 2001-2021, Tencent Cloud.