make layer current...

make layer current...

Anonymous
Not applicable
235 Views
2 Replies
Message 1 of 3

make layer current...

Anonymous
Not applicable
hi

i am creating a program that allows user to create several layers, and when
they press ok, i want to get the last layer they created to be the current
layer, is there a way to do this???

thanks in advance

cheers
mark
0 Likes
236 Views
2 Replies
Replies (2)
Message 2 of 3

Anonymous
Not applicable
Read this example I hope it could help.
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

In your case :
ThisDrawing.ActiveLayer="The last layer they created"
0 Likes
Message 3 of 3

Anonymous
Not applicable
here is the example again in a readable way.
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
0 Likes