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

Is it possible to automate the creation of artboards that correspond to datasets?

New Here ,
Jun 09, 2020 Jun 09, 2020

Copy link to clipboard

Copied

Hi!

To make wine labels for a store,  I used the Variables function to automate switching out the text. However, there are still lots of minor tweaks to make to the labels, so I'd like to also automate the process of creating a new artboard in the document for each dataset. I've been at it for a few hours trying to script something for this, but I'm still pretty new to Javascript. Through stitching together some things I found online, I wrote this:

 

 

var myDocument = app.activeDocument;

function addArtboard() {
  var firstArtBoard = myDocument.artboards[0];
  for(var prop in firstArtBoard) {
    if(firstArtBoard.hasOwnProperty(prop)) {
      $.writeln(prop);
    }
  }
  
  $.writeln(firstArtBoard.artboardRect);
  var x1 = firstArtBoard.artboardRect[2] + 10;
  var y1 = firstArtBoard.artboardRect[1];
  var x2 = x1 + firstArtBoard.artboardRect[2];
  var y2 = firstArtBoard.artboardRect[3];
  myDocument.artboards.add([x1, y1, x2, y2]);
}

for (i = 0; i < myDocument.dataSets.length; i++) {
  var wineType = myDocument.dataSets[i];
  var newBoard = myDocument.artboards[i];
  addArtboard(i);
  newBoard.dataSet = wineType;
}

 

(all the code for creating a new artboard from here)

It creates 9 long artboards on top of one another to the right of the initial one-- I realize now this is due to the createArtboard() referencing the initial artboard when specifying the new position, but again, I'm unsure how to fix the position or size. I would attach the illustrator file, but it's coming up with a strange error that prevents it.

 

forum2.JPG

 

Any help is appreciated!

 

TOPICS
Scripting , Tools

Views

1.3K

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

Valorous Hero , Jun 10, 2020 Jun 10, 2020

Scripting along with datasets to affect a single document can be a special challenge, because dataset processing is mostly geared toward exporting single-state documents based on the variable template. However, they do give us an option to actually work on the one document and not do any exporting via this option inside the Batch Actions dialog: Destination None.

In your case you may be able to use just the native batch actions to accomplish most of your needs and potentially use smaller auxilli

...

Votes

Translate

Translate
Adobe
Community Expert ,
Jun 10, 2020 Jun 10, 2020

Copy link to clipboard

Copied

Can't help you with the script, but to show AI files, please upload them to Dropbox or Creative Cloud and post a link in the forum. 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
Valorous Hero ,
Jun 10, 2020 Jun 10, 2020

Copy link to clipboard

Copied

Scripting along with datasets to affect a single document can be a special challenge, because dataset processing is mostly geared toward exporting single-state documents based on the variable template. However, they do give us an option to actually work on the one document and not do any exporting via this option inside the Batch Actions dialog: Destination None.

In your case you may be able to use just the native batch actions to accomplish most of your needs and potentially use smaller auxilliary scripts to help other aspects of the workflow.

I created a sample test based on this use case and wonder if it would help you. Here is what it does: it uses actions and the batch process to copy some template artwork in the document and place it at a chosen distance from the last active artboard, then it creates a new artboard for the copied artwork. The copied artwork is going to be the live variable-bound art which will get populated with new text or images on the next dataset cycle.

Luckily the behavior of copy/pasting in Illustrator when it comes to variable-bound art does paste the item back in without the variable being bound, which is a good thing for this process.

 

Here is the document setup: there is one layer with one group in it. This group has a textframe named "name" and a rectangle the size of the artboard in it. More in-depth the group actually has a special note in it inside of Attributes > notes that says "original". The yellowish rectangle also has a note in it that says "bg". These are used later by the action.

Silly-V_0-1591777249926.png

Here is the action:

Silly-V_1-1591777479103.png

  1. Set Selection - selects all objects whose note has "original".
  2. Copy - copies the selected group (the original group).
  3. Deselect All - deselects the original item selection so that the next paste can go into a new layer.
  4. Layer (New Layer) - makes a new layer which is now the active targeted (blue highlight) item in the Layers panel.
  5. Paste in Front - pastes the copied original group into the new layer.
  6. Alignment (Vertical Align Botton) - the pasted art is still selected and it gets aligned to the last active document artboard. Note: make sure to leave your alignment options on "Align to Artboard", not "Align to Selection".
  7. Move - moves the pasted art downward from where it was last aligned to an active artboard, which should be the last bottom-most artboard as this artboard collection expands downwards.
  8. Attribute Setting (Note:) - the pasted art is still selected, and now the action erases the word "original" from the selected group's notes. To remove all notes, simply delete the note text inside the Attributes > note section.
  9. Layer (Enter Isolation Mode) - there are many ways to go about this, but my easiest way was to enter isolation mode (recordable as a flyout menu item inside the layers panel) and duplicate a path in order to convert it to a new artboard. Entering isolation mode allows the rectangle with the note "bg" to exist in multiple places such as in the result state of the document, but the action can still use it only on a single group as intended.
  10. Set Selection - selects all objects whose note has "bg", which is the background rectangle the size of the artboard as part of the original art.
  11. Copy - copy the selected rectangle.
  12. Paste in Front - paste this rectangle in front of itself.
  13. Convert to Artboards - found in Object > Artboards > Convert to Artboards menu item, this option will turn any selected rectangle into a new artboard.
  14. Layer (Exist Isolation Mode) - now it's time to exit isolation and repeat the process with the turn of the next dataset.

 

Now let's run the process.

Silly-V_2-1591778388589.png

 

Remember, the batch action dialog can be set to a source of Data Sets and a Destination of None, which will export no files but allow you to run a series of custom actions on the same document for each dataset record.

The batch actions play and create the new artboards with the different versions of editable art on their separate layers.

The very first layer contains the original artwork that is bound to the variables, and it has the values of the very last dataset after the process is over. You could hide or delete this artwork, choose to keep it and ignore this first artboard when using asset export or do whatever you wish with this extra artboard as it suits your workflow.

Silly-V_3-1591778914901.png

 

Batch-Artboard-Video.gif

Well, I hope this helps in some way. Now, you may have noticed how although it is very nice that these new layers and artboards get made, but they are all named generic such as "Artboard 1". This is where other tiny helper scripts could come in handy should you also wish to do something actions absolutely can't during the batch process. It would be nice if a very simple script could just name the current layer or new artboard to some specific variable's value. Using the Insert Menu item it's possible to insert a custom script to play on each dataset inside of the action. Such a script could even be made to sense whether the current dataset is the last one, or first one, and do something extra to the document like cleaning up and removing the very first original 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
New Here ,
Jun 11, 2020 Jun 11, 2020

Copy link to clipboard

Copied

Thank you so so much! This is exactly what I needed. You just saved me hours of work!

 

I'm sure there's a way to script it so the names will automatically match a variable, but that sort of thing is way beyond me haha. Thank you again for such a clear and helpful tutorial!

 

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 ,
Mar 29, 2021 Mar 29, 2021

Copy link to clipboard

Copied

This would be great as a downloadable action 🙂

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 ,
Aug 06, 2021 Aug 06, 2021

Copy link to clipboard

Copied

Hi,

I have a bit stupid question 😄
step number one, 

1- Set Selection - selects all objects whose note has "original".
how to select all objects with certain note?
Also, what do I need to change in your action to do the same copies in the same artboard
I need to duplicate the lable within the same artboard using next dataset everytime
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 Expert ,
Aug 06, 2021 Aug 06, 2021

Copy link to clipboard

Copied

quote

1- Set Selection - selects all objects whose note has "original".


By @Taha Moussa

 

The action panel's menu has an option called 'Select Object'.

It's not a stupid question. It's obscure for most users.

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 ,
Aug 06, 2021 Aug 06, 2021

Copy link to clipboard

Copied

Thank you so much

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 03, 2023 Oct 03, 2023

Copy link to clipboard

Copied

LATEST

Thanks you the tip.

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