Skip to main content
Participant
November 6, 2008
Question

Illustrator scripting with datasets & variables

  • November 6, 2008
  • 2 replies
  • 1966 views
I have a .ai file with 3 datasets containing 2 variables each. I am new to adobe scripting and am trying to write a script that will loop through the 3 datasets, swap out the variables, and save as 3 different .pdf files. I can loop and export, but don't know how to access the variables.

Here is a snipped from what I have:

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

var ds1 = docRef.dataSets.getByName('ABC'); // ABC is a client name, but numeric index is required
//var ds1 = docRef.dataSets.index(1); // this doesn't seem to work, but i need it to
docRef.activeDataset = ds1;

// I need to access the dataset variables here, where ClientName is a variable name within the dataset
client_name = ?????;

ds1.display();
app.redraw();

// ----- save changes
filepath = '/Users/me/Documents/clients/'+client_name+'.pdf';
saveInFile = new File( filepath );
pdfSaveOpts = getPDFOptions( );
docRef.saveAs( saveInFile, pdfSaveOpts );
}

Thanks for any help
This topic has been closed for replies.

2 replies

Known Participant
November 12, 2008
markr34,

I have never done any dataset scripting, but my eyes tell me that at this line:

//var ds1 = docRef.dataSets.index(1); // this doesn't seem to work, but i need it to

you'd probably want to use square brackets [1] rather than parentheses to refer to array by index.

HTH
JETalmage
Inspiring
November 7, 2008
Are you aware that you can do that with an Action in Batch mode, and avoid resorting to scripting?

JET