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

Script to fit individual art boards to multiple selected images

Community Beginner ,
May 01, 2017 May 01, 2017

Copy link to clipboard

Copied

I am looking for a way to give individual art boards to multiple items that share the same parent artboard.

https://drive.google.com/open?id=0B_gulI8o3v6eNVJYdFhJOHdwVHc Here is an example. All 4 images are on a parent artboard. I currently manually use the art board tool and click on the pink line to give each individual image its own artboard.

This process will result in this format: https://drive.google.com/open?id=0B_gulI8o3v6eU1ZtaFNPYjZ4V1E

I would like to be able to automate this process. The script would basically need to scan the document from top to bottom left to right looking for selected images and give an individual art board fit to content. That is important as the numbering of the artboards is necessary.

I have been able to create a script that fits an art board to all four selections but not to individual selections like in my linked example.

Thanks in advance for any advice or help.

Cheers,

Steve

TOPICS
Scripting

Views

774

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 , May 01, 2017 May 01, 2017

Update: Ok I figured it out. Shoutout to @CarlosCanto for pointing me in the right direction with a script he provided in another discussion: Re: Selections to Artboards ?

var docRef = app.activeDocument;

var selectRef = docRef.pathItems;

//finds all cut lines

for ( var i = 0; i < selectRef.length; i++) {

    if (selectRef.strokeColor.cyan == 0 && selectRef.strokeColor.magenta == 100 && selectRef.strokeColor.yellow == 0 && selectRef.strokeColor.black == 0)

        docRef.pathItems.selected = selectRe

...

Votes

Translate

Translate
Adobe
Community Beginner ,
May 01, 2017 May 01, 2017

Copy link to clipboard

Copied

Update: Ok I figure out how to add individual art boards. The only issue now is it loops backwards based on what cut line was placed first. Starting at last placed and working backwards to the first placed. I just need to figure out how to reverse the art board placement.

var selectRef = docRef.pathItems;

//finds all cut lines

for ( var i = 0; i < selectRef.length; i++) {

    if (selectRef.strokeColor.cyan == 0 && selectRef.strokeColor.magenta == 100 && selectRef.strokeColor.yellow == 0 && selectRef.strokeColor.black == 0)

        docRef.pathItems.selected = selectRef.stroked;

          };

//adds Art Board to selections

function addArtBoard(doc){ 

var TotalArtboards = selectRef.length;

for (var i = 0 ; i < TotalArtboards ; i++){     

       app.activeDocument.artboards.add(selection.geometricBounds);

       }};

    addArtBoard(doc);

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 ,
May 01, 2017 May 01, 2017

Copy link to clipboard

Copied

Update: Ok I figured it out. Shoutout to @CarlosCanto for pointing me in the right direction with a script he provided in another discussion: Re: Selections to Artboards ?

var docRef = app.activeDocument;

var selectRef = docRef.pathItems;

//finds all cut lines

for ( var i = 0; i < selectRef.length; i++) {

    if (selectRef.strokeColor.cyan == 0 && selectRef.strokeColor.magenta == 100 && selectRef.strokeColor.yellow == 0 && selectRef.strokeColor.black == 0)

        docRef.pathItems.selected = selectRef.stroked;

          };

//adds  Art Board to selections

function addArtBoard(doc){  

var TotalArtboards = selectRef.length;

for (var i = TotalArtboards-1; i >= 0 ; i--){      

       app.activeDocument.artboards.add(selection.geometricBounds);}

        };

addArtBoard(doc);

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 ,
Jan 27, 2021 Jan 27, 2021

Copy link to clipboard

Copied

LATEST

Hi Steve. I'm just looking for what you're looking for,
And I can't do that through the script here.
He's giving me an error, do you have any idea why?

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