Community Tip - You can change your system assigned username to something more personal in your community settings. X
I've a macro that works through all layers in an illustration (making each one active as it goes along).
I want to make it activate the original layer at the end of the macro (i.e. the one that was active before the macro was run).
I can't find a way to do this.
Anyone know how check which layer is currently active in a macro?
Solved! Go to Solution.
You might need to tweak this some as I just did a quick grab from one of my macros and might have missed something, but this should get you going.
Macro Active_Layer
#Variable definitions.
Define i as integer
Define CurrentLayer as string
Define LayerName as string
#Sets values of variables.
i = ActiveDoc.LayerCount
CurrentLayer = ActiveDoc.Layers[i]
#Starts loop that goes through all existing layers and checks which is currently active. Then sets LayerName variable to that layer.
While (Exists(CurrentLayer) = True)
If (CurrentLayer.Active = True) Then
LayerName = CurrentLayer.Name
Else
End If
CurrentLayer = CurrentLayer.PreviousSibling
End While
Message LayerName
End Macro
You might need to tweak this some as I just did a quick grab from one of my macros and might have missed something, but this should get you going.
Macro Active_Layer
#Variable definitions.
Define i as integer
Define CurrentLayer as string
Define LayerName as string
#Sets values of variables.
i = ActiveDoc.LayerCount
CurrentLayer = ActiveDoc.Layers[i]
#Starts loop that goes through all existing layers and checks which is currently active. Then sets LayerName variable to that layer.
While (Exists(CurrentLayer) = True)
If (CurrentLayer.Active = True) Then
LayerName = CurrentLayer.Name
Else
End If
CurrentLayer = CurrentLayer.PreviousSibling
End While
Message LayerName
End Macro
Thanks Trevor
Useful as always - it worked of course - I'd missed the meaning of the layer.active command.