Skip to main content
1-Visitor
November 15, 2012
Solved

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

  • November 15, 2012
  • 1 reply
  • 1178 views

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?

Best answer by thendricks

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

1 reply

12-Amethyst
November 15, 2012

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

TimSharp1-VisitorAuthor
1-Visitor
November 15, 2012

Thanks Trevor

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