1

I use Illustrator as my main graphics program for building modular UI components.

enter image description here

Context: I'm exploring an animation software, Pixate, and will need to upload all UI assets to the project library — is there any way to make this any easier by somehow batch exporting all the symbols in a Symbol Library?

I have not yet been able to find a solution online that solves this, and would appreciate any direction!

  • 1
    Hi Ksy, have you checked out this thread already? Export Symbol as PNG – AndrewH Apr 15 '15 at 17:14
  • Wow, I must be bad at googling things :/ Perfect -- thank you! I will try this scripting solution out – ksy Apr 15 '15 at 17:15
  • This seems to be a great solution for elements of same size (e.g., icons) -- also appears to require dragging and dropping all symbols onto an artboard and making a grid -- I think I'll wing it this time, but I'll be using Photoshop next time to make this process easier and slice the UI components :) – ksy Apr 15 '15 at 17:24
  • Although this is not a way to batch export, I feel that the solution from this thread in using Command-Option-Shift-3 (Mac) saves me the most manual tasks – ksy Apr 15 '15 at 17:49
  • If you did have all objects pasted into the document wouldn't the answer from Jonathan be faster? – AndrewH Apr 15 '15 at 17:56
3

The following script will export all your symbols from the symbol library and save them to a chosen folder.

You just have to make sure all your layers are hidden first.

var doc = app.activeDocument;
var symbolCount = doc.symbols.length;

if (symbolCount >= 1) {

    if (confirm("Are all your layers hidden?")) {

        // create temp layer
        doc.layers.add();

        // create directory
        var dest = Folder.selectDialog();
        dest.create();

        // loop through symbols
        for (var i = 0; i < doc.symbols.length; i++) {

            // place a symbol instance - temp
            var s = doc.symbolItems.add(doc.symbols[i]);         

            // assign name
            var filename = (doc.symbols[i].name)

            // export symbols
            savePNG(dest, filename);

            // delete temp symbol instance
            s.remove();
        }
        // remove temp layer
        doc.layers[0].remove();
    }

    function savePNG(dest, filename) {
        // save options
        var type = ExportType.PNG24;
        var options = new ExportOptionsPNG24();
        options.transparency = true;

        // file
        var file = new File(dest + "/" + filename);

        // export
        doc.exportFile(file, type, options);
    }

} else {
    alert("You don't have any symbols in this document");
}

You can find this script at: https://gist.github.com/shaneparsons/1717f21a757f24fb4559

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.