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

Auto create Artboard

Participant ,
May 02, 2019 May 02, 2019

Copy link to clipboard

Copied

Hello everybody,

I have an issue

How to create auto Artboard with available layers?

Example:

With 25 layers from 1 to 25 opening in one tab

- 1 to 5 create Artboard 1

- 6 to 10 create Artboard 2

- 11 to 15 create Artboard 3

- 16 to 20 create Artboard 4

- 21 to 25 create Artboard 5

These Artboards are placed side by side on the tab current.

I appreciate any help!!!

Thank very much!

Capture.JPG

TOPICS
Actions and scripting

Views

1.8K

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
Adobe
Community Expert ,
May 03, 2019 May 03, 2019

Copy link to clipboard

Copied

Will there always be 25 layers that need to be grouped into lots of 5 layers on each of the 5 artboards?

Do the final artboards need to be the original canvas size, an out of the box preset size or a custom size?

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 ,
May 03, 2019 May 03, 2019

Copy link to clipboard

Copied

OK, it appears that there is no DOM code for artboards and that it is all AM based, is that right?

So I had a bit of a play for giggles. Assuming that the goal is to create a new artboard at the existing document canvas size, rather than an iPhone size or some other preset or custom value...

// Create New Artboard at Canvas Dimensions

#target photoshop

var savedRuler = app.preferences.rulerUnits;

app.preferences.rulerUnits = Units.PIXELS;

var aD = app.activeDocument;

var dW = aD.width

var dH = aD.height

// New artboard width converted to a float

var abWidth = dW.toString().replace( ' px', '.000000' );

// New artboard height converted to a float

var abHeight = dH.toString().replace( ' px', '.000000' );

// More info below:

// https://forums.adobe.com/thread/1867670

// https://forums.adobe.com/message/7646958#7646958

// ScriptingListener/AM code tidied up via the Clean SL script

make();

function make() {

  var c2t = function (s) {

  return app.charIDToTypeID(s);

  };

  var s2t = function (s) {

  return app.stringIDToTypeID(s);

  };

  var descriptor = new ActionDescriptor();

  var descriptor2 = new ActionDescriptor();

  var reference = new ActionReference();

  reference.putClass( s2t( "artboardSection" ));

  descriptor.putReference( c2t( "null" ), reference );

  // descriptor.putInteger( s2t( "layerSectionStart" ), 5 );

  // descriptor.putInteger( s2t( "layerSectionEnd" ), 6 );

  // Artboard name

  descriptor.putString( s2t( "name" ), "Artboard 1" );

  descriptor2.putDouble( s2t( "top" ), 0.000000 );

  descriptor2.putDouble( s2t( "left" ), 0.000000 );

  // Replace recorded artboard height for canvas height

  descriptor2.putDouble( s2t( "bottom" ), abHeight );

  // Replace recorded artboard width with canvas width

  descriptor2.putDouble( s2t( "right" ), abWidth );

  descriptor.putObject( s2t( "artboardRect" ), s2t( "classFloatRect" ), descriptor2 );

  executeAction( s2t( "make" ), descriptor, DialogModes.NO );

  app.preferences.rulerUnits = savedRuler;

}

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
Participant ,
May 05, 2019 May 05, 2019

Copy link to clipboard

Copied

Thanks for your help.

I tried it but it was not what I needed.

I will describe more carefully.

The above is just an example of a case. Exactly, I need in the script that sets a value as the number of layers to be combined into an artboard.

If I have 25 layers then give me 5 artboard.

If I have 50 layers then give me 10 artboard.

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 ,
May 05, 2019 May 05, 2019

Copy link to clipboard

Copied

Thanks for your help.

I tried it but it was not what I needed.

I will describe more carefully.

The above is just an example of a case. Exactly, I need in the script that sets a value as the number of layers to be combined into an artboard.

If I have 25 layers then give me 5 artboard.

If I have 50 layers then give me 10 artboard.

I was just playing around while waiting for you to answer my initial questions. It seemed to be a glaring omission that in the artboard tool GUI the current canvas size was not an option.

So there would be a GUI of some sort, where the user would enter the required layer count. How would errors be accounted for if one could not evenly divide the layer count with the artboard variable count (such as 49 layers, with the GUI variable asking for 5 layers, which is 9.8 and not 10)?

I like your script, however, I have no idea how it is doing what it is doing, except that it also creates the single artboard at the canvas size, just as my one did.

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
Participant ,
May 05, 2019 May 05, 2019

Copy link to clipboard

Copied

I only use fixed cases for the number of layers.

You try my script. It is doing it for a layer. How does it make 2 or 3 or more layers is what I want.

And the following Artboard created will be next to the previous Artboard created just like the sample.

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 ,
May 05, 2019 May 05, 2019

Copy link to clipboard

Copied

Maybe posting screenshots with the Layers Panel visible might help illustrate your intention.

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
Participant ,
May 05, 2019 May 05, 2019

Copy link to clipboard

Copied

LATEST

Example:

1.JPG

2.JPG

Maybe 3 or more if there is a number to choose from in the script or if it is not possible, leave the default as a number.

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
Participant ,
May 05, 2019 May 05, 2019

Copy link to clipboard

Copied

I have a script, but it only creates an artboard for one layer and these artboards in one place. hope it useful

var d = new ActionDescriptor(); 

var r = new ActionReference(); 

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

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

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

 

var id = get_selected_layers_id(); 

 

if (id) for (var i = 0; i < id.length; i++) make_artboard(id

 

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

function make_artboard(id) 

    { 

    try { 

        var d = new ActionDescriptor(); 

        var r = new ActionReference(); 

        r.putClass(stringIDToTypeID("artboardSection")); 

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

        var r1 = new ActionReference(); 

        r1.putIdentifier(stringIDToTypeID("layer"), id); 

        d.putReference(stringIDToTypeID("from"), r1); 

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

        } 

    catch (e) { alert(e); throw(e); } 

    } 

 

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

function get_selected_layers_id() 

    { 

    try { 

        var r = new ActionReference();     

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

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

 

        var list = executeActionGet(r).getList(stringIDToTypeID("targetLayersIDs")); 

        if (!list.count) return null; 

 

        var ids = new Array(); 

        for (var i = 0; i < list.count; i++) ids.push(list.getReference(i).getIdentifier()); 

     

        return ids; 

        } 

 

    catch (e) { alert(e); return null; } 

    } 

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