Change an Object's Layer

AutoCAD ActiveX

 
Change an Object's Layer
 
 
 

Once you have created an object and assigned layer, color, and linetype properties to it, you may wish to change the object's layer. Changing an object's layer is useful if you accidentally create an object on the wrong layer or decide to change your layer organization later.

To change an object's layer, use the Layer property provided for that object. The Layer property takes the name of the layer as input.

Move an object to a different layer

This example creates a circle on the active layer and then creates a new layer called “ABC”. It then moves the circle to the new layer.

Sub Ch4_MoveObjectNewLayer()
    ' 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 new layer called "ABC"
    Dim layerObj As AcadLayer
    Set layerObj = ThisDrawing.Layers.Add("ABC")
      
    ' Assign the circle to the "ABC" layer
    circleObj.Layer = "ABC"
    circleObj.Update
End Sub