Recursive Exporter for Adobe Illustrator

Whether working on my own or with a graphic designer, I believe in the holistic approach to design — you have to see how the design elements interact with each other.

Most if not all designers would agree that it is less effective to tweak a widget’s design on its own without the ability to easily gauge how the change will affect the overall look. However this is exactly what the ‘resource approach’ requires, as each design element has to be in a different file and it is only after an export, compile and run cycle that you see how it all fits together.

This is less than optimal, so you would typically follow a different flow.

To enable you to see how the design elements interact without requiring an export, you would arrange a design mockup within Photoshop with each design element as a layer (and/or sub-layers in later versions) and perform all the design work right there. This is what every graphic designer does and theoretically it is then just a matter of exporting the layers (and sublayers) to files.

Good so far, but usually this is where the trouble starts — as many times the export process involves a lot of tiny elements which all require export to different files. Usually this is done outside the build process by a 3rd party graphic artist who sends you the exported files by eMail and sometimes forgets to export one or more of the elements. Only when this is finally settled, does the result gets tested within the build… And… Guess what, there’s a problem.

*Sigh*

It was to make my life easier and to enable the graphics design to be a full (and honored!) member of the automated build cycle, that I automated this export process.

Ages ago, before Photoshop scripting I wrote a small utility called PSD Ripper that simply parsed the Photoshop 6 .PSD file and converted individual layers into individual PNG files, it also used the layer name as the basis for the PNG filename. Later versions of Photoshop made it much easier — to achieve the same result I merely had to make a tiny modification to a small script that came with Photoshop.

However, as great as Photoshop is, lately I have come to appreciate a vector-oriented approach to design and have been using Adobe Illustrator to do the design work. Therefore, I needed a script that would enable me to continue with the same workflow except with Illustrator instead of Photoshop and as none was available, I wrote one.

Thus I present “Recursive Exporter for Adobe Illustrator v1.0“, tested with Adobe Illustrator CS2 12.0.

The lay of it:

Recursive Exporter for Adobe Illustrator v1.0 (2006)

What it does?
Recursively export layers and groups from Adobe Illustrator to 24-bit PNG (with alpha/transparency) support. Does smart naming of files and the level of recursion can be limited.

Usage:
The usage is pretty simple, once you run the script it will ask you to which folder to output the results and how deep it should recurse beyond the top layers. It will then output each visible non-locked element as a 24-bit PNG anti-aliased, alpha-transparency enabled file. Then the script will recurse into the element (if it is a layer or group) and do the same for each of its components.

The name for the output file is constructed recursively, so if you have a ‘logo’ group within a ‘banner’ layer it will export the group as ‘banner-logo.png’. Note that Illustrator enforces a 31-character filename limit.

If you want to create a background matte layer that will be included in every element simply add a visible, locked layer. It will not be exported on its own but will be visible when the elements are exported and thus included in them.

Problems:
Please report any bugs or problems with this script to the comments section.

License:
The script is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 2.5 License and is made available with absolutely no warranty or guarantee.
Technorati tags: , , , , ,