Skip to main content
CarloBalboa
Participant
October 6, 2021
Answered

Extendscript access and hide layer in the layer

  • October 6, 2021
  • 1 reply
  • 584 views

Hello, I'm starting to use Extendscript and I have super noob question: How to access a layer nested in the layer? I imported PSD file and I want to access  Comp1>Main_Layer>Layer and hide first layer:

var comp = app.project.item(1); // I can access Main_Comp1 and hide wanted layer
var outsideLayer = comp.layer(1); // I can access Main_Layer1 and hide wanted layer
var insideLayer = outsideLayer.layer(1); // I can't access layer1 in Main_Layer1 and hide wanted layer

insideLayer.enabled = false; // I got error

I tried "var insideLayer = mainLayer.source", but not working.

This topic has been closed for replies.
Correct answer Dan Ebberts

You're close. Try it this way:

var comp = app.project.item(1);
var outsideLayer = comp.layer(1);
var insideLayer = outsideLayer.source.layer(1);
insideLayer.enabled = false;

1 reply

CarloBalboa
Participant
October 6, 2021

visualization of what I want to automate.

Dan Ebberts
Community Expert
Dan EbbertsCommunity ExpertCorrect answer
Community Expert
October 6, 2021

You're close. Try it this way:

var comp = app.project.item(1);
var outsideLayer = comp.layer(1);
var insideLayer = outsideLayer.source.layer(1);
insideLayer.enabled = false;
CarloBalboa
Participant
October 6, 2021

OMG! That simple... Now I can access all nested layers! I have basic vanilla javascript knowledge and I felt so stupid to be stuck at the start. Thank you so much!