Exporting multiple sizes in sketch. Saving it as defaults?


I'm trying to figure out the way to keep my export sizes and prefix names as default options,

When I do it to mobile I have to create 7 diferents sizes and prefixes

I design in @3x so I have to export then for iOS and Android like: Sketch exporting layer properties

So every time I create a new doc, I'm repeating this process like 20 times per day.

Let me know if you know how to perform this easier.

Note: I also tried some export plugins for mobile, but those all export my buttons without the transparent background. I mean, they add the background on it ( I can't export only the button with transparent bg)

Thanks for answering!

6/1/2015 8:44:00 PM

Accepted Answer

Well, I programmed a script for doing this. It's pretty simple:

1 - Select a layer and then,( CMD + Shift + A ) and automatically generates this:

So you can export the layers really fast.

This is the code inside the .sketchplugin file I created (Copy and Paste it into a empty textFile and save it like exportPlugin.sketchplugin

Here is the code-->

// (shift cmd a) if (selection.length() > 0){

for (var i=0; i < selection.length(); i++){ addExportSizes(selection[i])
} [doc showMessage:"Export Options Added"] }else{ var app = [NSApplication sharedApplication]; [app displayDialog:"Anything selected :(" withTitle:"Exportabler"]; } function addExportSizes(layer){ var iOSExportData = [ { "format": "png", "scale": 1/3, "suffix": "" }, { "format": "png", "scale": 2/3, "suffix": "@2x" }, {
"format": "png", "scale": 3/3, "suffix": "@3x" }, { "format": "png", "scale": 1/3, "suffix": "mdpi" }, { "format": "png", "scale": 1/2, "suffix": "hdpi" }, { "format": "png", "scale": 2/3, "suffix": "xhdpi" }, {
"format": "png", "scale": 3/3, "suffix": "xxhdpi" } ] var export_options = [layer exportOptions] var export_sizes = [export_options sizes] while([export_sizes count] > 0) { [[export_sizes firstObject] remove] } for (var i = 0; i < iOSExportData.length; i++) { var size_data = iOSExportData[i] var size = [[layer exportOptions] addExportSize] [size setFormat:size_data.format] [size setScale:size_data.scale] [size setName:size_data.suffix] } [[doc currentPage] deselectAllLayers] [layer select:true byExpandingSelection:true] }

6/12/2015 11:55:00 AM