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

Illustrator Javascript - Binding variables of imported csv to art objects

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

TOPICS
Scripting

Views

835

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 Expert , Aug 06, 2020 Aug 06, 2020

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];
}

  

Votes

Translate

Translate
Adobe
Community Expert ,
Aug 06, 2020 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];
}

  

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

Copy link to clipboard

Copied

LATEST

Wow, thank you so much Carlos!

 

You're a life saver!

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