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

error javascript (no such element)

New Here ,
Oct 26, 2016 Oct 26, 2016

Copy link to clipboard

Copied

I am trying to learn javascript. My plan is to select a specific folder, then select a specific layer then move this layer to that specific folder. It's the last line below that is giving me the error. it says 'no such element'

Any help please,,,,

var selectLayerFolder = app.activeDocument.layerSets.getByName('Folder3')

alert (selectLayerFolder.name + " selected")

var selectLayer2 = app.activeDocument.layers.getByName('7')

alert(selectLayer2.name + ' selected')

{

app.activeDocument.layers[selectLayer2].move(app.activeDocument.layerSets[selectLayerFolder], ElementPlacement.PLACEAFTER)

}

TOPICS
Actions and scripting

Views

1.4K

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

Community Expert , Oct 26, 2016 Oct 26, 2016

Hi rmanueljr​,

you use wrong syntax.

Replace your line

app.activeDocument.layers[selectLayer2].move(app.activeDocument.layerSets[selectLayerFolder], ElementPlacement.PLACEAFTER)

with this line

selectLayer2.move(selectLayerFolder, ElementPlacement.INSIDE);

Have fun

Votes

Translate

Translate
Adobe
Engaged ,
Oct 26, 2016 Oct 26, 2016

Copy link to clipboard

Copied

Hi

The Move statement has not moved the layer into layerset (group).

Its only move the layer before,after,begin and end of layerset.

you have to use moveToEnd statement.

Use this code....

var docRef =app.activeDocument;

var laySet=docRef.layerSets.getByName('Folder3');

var layerRef = docRef.layers.getByName('7');

layerRef.moveToEnd (laySet);

-yajiv

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
Community Expert ,
Oct 26, 2016 Oct 26, 2016

Copy link to clipboard

Copied

Hi rmanueljr​,

you use wrong syntax.

Replace your line

app.activeDocument.layers[selectLayer2].move(app.activeDocument.layerSets[selectLayerFolder], ElementPlacement.PLACEAFTER)

with this line

selectLayer2.move(selectLayerFolder, ElementPlacement.INSIDE);

Have fun

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
New Here ,
Oct 26, 2016 Oct 26, 2016

Copy link to clipboard

Copied

LATEST

Wow, they both worked!

Thank you very much. This has kept me thinking for days.

Really need to study more on this if i have time

Thank you

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