CAD开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

AutoCAD 2019 开发者帮助

Lock 属性 (ActiveX)

2024-5-18 17:53| 发布者: admin| 查看: 89| 评论: 0|原作者: admin|来自: AutoCAD

Lock 属性 (ActiveX)

锁定或解锁图层。

支持的平台:仅限 Windows

签名

VBA:

object.Lock
对象

类型:图层

此属性应用于的对象。

属性值

只读:

类型:布尔

  • True:图层已锁定。
  • False:图层已解锁。

言论

您无法编辑锁定图层上的对象;但是,如果该层打开并解冻,它们仍然可见。您可以激活锁定图层,并可以向其添加对象。还可以将对象捕捉模式应用于锁定图层上的对象。您可以冻结和关闭锁定的图层,并更改其关联的颜色。

当您想要编辑与特定图层关联的对象,但又想查看其他图层上的对象时,锁定非常有用。

例子

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

可视化 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."))
    )
)

路过

雷人

握手

鲜花

鸡蛋

最新评论

QQ|Archiver|CAD开发者社区 ( 苏ICP备2022047690号-1   苏公网安备32011402011833)

GMT+8, 2024-12-15 11:26

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

返回顶部