Last active
May 19, 2016 16:26
-
-
Save shaneparsons/fffd6bc6f8e80f84a381 to your computer and use it in GitHub Desktop.
Illustrator Script - Batch Export Symbols as SVGs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | |
// create temp artboard | |
doc.artboards.add(doc.artboards[0].artboardRect); | |
// get temp artboard | |
var tempAB = doc.artboards.getActiveArtboardIndex(); | |
// 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]); | |
// resize artboard | |
doc.artboards[tempAB].artboardRect = doc.visibleBounds; | |
app.redraw(); | |
// choose directory | |
var filename = doc.symbols[i].name; | |
// export symbols | |
saveSVG(dest, filename); | |
// delete temp symbol instance | |
symbol.remove(); | |
} | |
// remove temp layer | |
doc.layers[0].remove(); | |
// remove temp artboard | |
doc.artboards[tempAB].remove(); | |
} | |
} | |
function saveSVG(dest, filename) { | |
// save options | |
var type = ExportType.SVG; | |
var options = new ExportOptionsSVG(); | |
// file | |
var file = new File(dest + "/" + filename); | |
// export | |
doc.exportFile(file, type, options); | |
} | |
} else { | |
alert("You don't have any symbols in this document"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Note: This script seems to have issues since Illustrator added dynamic symbols. I wouldn't recommend using it.