Script to arrange artboard in grid
Hello guys, I need a script to arrange selected artboards in a grid format in photoshop cc 2017 or cc 2018. Thanks in advance
Hello guys, I need a script to arrange selected artboards in a grid format in photoshop cc 2017 or cc 2018. Thanks in advance
Hello, where can you share this script with me?
I need him very much.
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); }
}
Already have an account? Login
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.