abynim / Sketch-Headers

Headers from Sketch app exported using class-dump
463 stars 74 forks source link

Export requests are failing in update 44? #9

Closed geraldeersteling closed 7 years ago

geraldeersteling commented 7 years ago

Hi,

Does anyone knows what they changed in exporting artboards in update 44? I wrote a plugin to export artboards, but with the update the exported artboards are "empty". I do see the PNG exported to the correct path (and everything is correct; the size, name, format etc.) but the PNG is "empty" (see screenshot)

screen shot 2017-05-17 at 15 50 41


The snippet I'm using to export the file is:

doc = context.document
var path // <-- assume this is a valid file URL
var layer // <-- assume this is a valid MSArtboardGroup
if (!layer.isLayerExportable()) {
    print([NSString stringWithFormat:"The layer [%@] is not exportable!", layer.name()])
    return
}

var requests = NSMutableArray.array()

for (var i = 0; i < layer.exportOptions().exportFormats().length; i++) {
    var format = layer.exportOptions().exportFormats()[i]
    var request = [MSExportRequest exportRequestFromExportFormat:format layer:layer inRect:layer.absoluteInfluenceRect() useIDForName:true]
    request.name = (format.name()) ? format.name() : request.name()
    requests.addObject(request)
}

// Loop all requests and export each of them
for(var k = 0; k < requests.length; k++) {
    var request = requests[k]
    exportName = request.name()
    exportPath = [path stringByAppendingPathComponent:exportName]
    exportPath = [exportPath stringByAppendingPathExtension:request.format()]

    [doc saveArtboardOrSlice:request toFile:exportPath]
    var msg = [NSString stringWithFormat:"Saved: %@ to %@", exportName, exportPath]
    log(msg)
}

Before the snippet worked perfectly, but right now I do see the message that the file is saved/exported but encounter the problems I stated before.

Does anyone knows what must be changed to export correctly?

abynim commented 7 years ago

Please post plugin-related questions on the forum at http://sketchplugins.com