Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Layer getByName

Engaged ,
Jun 03, 2013 Jun 03, 2013

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

TOPICS
Actions and scripting
951
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe
Community Expert ,
Jun 03, 2013 Jun 03, 2013
LATEST

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines