Copy link to clipboard
Copied
Hi
I have a client who wants to receive his image in the following format
one layer for the background
another layer for the shaddow
another layer for the object
I am doing many images so i am looking a way to Script to Merge each main group (not subgroup) in to a layer
then while i work i can make sure to work in these groups
is there a way to do it?
Thank you in advance
Something like this?
#target photoshop;
while(app.activeDocument.layerSets.length){
activeDocument.activeLayer = app.activeDocument.layerSets[0];
executeAction(stringIDToTypeID("newPlacedLayer"), new ActionDescriptor(), DialogModes.NO);
activeDocument.activeLayer.rasterize(RasterizeType.ENTIRELAYER);
}
Copy link to clipboard
Copied
Something like this?
#target photoshop;
while(app.activeDocument.layerSets.length){
activeDocument.activeLayer = app.activeDocument.layerSets[0];
executeAction(stringIDToTypeID("newPlacedLayer"), new ActionDescriptor(), DialogModes.NO);
activeDocument.activeLayer.rasterize(RasterizeType.ENTIRELAYER);
}
Copy link to clipboard
Copied
Excellent!
Works perfectly!
Thanks!
Copy link to clipboard
Copied
Hi SuperMerlin
Thank you for the script.
I ALMOST works in my case.
Is it possible to rewrite the script, so that photoshop selects the top layer (In my case a Artboard group) ?
When using "select --> All layers" i get a error (See attached) But if i manually select the top artboard, the scripts runs perfect!
The script is for a save action, converting multiple (and different amount) of artboards to 16/bit, flattening and converting back to 8/bit. And then exporting every layer into seperate files.
Thank you so much in advance. 🙂
Copy link to clipboard
Copied
I don’t understand your scenario, could you please post screenshots with the pertinent Panels (Toolbar, Layers, Options Bar, …) visible of the starting point and intended result?
Copy link to clipboard
Copied
Hi
The intended result is to come from all these artboards, to flattenede seperate layers. (See attached)
The problem is, that the script comes with a error, when either "select all layers/groups" from the select tab, or when not selecting any layers. The only way it works, is by manually selecting the top layer (the one called Singlesalg_930x180) and i want the script to automaticly select the first group, not taking account for name etc.
Copy link to clipboard
Copied
Is »Insert Photos« not good enough for you?
Why don’t you include a simple line like
activeDocument.activeLayer = activeDocument.layerSets[0];
at the start of the Script?
Copy link to clipboard
Copied
Why don’t you include a simple line like
activeDocument.activeLayer = activeDocument.layerSets[0];
at the start of the Script?
By @c.pfaffenbichler
That was my thought, but it doesn't work with artboards/groups.
This does though:
activeDocument.activeLayer = activeDocument.layerSets[0].layers[0];
activeDocument.activeLayer = activeDocument.activeLayer.parent;
Copy link to clipboard
Copied
So how would the final script look like?
Sorry for my really limited knowledge in writing code.
And once again, thank you so much guys, for the help.
Copy link to clipboard
Copied
So how would the final script look like?
By @Simon3344797511r3
Try this:
#target photoshop;
activeDocument.activeLayer = activeDocument.layerSets[0].layers[0];
activeDocument.activeLayer = activeDocument.activeLayer.parent;
while (app.activeDocument.layerSets.length) {
activeDocument.activeLayer = app.activeDocument.layerSets[0];
executeAction(stringIDToTypeID("newPlacedLayer"), new ActionDescriptor(), DialogModes.NO);
activeDocument.activeLayer.rasterize(RasterizeType.ENTIRELAYER);
}
Copy link to clipboard
Copied
Great! That worked.
Copy link to clipboard
Copied
For reference, this topic is also discussed here: