Skip to main content
Inspiring
August 5, 2015
Answered

How to get artboard properties in photoshop CC 2015?

  • August 5, 2015
  • 1 reply
  • 1796 views

There is a new feature in Photoshop CC 2015 to create the multiple artboards in the same document.

I want to get the properties of artboards like x, y, height etc. Is it possible to fetch the artboard details from the script?

Thanks.

This topic has been closed for replies.

1 reply

c.pfaffenbichler
Community Expert
c.pfaffenbichlerCommunity ExpertCorrect answer
Community Expert
August 5, 2015
_VGAuthor
Inspiring
August 5, 2015

Thank you for pointing me in right direction.

c.pfaffenbichler
Community Expert
Community Expert
August 5, 2015

Also maybe this helps:

// 2015, use it at your own risk;

#target "photoshop-90.032"

if (app.documents.length > 0) {

var theArtboards = getArtboardStuff();

alert (theArtboards.join("\n"));

};

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

function getArtboardStuff () {

var originalRulerUnits = app.preferences.rulerUnits;

app.preferences.rulerUnits = Units.PIXELS;

// the file;

var myDocument = app.activeDocument;

// get number of layers;

var ref = new ActionReference();

ref.putEnumerated( charIDToTypeID("Dcmn"), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );

var applicationDesc = executeActionGet(ref);

var theNumber = applicationDesc.getInteger(stringIDToTypeID("numberOfLayers"));

// process the layers;

var theLayers = new Array;

for (var m = 0; m <= theNumber; m++) {

try {

var ref = new ActionReference();

ref.putIndex( charIDToTypeID( "Lyr " ), m);

var layerDesc = executeActionGet(ref);

// if artboard;

if (layerDesc.getBoolean(stringIDToTypeID("artboardEnabled")) == true) {

var artBoardRect = layerDesc.getObjectValue(stringIDToTypeID("artboard")).getObjectValue(stringIDToTypeID("artboardRect"));

var theName = layerDesc.getString(stringIDToTypeID('name'));

var theID = layerDesc.getInteger(stringIDToTypeID('layerID'));

theLayers.push([theName, theID, [artBoardRect.getUnitDoubleValue(stringIDToTypeID("left")), artBoardRect.getUnitDoubleValue(stringIDToTypeID("top")), artBoardRect.getUnitDoubleValue(stringIDToTypeID("right")), artBoardRect.getUnitDoubleValue(stringIDToTypeID("bottom"))]])

};

}

catch (e) {};

};

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

app.preferences.rulerUnits = originalRulerUnits;

return theLayers

};