-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathFrom Artboards.sketchplugin
38 lines (30 loc) · 1.18 KB
/
From Artboards.sketchplugin
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// Sketch Plugin: Export to ICNS From Artboards (option shift command a)
// Source: https://github.com/solicomo/export-to-icns
// Version: 0.1.1
// Author: Soli
@import 'common.jst'
(function() {
var iconPath = save_path()
var tmpPath = NSTemporaryDirectory()
var guid = [[NSProcessInfo processInfo] globallyUniqueString]
var iconsetPath = [tmpPath stringByAppendingPathComponent: guid + @".iconset"]
var fileManager = [NSFileManager defaultManager]
[fileManager createDirectoryAtPath:iconsetPath withIntermediateDirectories:true attributes:nil error:nil]
var artboardCount = [[[doc currentPage] artboards] count]
if (artboardCount < 1) {
[doc showMessage:"Failed: No artboard or slice found."]
return false
}
var artboards = [[doc currentPage] artboards]
for (var i=0; i < artboardCount; i++) {
var artboard = [artboards objectAtIndex:i]
var artboardName = [artboard name]
var fileName = [iconsetPath stringByAppendingPathComponent: artboardName + ".png"]
if ([artboardName hasSuffix:@"Lock"]) {
continue
}
[doc saveArtboardOrSlice:artboard toFile:fileName]
}
convert_iconset_to_icns(iconsetPath, iconPath)
[fileManager removeItemAtPath:iconsetPath error:nil]
})();