CAD开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

AutoCAD 2018 开发者帮助

LayerOn 属性 (ActiveX)

2024-5-18 16:54| 发布者: admin| 查看: 74| 评论: 0|原作者: admin|来自: AutoCAD

LayerOn 属性 (ActiveX)

指定图层的状态。

支持的平台:仅限 Windows

签名

VBA:

object.LayerOn
对象

类型:图层

此属性应用于的对象。

属性值

只读:

类型:布尔

  • True:图层已打开。
  • False:图层已关闭。

言论

与关闭图层关联的对象不会显示在屏幕上或打印。与属性不同,关闭的图层会在再生过程中生成,但不会显示。Freeze

关闭或冻结图层上的 AutoCAD 曲面和圆是不可见的,但在使用 HIDE、SHADEMODE 或 RENDER 命令时,它们仍会隐藏对象。

例子

VBA:

Sub Example_LayerOn()
    ' This example creates a new layer called "LayerOn".
    ' It then displays the status of the LayerOn property
    ' for the new layer, toggles the status of the
    ' LayerOn 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 LayerOn status.
    
    Dim layerObj As AcadLayer
    
    ' Create the new layer
    Set layerObj = ThisDrawing.Layers.Add("LayerOn")
    
    ' Display the LayerOn status of the new layer
    GoSub DISPLAYSTATUS
    
    ' Toggle the status of the LayerOn property for the layer
    layerObj.LayerOn = Not (layerObj.LayerOn)
    
    ' Display the LayerOn status of the new layer
    GoSub DISPLAYSTATUS
    Exit Sub
    
DISPLAYSTATUS:
    If layerObj.LayerOn Then
        MsgBox "Layer " & layerObj.name & " is turned on.", , "LayerOn Example"
    Else
        MsgBox "Layer " & layerObj.name & " is turned off.", , "LayerOn Example"
    End If
    Return
        
End Sub

可视化 LISP:

(vl-load-com)
(defun c:Example_LayerOn()
    ;; This example creates a new layer called "LayerOn".
    ;; It then displays the status of the LayerOn property
    ;; for the new layer, toggles the status of the
    ;; LayerOn 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 LayerOn 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) "LayerOn"))
    
    ;; Display the LayerOn status of the new layer
    (if (= (vla-get-LayerOn layerObj) :vlax-true)
        (alert (strcat "Layer " (vla-get-Name layerObj) " is turned on."))
        (alert (strcat "Layer " (vla-get-Name layerObj) " is turned off."))
    )

    ;; Toggle the status of the LayerOn property for the layer
    (vla-put-LayerOn layerObj (if (= (vla-get-LayerOn layerObj) :vlax-true) :vlax-false :vlax-true))
    
    ;; Display the LayerOn status of the new layer
    (if (= (vla-get-LayerOn layerObj) :vlax-true)
        (alert (strcat "Layer " (vla-get-Name layerObj) " is turned on."))
        (alert (strcat "Layer " (vla-get-Name layerObj) " is turned off."))
    )
)

路过

雷人

握手

鲜花

鸡蛋

最新评论

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

GMT+8, 2024-12-15 22:04

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

返回顶部