Skip to content

Instantly share code, notes, and snippets.

@shaneparsons
Last active May 19, 2016 16:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shaneparsons/1717f21a757f24fb4559 to your computer and use it in GitHub Desktop.
Save shaneparsons/1717f21a757f24fb4559 to your computer and use it in GitHub Desktop.
Illustrator Script - Batch Export Symbols as PNGs
var doc = app.activeDocument;
var symbolCount = doc.symbols.length;
if (symbolCount >= 1) {
if (confirm("Are all your layers hidden?")) {
// choose directory
var dest = Folder(doc.path).selectDlg();
// folder chosen
if (dest) {
// create temp layer
doc.layers.add();
// loop through symbols
for (var i = 0; i < doc.symbols.length; i++) {
// place a symbol instance - temp
var symbol = doc.symbolItems.add(doc.symbols[i]);
// assign name
var filename = (doc.symbols[i].name)
// export symbols
savePNG(dest, filename);
// delete temp symbol instance
symbol.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");
}
@shaneparsons
Copy link
Author

Note: This script seems to have issues since Illustrator added dynamic symbols. I wouldn't recommend using it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment