CAD开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

ActiveX 开发指南

相关分类

活动层属性 (ActiveX)

2023-1-4 00:08| 发布者: admin| 查看: 858| 评论: 0|来自: AutoCAD

摘要: 指定活动图层。

指定活动图层。

支持的平台:仅窗口

签名

工 务 局:

object.ActiveLayer
对象

类型:文档

此属性适用的对象。

属性值

只读:

类型:图层

当前处于活动状态的图层。

言论

创建新对象时,这些对象将放置在活动图层上。要更改现有对象所在的图层,请使用该对象的属性。Layer

要创建新图层,请使用该方法。Add

要更改图层的可见性或其他属性,请参阅对象。Layer

例子

工 务 局:

Sub Example_ActiveLayer()
    ' This example returns the current layer
    ' and then adds a new layer.
    ' Finally, it returns the layer to the previous setting.
    Dim currLayer As AcadLayer
    Dim newLayer As AcadLayer
    
    ' Return the current layer of the active document
    Set currLayer = ThisDrawing.ActiveLayer
    MsgBox "The current layer is " & currLayer.name, vbInformation, "ActiveLayer Example"
    
    ' Create a Layer and make it the active layer
    Set newLayer = ThisDrawing.Layers.Add("TestLayer")
    ThisDrawing.ActiveLayer = newLayer
    MsgBox "The new layer is " & newLayer.name, vbInformation, "ActiveLayer Example"

    ' Reset the layer to its previous setting
    ThisDrawing.ActiveLayer = currLayer
    MsgBox "The active layer is reset to " & currLayer.name, vbInformation, "ActiveLayer Example"
End Sub

Visual LISP:

(vl-load-com)
(defun c:Example_ActiveLayer()
    ;; This example returns the current layer
    ;; and then adds a new layer.
    ;; Finally, it returns the layer to the previous setting.
    (setq acadObj (vlax-get-acad-object))
    (setq doc (vla-get-ActiveDocument acadObj))
    
    ;; Return the current layer of the active document
    (setq currLayer (vla-get-ActiveLayer doc))
    (alert (strcat "The current layer is " (vla-get-Name currLayer)))
    
    ;; Create a Layer and make it the active layer
    (setq layers (vla-get-Layers doc))
    (setq newLayer (vla-Add layers "TestLayer"))
    (alert (strcat "The new layer is " (vla-get-Name newLayer)))

    ;; Restore the previous layer
    (setq currLayer (vla-get-ActiveLayer doc))
    (alert (strcat "The active layer is restored to " (vla-get-Name currLayer)))
)

路过

雷人

握手

鲜花

鸡蛋

最新评论

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

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

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

返回顶部