You can create new layers and assign color and linetype properties to those layers. Each individual layer is part of the Layers collection. Use the Add method to create a new layer and add it to the Layers collection.
You can assign a name to a layer when it is created. To change the name of a layer after it has been created, use the Name property. Layer names can include up to thirty-one characters and contain letters, digits, and the special characters dollar sign ($), hyphen (-), and underscore (_) but cannot include blank spaces.
For more information about creating layers, see “Create and Name Layers” in the User's Guide.
Create a new layer, assign it the color red, and add an object to the layer
The following code creates a circle and a new layer. The new layer is assigned the color red. The circle is assigned to the layer, and the color of the circle changes accordingly.
Sub Ch4_NewLayer()
' Create a circle
Dim circleObj As AcadCircle
Dim center(0 To 2) As Double
Dim radius As Double
center(0) = 2: center(1) = 2: center(2) = 0
radius = 1
Set circleObj = ThisDrawing.ModelSpace. _
AddCircle(center, radius)
' Create a color object
Dim col As New AcadAcCmColor
col.ColorMethod = AutoCAD.acColorMethodForeground
' Set the layer to the color
Dim layColor As AcadAcCmColor
Set layColor =
AcadApplication.GetInterfaceObject("AutoCAD.AcCmColor.17")
Call layColor.SetRGB(122, 199, 25)
ThisDrawing.ActiveLayer.TrueColor = layColor
col.ColorMethod = AutoCAD.acColorMethodByLayer
' Assign the circle the color "ByLayer" so
' that the circle will automatically pick
' up the color of the layer on which it resides
circleObj.Color = acByLayer
circleObj.Update
End Sub