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

How to create artboards from script?

Community Beginner ,
Sep 02, 2017 Sep 02, 2017

Copy link to clipboard

Copied

I need create about 20 artboards different sizes from scripting. How can I do it?

Manual PS CC 2015 doesn't even contain a word "artboard"

After I will try to place at the artboards some linked smart objects, texts and so one.

TOPICS
Actions and scripting

Views

4.4K

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

Community Beginner , Oct 02, 2017 Oct 02, 2017

HI

I make a lot of static banners in my daily work, and manually making artboards sucks! So i made this script to help me out.)

it take an Array of width and height  as manny as you want ( var sizes = [[488,150],[744,236]] )
and then in a for loop runs a function ( createNewArtboard ) and space them out verticaly with a 20pixel spacing.

download it here . ----->  Dropbox - makeartboards.js

Maybe you can use it.

regards Kristian

Votes

Translate

Translate
Adobe
Community Expert ,
Sep 04, 2017 Sep 04, 2017

Copy link to clipboard

Copied

Have you tried using ScriptingListener-plugin to record the code for the operation and then wrap the code in a function yet?

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 ,
Sep 04, 2017 Sep 04, 2017

Copy link to clipboard

Copied

Not yet. I will try. Thank you.

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 ,
Oct 02, 2017 Oct 02, 2017

Copy link to clipboard

Copied

For me it was very helpful! This method is great!

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 ,
Apr 22, 2020 Apr 22, 2020

Copy link to clipboard

Copied

Thank you so much! As someone new to Photoshop scripting, this is such a great tip.

 

For anyone else looking, here's a link to where you can download the ScriptingListener:

https://helpx.adobe.com/photoshop/kb/downloadable-plugins-and-content.html

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 ,
Oct 02, 2017 Oct 02, 2017

Copy link to clipboard

Copied

HI

I make a lot of static banners in my daily work, and manually making artboards sucks! So i made this script to help me out.)

it take an Array of width and height  as manny as you want ( var sizes = [[488,150],[744,236]] )
and then in a for loop runs a function ( createNewArtboard ) and space them out verticaly with a 20pixel spacing.

download it here . ----->  Dropbox - makeartboards.js

Maybe you can use it.

regards Kristian

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 ,
Oct 02, 2017 Oct 02, 2017

Copy link to clipboard

Copied

Thank you! It works

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 31, 2017 Oct 31, 2017

Copy link to clipboard

Copied

Hello, Can you help me out with a script that arrange selected artboards into grid in photoshop. Script will ask number of rows,colums vertical space and horizontal space from user and create a grid of artboards. Assuming all artboards are of same size. Its super urgent for me. Thanks 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
New Here ,
Oct 25, 2022 Oct 25, 2022

Copy link to clipboard

Copied

I made an update so now it is working in the new photoshop

/* Got questions improvements? please do ask or share
regards Kristian Andersen krilleandersen@gmail.com
*/
 
var oldHH= 0;
var startRulerUnits = app.preferences.rulerUnits;
app.preferences.rulerUnits = Units.PIXELS;

var createNewArtboard = function(w,h,t,n) {

var ww=parseFloat(w);//+'.'+000000;
var hh=parseFloat(h);//+'.'+000000;
var tt = parseFloat(oldHH);//+ '.'+000000;
var nme=w+'x'+h;

//alert(oldHH)
 
//Make the Artboard
// =======================================================
var idMk = charIDToTypeID( "Mk " );
var desc510 = new ActionDescriptor();
var idnull = charIDToTypeID( "null" );
var ref39 = new ActionReference();
var idartboardSection = stringIDToTypeID( "artboardSection" );
ref39.putClass( idartboardSection );
desc510.putReference( idnull, ref39 );
var idlayerSectionStart = stringIDToTypeID( "layerSectionStart" );
desc510.putInteger( idlayerSectionStart, 5 );
var idlayerSectionEnd = stringIDToTypeID( "layerSectionEnd" );
desc510.putInteger( idlayerSectionEnd, 6 );
var idNm = charIDToTypeID( "Nm " );
desc510.putString( idNm, ""+nme+"" );
 
var idartboardRect = stringIDToTypeID( "artboardRect" );
var desc511 = new ActionDescriptor();
 
var idTop = charIDToTypeID( "Top " );
desc511.putDouble( idTop, 0.000000 );
 
var idLeft = charIDToTypeID( 'Left' );
desc511.putDouble( idLeft, 0.000000);
 
 
var idBtom = charIDToTypeID( 'Btom' );
desc511.putDouble( idBtom, parseInt(hh)); //<--- Height
 
var idRght = charIDToTypeID( 'Rght' );
desc511.putDouble( idRght, parseInt(ww));//<--- Width
 
var idclassFloatRect = stringIDToTypeID( "classFloatRect" );
desc510.putObject( idartboardRect, idclassFloatRect, desc511 );
executeAction( idMk, desc510, DialogModes.NO );
 
 

//Change artboard default name
// =======================================================
var idsetd = charIDToTypeID( "setd" );
var desc907 = new ActionDescriptor();
var idnull = charIDToTypeID( "null" );
var ref132 = new ActionReference();
var idLyr = charIDToTypeID( "Lyr " );
var idOrdn = charIDToTypeID( "Ordn" );
var idTrgt = charIDToTypeID( "Trgt" );
ref132.putEnumerated( idLyr, idOrdn, idTrgt );
desc907.putReference( idnull, ref132 );
var idT = charIDToTypeID( "T " );
var desc908 = new ActionDescriptor();
var idNm = charIDToTypeID( "Nm " );
 
desc908.putString( idNm, ""+'xxx_'+'oooo'+'_'+nme+ "" ); //<-- artboard name
 
 
var idLyr = charIDToTypeID( "Lyr " );
desc907.putObject( idT, idLyr, desc908 );
executeAction( idsetd, desc907, DialogModes.NO );
 

//Space out artboard
// =======================================================
var ideditArtboardEvent = stringIDToTypeID( "editArtboardEvent" );
var desc95 = new ActionDescriptor();
var idnull = charIDToTypeID( "null" );
var ref12 = new ActionReference();
var idLyr = charIDToTypeID( "Lyr " );
var idOrdn = charIDToTypeID( 'Ordn' );
var idTrgt = charIDToTypeID( 'Trgt' );
ref12.putEnumerated( idLyr, idOrdn, idTrgt );
desc95.putReference( idnull, ref12 );
var idartboard = stringIDToTypeID( "artboard" );
var desc96 = new ActionDescriptor();
var idartboardRect = stringIDToTypeID( "artboardRect" );
var desc97 = new ActionDescriptor();
 
var idTop = charIDToTypeID( "Top " );
desc97.putDouble( idTop, tt ); //<-- artboard y
 
var idLeft = charIDToTypeID( 'Left' );
desc97.putDouble( idLeft, 0.000000 );//<-- artboard x
 
var idBtom = charIDToTypeID( 'Btom' );
desc97.putDouble( idBtom, hh );
 
var idRght = charIDToTypeID( 'Rght' );
desc97.putDouble( idRght, ww );
 
var idclassFloatRect = stringIDToTypeID( "classFloatRect" );
desc96.putObject( idartboardRect, idclassFloatRect, desc97 );
var idguideIDs = stringIDToTypeID( "guideIDs" );
var list10 = new ActionList();
desc96.putList( idguideIDs, list10 );
var idartboardPresetName = stringIDToTypeID( "artboardPresetName" );
desc96.putString( idartboardPresetName, ""+nme+"" );
 
var idClr = charIDToTypeID( "Clr " );
var desc98 = new ActionDescriptor();
var idRd = charIDToTypeID( "Rd " );
desc98.putDouble( idRd, 255.000000 );
var idGrn = charIDToTypeID( "Grn " );
desc98.putDouble( idGrn, 255.000000 );
var idBl = charIDToTypeID( "Bl " );
desc98.putDouble( idBl, 255.000000 );
var idRGBC = charIDToTypeID( 'RGBC' );
desc96.putObject( idClr, idRGBC, desc98 );
var idartboardBackgroundType = stringIDToTypeID( "artboardBackgroundType" );
 
desc96.putInteger( idartboardBackgroundType, 3 ); //<-- artboardBackgroundType 1 = white, 2 = black, 3 = transparent
 
var idartboard = stringIDToTypeID( "artboard" );
desc95.putObject( idartboard, idartboard, desc96 );
var idchangeSizes = stringIDToTypeID( "changeSizes" );
desc95.putInteger( idchangeSizes, 5 );
executeAction( ideditArtboardEvent, desc95, DialogModes.NO );

 
oldHH = parseFloat(oldHH+parseFloat(h)+50); //<-- calculate artboart y position (artboard height + pervious artboard height+50pixels)
 
 
};


function makeshithappen(){
//banner sizes /,
var sizes = [[60,600],[225,265],[450,100],[478,235],[620,540],[620,540],[640,340],[640,340],[851,315],[900,200],[1200,628],[1200,717],[1242,250],[1260,420],[1350,300],[1434,220],[1474,180],[1500,500],[1800,400],[2500,350]];


var count=1;
var sizeW;
var sizeH;
for(var i = 0; i < sizes.length; i++) {
 
var size = sizes[i];
 
for(var j = 0; j < size.length; j++) {
if(count==1){
sizeW = size[j];
}
if(count==2){
sizeH = size[j] ;
createNewArtboard(sizeW,sizeH,(sizeH+sizeH),size);
count=0;
}
count++
}
}

}


 
makeshithappen()
 

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 ,
Apr 24, 2023 Apr 24, 2023

Copy link to clipboard

Copied

LATEST

Hello

is there a way to have popup window that let you input all the sizes you want? Thank you

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