Skip to main content
Participating Frequently
July 5, 2011
Question

Script to Make all text Dynamic

  • July 5, 2011
  • 2 replies
  • 22894 views

Is there a way or a script that will make all the text on a page Dynamic? At the moment we have to select each text box and press 'make text dynamic', which can get tiresome with a lot of text boxes. If we select all the text boxes and do the same we get a lot of variables with the same name which gives an error.

So we need a script that can make it all dynamic with different named variables.

Anyone....

This topic has been closed for replies.

2 replies

bsf2017
Inspiring
April 12, 2017

How can I test the length of the itext variable, i.e. how long the text in my text box is?

itext.contentVariable.length produces "unknown".

Thanks

Silly-V
Legend
April 13, 2017

You can only do this when the variable's text is populated into the text frame. It then could be retrieved like this: app.activeDocument.textFrames[0].contents

CarlosCanto
Community Expert
Community Expert
July 6, 2011

here you go, it doesn't deal with errors. Delete all existing variables before running.

#target illustrator

// script.name = makeAllTextDynamic.jsx;

// script.description = makes ALL text Dynamic, creates Variables;

// script.required = one document with at leas one textFrame;

// script.parent = CarlosCanto // 7/5/11;

// script.elegant = false;

var idoc = app.activeDocument;

for (i=0; i<idoc.textFrames.length; i++)

     {

          var itext = idoc.textFrames;

          var idocvar = idoc.variables.add();

          idocvar.kind = VariableKind.TEXTUAL;

          itext.contentVariable = idocvar;

     }

Participant
February 6, 2017

Dear Carlos,

the script you wrote is amazing! I was looking for something like this for a long time and I think it's a great way to translate text in Illustrator.

I only have one problem: the script only works with text selected that is not in groups. If the text is in a seperate group, then it is not used to make a variable.

Illustrator handles groups that hosts text-elements really strangely but in a big project, we need this file structure. Most often it is this kind of text we have:

Unfortunately your script doesn't use these text elements for the "make-variable" routine.

However, as soon as any other elements (like lines, paths, cicles) are part of the group - it's working just fine!

I think, illustrator handles Groups with only text inside differently than groups that contain multiple kinds of data in it.

Is there any possible way your script could be adapted to solve this problem? Then I could just select all text and make it variables - it would be amazing!

Thanks for your efforts and best regards

Hannes

bsf2017
Inspiring
April 6, 2017

the first version I posted works with grouped text frames. I just tested it on windows 10, Ai CC2017


How can I go the next step and save the dataset to an xml file in a certain directory?

Here is my start:

var destFolder = null;

        destFolder = Folder.selectDialog( 'Select folder for XML files.', '~' );

Thanks