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

Script to arrange artboard in grid

Contributor ,
Oct 30, 2017 Oct 30, 2017

Copy link to clipboard

Copied

Hello guys, I need a script to arrange selected artboards in a grid format in photoshop cc 2017 or cc 2018. Thanks in advance

TOPICS
Actions and scripting

Views

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

People's Champ , Sep 07, 2018 Sep 07, 2018

var clms = 5;

var space_x = 20;

var space_y = 20;

clms = prompt("Columns", clms, "Input");

if (clms)

    {

    clms = Number(clms);

    var arts = new Array();

    var w = 0;

    var h = 0;

    for (var i = 0; i < activeDocument.layerSets.length; i++)

        {

        var r = new ActionReference();     

        r.putProperty(stringIDToTypeID("property"), stringIDToTypeID("artboardEnabled"));         

        r.putIdentifier(stringIDToTypeID("layer"), activeDocument.layerSets.id);     

   

        if (exec

...

Votes

Translate

Translate
Adobe
Enthusiast ,
Oct 30, 2017 Oct 30, 2017

Copy link to clipboard

Copied

Can you upload image how result of script should look at your screen?

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
Contributor ,
Oct 30, 2017 Oct 30, 2017

Copy link to clipboard

Copied

Here is more description A simple script to rearrange selected artboards into a grid with the option of how many rows and columns + how much spacing between them vertically and horizontally. Preferably in the order they're laid out in the layers panel. This is all assuming that the selected artboards have the same dimensions to make the math slightly easier. Final result will be as in screen shot.Screen Shot 2017-10-30 at 7.27.59 PM.png

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
Explorer ,
Sep 06, 2018 Sep 06, 2018

Copy link to clipboard

Copied

Hello, where can you share this script with me?

I need him very much.

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
Enthusiast ,
Sep 06, 2018 Sep 06, 2018

Copy link to clipboard

Copied

I didn't make script for this. I just wanted to make the question more clear if other scripters would have interest.

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
People's Champ ,
Sep 07, 2018 Sep 07, 2018

Copy link to clipboard

Copied

var clms = 5;

var space_x = 20;

var space_y = 20;

clms = prompt("Columns", clms, "Input");

if (clms)

    {

    clms = Number(clms);

    var arts = new Array();

    var w = 0;

    var h = 0;

    for (var i = 0; i < activeDocument.layerSets.length; i++)

        {

        var r = new ActionReference();     

        r.putProperty(stringIDToTypeID("property"), stringIDToTypeID("artboardEnabled"));         

        r.putIdentifier(stringIDToTypeID("layer"), activeDocument.layerSets.id);     

   

        if (executeActionGet(r).getBoolean(stringIDToTypeID("artboardEnabled")))

            {

            var r = new ActionReference();     

            r.putProperty(stringIDToTypeID("property"), stringIDToTypeID("artboard"));         

            r.putIdentifier(stringIDToTypeID("layer"), activeDocument.layerSets.id);     

   

            var rect = executeActionGet(r).getObjectValue(stringIDToTypeID("artboard")).getObjectValue(stringIDToTypeID("artboardRect"));

   

            var l = rect.getDouble(stringIDToTypeID("left"));

            var t = rect.getDouble(stringIDToTypeID("top"));

            var r = rect.getDouble(stringIDToTypeID("right"));

            var b = rect.getDouble(stringIDToTypeID("bottom"));

   

            arts.push([activeDocument.layerSets, [l,t,r,b]]);

   

            var w1 = r-l;

            var h1 = b-t;

   

            if (w1 > w) w = w1;

            if (h1 > h) h = h1;

            }

        }

    var rows = Math.floor(arts.length/clms);

    if (rows*clms < arts.length) ++rows;

    var i = 0;

    for (var y = 0; y < rows; y++)

        {

        var pos_y = y * (h + space_y);

        for (var x = 0; x < clms; x++)

            {

            if (i >= arts.length) break;

            activeDocument.activeLayer = arts[0];

            var pos_x = x * (w + space_x);

            move(pos_x-arts[1][0], pos_y-arts[1][1])

            i += 1;

            }

        }

    }

///////////////////////////////////////////////////////////////////////////

function move(x, y)

    {

    try {

        var d = new ActionDescriptor();

        var r = new ActionReference();

        r.putEnumerated(stringIDToTypeID("layer"), stringIDToTypeID("ordinal"), stringIDToTypeID("targetEnum"));

        d.putReference(stringIDToTypeID("null"), r);

        var d1 = new ActionDescriptor();

        d1.putUnitDouble(stringIDToTypeID("horizontal"), stringIDToTypeID("pixelsUnit"), x);

        d1.putUnitDouble(stringIDToTypeID("vertical"), stringIDToTypeID("pixelsUnit"), y);

        d.putObject(stringIDToTypeID("to"), stringIDToTypeID("offset"), d1);

        executeAction(stringIDToTypeID("move"), d, DialogModes.NO);

        }

    catch (e) { throw(e); }

    }

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
Explorer ,
Sep 07, 2018 Sep 07, 2018

Copy link to clipboard

Copied

I saw you again. You really are the second enthusiastic foreigner I have ever met.

Thank you very much for your script he is very good

You are really a programming god

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 ,
May 10, 2022 May 10, 2022

Copy link to clipboard

Copied

Hey, do you have an updated version of this for PS 2021 / 2022? It no longer works

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
LEGEND ,
May 10, 2022 May 10, 2022

Copy link to clipboard

Copied

Transition from old forums crippled the code which it still works in 23.3.2.

 

Correct appropriate lines twice:

 

activeDocument.layerSets[i].id

 

and:

 

activeDocument.activeLayer = arts[x][0][i];
var pos_x = x * (w + space_x);
move(pos_x-arts[x][1][0], pos_y-arts[x][1][1])

 

After you make above changes, start with overlapping artboards and select all beside top one.

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 ,
Jul 21, 2022 Jul 21, 2022

Copy link to clipboard

Copied

LATEST

I thought it might be worth mentioning here that you can also use the "Align" and "Distribute" tools on artboards. Just select the artboards in the layers panel and then click one of the "Align" and "Distribute" icons.

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