Layers Property (ActiveX)

Gets the Layers collection for the document.

Supported platforms: Windows only

Signature

VBA:

object.Layers
object

Type: Database, Document

The objects this property applies to.

Property Value

Read-only: Yes

Type: Layers

The Layers collection for the document.

Remarks

No additional remarks.

Examples

VBA:

Sub Example_Layers()
    ' This example finds the current Layers collection and
    ' adds a new layer to that collection.
    
    Dim layerColl As AcadLayers
    Set layerColl = ThisDrawing.Layers
    
    ' Create a dimension style named "TEST" in current drawing
    Dim testlayer As AcadLayer
    Set testlayer = layerColl.Add("TEST")
    MsgBox "A new layer called " & testlayer.name & " has been added to the Layers collection.", vbInformation, "Layers Example"
End Sub

Visual LISP:

(vl-load-com)
(defun c:Example_Layers()
    ;; This example finds the current Layers collection and
    ;; adds a new layer to that collection.
    (setq acadObj (vlax-get-acad-object))
    (setq doc (vla-get-ActiveDocument acadObj))
    
    (setq layerColl (vla-get-Layers doc))
    
    ;; Create a dimension style named "TEST" in current drawing
    (setq testlayer (vla-Add layerColl "TEST"))
    (alert (strcat "A new layer called " (vla-get-Name testlayer) " has been added to the Layers collection."))
)