CAD开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

ActiveX 开发指南

相关分类

锁定属性 (ActiveX)

2023-1-3 11:43| 发布者: admin| 查看: 379| 评论: 0|来自: AutoCAD

摘要: 锁定或解锁图层。

锁定或解锁图层。

支持的平台:仅窗口

签名

工 务 局:

object.Lock
对象

类型:图层

此属性适用的对象。

属性值

只读:

类型:布尔

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

言论

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

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

例子

工 务 局:

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."))
    )
)

路过

雷人

握手

鲜花

鸡蛋

最新评论

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

GMT+8, 2024-5-12 08:11

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

返回顶部