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

PS scripting in JS. How to acquire the Content Layer of a Frame Layer's?

New Here ,
Oct 10, 2025 Oct 10, 2025

So when I make a scriptto automate, I need to trim an image in the frame and resize it to its original ratio and resize to fit the frame. 

Currently I am using the 'activeLayer' property to access that layer after execute an action of 'replace content in frame', I wonder if there's way to select the content layer directly without changing the active layer of the document.

TOPICS
Actions and scripting , Windows
66
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 ,
Oct 10, 2025 Oct 10, 2025

Does »Replace Contents« not work in your set-up? 

Could you provide sample files or at least screenshots with the pertinent Panels (Toolbar, Layers, Options Bar, Properties, …) visible? 

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
Community Expert ,
Oct 10, 2025 Oct 10, 2025

Groups, Artboards and Frame layers are all variants of layerSets. To access a layer without making it active, you can use it's index number.

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
Community Expert ,
Oct 10, 2025 Oct 10, 2025
LATEST

Further to my previous post.

 

Assuming that the frame layer is active and that it has content, selecting the top frame layer's content by index number:

 

app.activeDocument.activeLayer = app.activeDocument.activeLayer.layers[0];

.

 Or using the first layerSet index number in the collection (you obviously need to know which layerSet index number to target, as opposed to the entire layers collection):

 

app.activeDocument.activeLayer = app.activeDocument.layerSets[0].layers[0];

 

Or just using the layers absolute position in the stack (not isolating by layerSet), such as the very back layer index:

 

app.activeDocument.activeLayer = app.activeDocument.layers[app.activeDocument.layers.length - 1].layers[0];


I haven't tried replacing content, hopefully the same principle applies.

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