-
Notifications
You must be signed in to change notification settings - Fork 64
/
Stats.sketchplugin
44 lines (40 loc) · 1.15 KB
/
Stats.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
39
40
41
42
43
44
// Show stats for document
// Pages
var pages = [doc pages],
page_count = [pages count],
artboard_count = 0,
layer_count = 0
// Artboards
for (var i=0; i < [pages count]; i++) {
var page = [pages objectAtIndex:i]
var artboards = [page artboards]
artboard_count += [artboards count]
var all_items = [page children]
for (var j=0; j < [all_items count]; j++) {
var item = [all_items objectAtIndex:j]
log([item className])
if ([item className] != "MSPage" && [item className] != "MSArtboardGroup" && [item className] != "MSRectangleShape" && [item className] != "MSOvalShape" && [item className] != "MSStarShape" && [item className] != "MSPolygonShape" && [item className] != "MSTriangleShape" && [item className] != "MSShapePathLayer") {
log("Adding")
layer_count++
}
}
}
var msg = "Stats: " + page_count + " page"
if (page_count > 1) {
msg += "s"
}
if (artboard_count > 0) {
msg += ", " + artboard_count + " artboard"
if (artboard_count > 1) {
msg += "s"
}
}
if (layer_count > 0) {
msg += ", " + layer_count + " layer"
if (layer_count > 1) {
msg += "s"
}
}
msg += "."
log(msg)
[doc showMessage:msg]