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

Script to Merge each main group (not subgroup) in to a layer

New Here ,
Mar 14, 2019 Mar 14, 2019

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

TOPICS
Actions and scripting

Views

2.3K

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

Guide , Mar 14, 2019 Mar 14, 2019

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);

}

Votes

Translate

Translate
Adobe
Guide ,
Mar 14, 2019 Mar 14, 2019

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);

}

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 ,
Nov 06, 2022 Nov 06, 2022

Copy link to clipboard

Copied

Excellent! 

Works perfectly!

 

Thanks!

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 Beginner ,
Nov 28, 2023 Nov 28, 2023

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. 🙂


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 ,
Nov 28, 2023 Nov 28, 2023

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? 

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 Beginner ,
Nov 28, 2023 Nov 28, 2023

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. 

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 ,
Nov 28, 2023 Nov 28, 2023

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? 

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 ,
Nov 28, 2023 Nov 28, 2023

Copy link to clipboard

Copied

quote

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;

 

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 Beginner ,
Nov 28, 2023 Nov 28, 2023

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. 

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 ,
Nov 28, 2023 Nov 28, 2023

Copy link to clipboard

Copied

quote

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);
}

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 Beginner ,
Nov 28, 2023 Nov 28, 2023

Copy link to clipboard

Copied

LATEST

Great! That worked. 

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 ,
Nov 28, 2023 Nov 28, 2023

Copy link to clipboard

Copied

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