Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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?
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now