Get Current Layer

Get Current Layer

sgrya1
Advocate Advocate
648 Views
5 Replies
Message 1 of 6

Get Current Layer

sgrya1
Advocate
Advocate
How do I get the currently active layer in a drawing so that I can save it and revert to it later?
I've tried
PrevLayer = ThisDrawing.ActiveLayer
Which creates a message box error.
0 Likes
649 Views
5 Replies
Replies (5)
Message 2 of 6

arcticad
Advisor
Advisor
LayerName = ThisDrawing.ActiveLayer.name

Set LayerReference = ThisDrawing.ActiveLayer
---------------------------



(defun botsbuildbots() (botsbuildbots))
0 Likes
Message 3 of 6

sgrya1
Advocate
Advocate
If I set
PrevLayer = ThisDrawing.ActiveLayer.Name
then have
ThisDrawing.ActiveLayer = PrevLayer
I also get an error

If I add
Set LayerReference = ThisDrawing.ActiveLayer
LayerReference requires a variable setting. What do I use? eg LayerReference as string?
0 Likes
Message 4 of 6

arcticad
Advisor
Advisor
set the index of the layer by the reference name

ThisDrawing.ActiveLayer = ThisDrawing.Layers(PrevLayer)
---------------------------



(defun botsbuildbots() (botsbuildbots))
0 Likes
Message 5 of 6

sgrya1
Advocate
Advocate
: ) Thankyou!!!
0 Likes
Message 6 of 6

arcticad
Advisor
Advisor
Your Welcome.
---------------------------



(defun botsbuildbots() (botsbuildbots))
0 Likes