Copy link to clipboard
Copied
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....
Copy link to clipboard
Copied
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;
}
Copy link to clipboard
Copied
Wow thanks for this! I just starting using this for some translation work I'm doing.
One question - how could I get it to only look at what is on the artboard and ignore text boxes that are on the pasteboard?
Thanks in advance! Very appreciated.
Copy link to clipboard
Copied
here you go, I thought it would be better if it works with selected objects, instead of what's in the artboard...so, select your text before running. You can marquee around your art and select other objects if they are in your way, they will all be ignored, only text will be turned into variables
#target illustrator
// script.name = makeSelectedTextDynamic.jsx;
// script.description = makes SELECTED text Dynamic, creates Variables;
// script.required = one document with at leas one textFrame;
// script.parent = CarlosCanto // 2/15/13
// script.elegant = false;
var idoc = app.activeDocument;
var sel = idoc.selection;
for (i=0; i<sel.length; i++) {
var itext = sel;
if (itext.typename=="TextFrame") {
var idocvar = idoc.variables.add();
idocvar.kind = VariableKind.TEXTUAL;
itext.contentVariable = idocvar;
}
}
Copy link to clipboard
Copied
I've been trying the script with a relatively old Mac (OSX 10.5.9, 4gb ram) but Illustrator seems to run out of memory at one point for the biggest document.
After testing on a different machine, I get a variable library with 497 items, mostly short strings as one could find on a map, but the other side of the map that has 391 strings processes fine on this Mac.
The "bad" side of the map seems to have a very big number of non text items, so I'm guessing that if the script runs through all the items to search for "TextFrame" then it is bound to use a lot of memory.
Is there a way to limit the script to the layers that are supposed to include text boxes ? or to optimize it so that Illustrator does not accumulate all the data in memory and eventually crashes ?
Jean-Christophe Helary
Copy link to clipboard
Copied
are you running it from the ESTK? or within Illustrator?
this one processes the Active Layer only
#target illustrator
// script.name = makeActiveLayerTextDynamic.jsx;
// script.description = makes ALL text in the Active Layer Dynamic, creates Variables;
// script.required = one document with at least one textFrame;
// script.parent = CarlosCanto // 04/17/14;
// script.elegant = false;
var idoc = app.activeDocument;
var ilayer = idoc.activeLayer;
for (i=0; i<ilayer.textFrames.length; i++)
{
var itext = ilayer.textFrames;
var idocvar = idoc.variables.add();
idocvar.kind = VariableKind.TEXTUAL;
itext.contentVariable = idocvar;
}
Copy link to clipboard
Copied
Thank you Carlos.
I am running the script from Illustrator. I am a translator so I have no idea of how Illustrator works and how to use it... I just follow the instructions here.
Also, it appears that regions of the document that are "masked" (?) don't seem to be parsed for text boxed. The DTP operator send me "unmasked" data for the parts that had not been put into the variable library.
So, following up on your solution above, let me ask 2 questions:
1) how to select a layer to make it active ?
2) how to "unmask" data so that it is available to the script ?
Jean-Christophe Helary
Copy link to clipboard
Copied
Hi! I know this is a very old post but I will try a longshot here anyway. I am not experienced in scripting for Adobe applications, but I tried copying your script and saving it with an jsx extension but no variables are created when I select text and run script from Files menu. Any Idea what I might be doing wrong?
Best regards
Are
Copy link to clipboard
Copied
#target illustrator
// script.name = makeActiveLayerTextDynamic.jsx;
// script.description = makes ALL text in the Active Layer Dynamic, creates Variables;
// script.required = one document with at least one textFrame;
// script.parent = CarlosCanto // 04/17/14;
// script.elegant = false;
var idoc = app.activeDocument;
var ilayer = idoc.activeLayer;
for (i = 0; i < ilayer.textFrames.length; i++) {
var itext = ilayer.textFrames[i];
var idocvar = idoc.variables.add();
idocvar.kind = VariableKind.TEXTUAL;
itext.contentVariable = idocvar;
}
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
the first version I posted works with grouped text frames. I just tested it on windows 10, Ai CC2017
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
What you are looking for is the document.exportVariables(File) function. Use it to save a .xml file, it will have all the document's variables and datasets inside.
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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