Illustrator script, improving performance

(I’ve sent a similar mail to ASUL, but I wanted to add some background here).

Last year, @ShaneStanley wrote a wonderful Illustrator script that has helped me tremendously for work. The original script was written on an Adobe support forum, in Javascript, but Shane greatly improved it’s functionality, and most importantly wrote it in AppleScript :slight_smile:.

Basically, it extracts all the text boxes contents to variables and I can then save the variables to XML, translate them and the open the new variable list to have the translation automatically be reflected in the text boxes. If you know people in the translation industry, let them know that’s the way to got (I wish InDesign could be dealt with that way but it seems way more complex).

Anyway, I had a 24 pages layout to translate, with about 950 text boxes and the script took 2 hours to complete, taking an average 7 seconds for each box.

So, I’m wondering what would be the way to drastically improve the performance of that script…

On Jan 23, 2017, at 7:18, Shane Stanley sstanley@myriad-com.com.au wrote:

On 23 Jan 2017, at 1:51 am, Jean-Christophe Helary jean.christophe.helary@gmail.com wrote:
The process is a bit slow

You can probably speed it up a bit by either running it from AI’s menu, or wrapping it in a script object:

script addVariables
	tell application id "com.adobe.illustrator" -- Adobe Illustrator
		tell document 1
			set theSel to selection
			my addVariablesFor:theSel
		end tell
	end tell
	
	on addVariablesFor:listOfItems
		tell application id "com.adobe.illustrator" -- Adobe Illustrator
			tell document 1
				repeat with anItem in listOfItems
					set theClass to class of anItem
					if theClass is text frame then
						set theVar to make new variable at end with properties {kind:textual}
						set anItem's content variable to theVar
					else if theClass is group item then
						(my addVariablesFor:(page items of anItem))
					end if
				end repeat
			end tell
		end tell
	end addVariablesFor:
	
end script

tell application id "com.adobe.illustrator" -- Adobe Illustrator
	run script addVariables
end tell

The designer who first ran the script had Illustrator crash at about 700 variables. Both on Windows 10 and in macOS in either case with 16gb of ram. My (2011) MBP also has 16gb but was able to complete the task.

The only obvious thing I can think of is the low-tech approach of turning off previews and resizing the window very small, with no elements visible.

As for the crash, I’m not sure what to suggest. I suppose it could be too much recursion. I’m intrigued to know how it crashed under Windows 10, though :thinking:

Thank you for the hints. I’ll try that with next job. As for W10, I’ll ask the designer.

Interesting result… I tried to run the script from IA with the data out of sight and that’s how IA crashed.

When I run the script from SD, no crash and the script proceeds slowly to completion.

1 Like

Bummer. Make sure you report it here:

https://illustrator.uservoice.com

2 Likes

Thank you for significant information!