Copy link to clipboard
Copied
Hiya
app.activeDocument.activeLayer = app.activeDocument.artLayers.getByName("Layer 1");
I found out that the getByName layer method will grab the topmost layer if there are multiple layers named the same. Since you can have layers named the same (unlike path names) would the best practice for this to check for unique names before doing such a call?
Cheers
Copy link to clipboard
Copied
The topmost layer is always layers[0]
getByName() get the next layer which is having the correct name. There is normally no need to search, if there any other layers with the same name exists.
Why do you have layers with the same name? In this case you should check for unique names before you use this method. One way to do this: check your layers with REGEX like search() or match() whether the same name is used in the document multiple.
 
					
				
				
			
		
 
					
				
				
			
		
Find more inspiration, events, and resources on the new Adobe Community
Explore Now