ActiveLayer 属性 (ActiveX) 
指定活动图层。 支持的平台:仅限 Windows 言论创建新对象时,将放置在活动图层上。若要更改现有对象所在的图层,请使用该对象的属性。Layer 要创建新图层,请使用以下方法。Add 要更改图层的可见性或其他属性,请参阅对象。Layer 例子VBA: 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
可视化 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)))
)
 | 
|Archiver|CAD开发者社区
( 苏ICP备2022047690号-1   苏公网安备32011402011833)
GMT+8, 2025-11-4 20:11
Powered by Discuz! X3.4
Copyright © 2001-2021, Tencent Cloud.