cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

The community will undergo maintenance on October 16th at 10:00 PM PDT and will be unavailable for up to one hour.

How do you check which is the current layer in an Isodraw macro?

TimSharp
6-Contributor

How do you check which is the current layer in an Isodraw macro?

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?

ACCEPTED SOLUTION

Accepted Solutions

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

View solution in original post

2 REPLIES 2

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

TimSharp
6-Contributor
(To:thendricks)

Thanks Trevor

Useful as always - it worked of course - I'd missed the meaning of the layer.active command.

Announcements

Top Tags