アクティブな画層を指定します。
サポートされているプラットフォーム: 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
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)))
)