Highlighted

Illustrator Javascript - Binding variables of imported csv to art objects

New Here ,
Aug 06, 2020

Copy link to clipboard

Copied

Hi,

 

I'm very new to scripting and I'm in the middle of developing a small script that imports data of a csv (only one dataset) and exports that dataset as a pdf.

 

The step I'm struggling with is, after importing the csv and the variables are visible in the panel, I need to make them dynamic and bind them to their respective objects before I can export the document.

Ideally, I would like it bind them by name (as it's possible with the variableImporter.jsx script) so that they bind to objects that have the same name as the variables themselves.

 

However, I don't really get how to do this. The closest info to this solution I've found is this one, where all text is made dynamic by creating a variable:

 

https://community.adobe.com/t5/illustrator/script-to-make-all-text-dynamic/td-p/3521197?page=1

 

But I don't seem to find anything that relates to binding the already imported variables.

 

Snag_1edad1c7.png

 

Any ideas?

 

I'm grateful for any tips.

Adobe Community Professional
Correct answer by CarlosCanto | Adobe Community Professional

if the variables are already made, you would loop through each of them, find an object with the same name as the variable then assign the variable to its contentVariable property.

 

var idoc = app.activeDocument;
var variables = idoc.variables;

for (var a=0; a<variables.length; a++) {
    idoc.pageItems[variables[a].name].contentVariable = variables[a];
}

  

TOPICS
Scripting

Views

70

Likes

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

Illustrator Javascript - Binding variables of imported csv to art objects

New Here ,
Aug 06, 2020

Copy link to clipboard

Copied

Hi,

 

I'm very new to scripting and I'm in the middle of developing a small script that imports data of a csv (only one dataset) and exports that dataset as a pdf.

 

The step I'm struggling with is, after importing the csv and the variables are visible in the panel, I need to make them dynamic and bind them to their respective objects before I can export the document.

Ideally, I would like it bind them by name (as it's possible with the variableImporter.jsx script) so that they bind to objects that have the same name as the variables themselves.

 

However, I don't really get how to do this. The closest info to this solution I've found is this one, where all text is made dynamic by creating a variable:

 

https://community.adobe.com/t5/illustrator/script-to-make-all-text-dynamic/td-p/3521197?page=1

 

But I don't seem to find anything that relates to binding the already imported variables.

 

Snag_1edad1c7.png

 

Any ideas?

 

I'm grateful for any tips.

Adobe Community Professional
Correct answer by CarlosCanto | Adobe Community Professional

if the variables are already made, you would loop through each of them, find an object with the same name as the variable then assign the variable to its contentVariable property.

 

var idoc = app.activeDocument;
var variables = idoc.variables;

for (var a=0; a<variables.length; a++) {
    idoc.pageItems[variables[a].name].contentVariable = variables[a];
}

  

TOPICS
Scripting

Views

71

Likes

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
Aug 06, 2020 0
Adobe Community Professional ,
Aug 06, 2020

Copy link to clipboard

Copied

if the variables are already made, you would loop through each of them, find an object with the same name as the variable then assign the variable to its contentVariable property.

 

var idoc = app.activeDocument;
var variables = idoc.variables;

for (var a=0; a<variables.length; a++) {
    idoc.pageItems[variables[a].name].contentVariable = variables[a];
}

  

Likes

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
Reply
Loading...
Aug 06, 2020 1
New Here ,
Aug 06, 2020

Copy link to clipboard

Copied

Wow, thank you so much Carlos!

 

You're a life saver!

Likes

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
Reply
Loading...
Aug 06, 2020 0