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

how get Layer ID from Layer Name ?

Participant ,
Dec 10, 2013 Dec 10, 2013

Copy link to clipboard

Copied

Hello everyone.

Tangled with the implementation of a small script.

I want to add to each of the selected layers of the Document a new layer with the image, make sure the top of each layer.

I think what I need:

1. Create an array of user-selected layers (necessarily by name)

2. Select image;

3. Pass through the array to create a layer, put in the new layer selected image and move the array over this layer.

Found an example where the array is created on indexes, but in my case it's not that - after each addition of a new layer indexes is changes .How do I get the index of the layer by its name?

TOPICS
Actions and scripting

Views

2.5K

Translate

Translate

Report

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

correct answers 1 Correct answer

Guru , Dec 11, 2013 Dec 11, 2013

Andy_Bat1 wrote:

but as I understand, I need to know the ID or Index of the layer?

No, you need a layer( or layerSet ) object. You can make a reference to a layer object in several ways. The snippet you posted has two, one is the activeLayer property and the second is by index. You can also make a reference using the layer name and some methods like ArtLayers.add() return a layer object. The DOM doesn't have a layer ID property.

app.activeDocument.activeLayer.move(activeDocument.artLayers.getByNam

...

Votes

Translate

Translate
Adobe
Guru ,
Dec 10, 2013 Dec 10, 2013

Copy link to clipboard

Copied

Would need to know if you are using the DOM or Action Manager before I can post an example. The DOM doesn't have a layerID and layerID is not the same as the layer index. The index can change as you noted but the ID doesn't. If you are using Action Manager I would use the layerID.

Votes

Translate

Translate

Report

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
Participant ,
Dec 10, 2013 Dec 10, 2013

Copy link to clipboard

Copied

I like to work with the DOM. How to move the layer to the house to a certain position?

I have an example - place layer before background:

app.activeDocument.activeLayer.move(activeDocument.layers[activeDocument.layers.length-1],ElementPlacement.PLACEBEFORE);

but as I understand, I need to know the ID or Index of the layer?

Message was edited by: Andy_Bat1

Votes

Translate

Translate

Report

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
Guru ,
Dec 11, 2013 Dec 11, 2013

Copy link to clipboard

Copied

LATEST

Andy_Bat1 wrote:

but as I understand, I need to know the ID or Index of the layer?

No, you need a layer( or layerSet ) object. You can make a reference to a layer object in several ways. The snippet you posted has two, one is the activeLayer property and the second is by index. You can also make a reference using the layer name and some methods like ArtLayers.add() return a layer object. The DOM doesn't have a layer ID property.

app.activeDocument.activeLayer.move(activeDocument.artLayers.getByName('top'),ElementPlacement.PLACEBEFORE);

app.activeDocument.activeLayer.name = 'new top';

Votes

Translate

Translate

Report

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