6

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!

  • Maybe there are exporting scripts for sketch that do what you want. – Joonas Jun 2 '15 at 9:34
6

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:

http://i.stack.imgur.com/trpdg.png

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] }

| improve this answer | |
  • This script didn't work for me... Is this still working for you in the current version of Sketch? – bmueller Apr 13 '16 at 16:22
  • No.. Not any more :( – angeant Apr 13 '16 at 16:27

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.