Closed cmyk closed 9 years ago
Yes please attach an example sketch file :smiley: I still need to update this plugin... Hopefully I can find some time in the near future.
Hi Geert,
here it is (attached a zip to this email, but not sure, you'll get it). We actually fixed your script for the other issue I reported. https://github.com/GeertWille/sketch-to-xcode-assets-catalog/issues/14
Cheers Philipp
--- main.js
+++ (clipboard)
@@ -106,6 +106,8 @@
jsonPath = '',
lineBuffer = [];
+// com.geertwille.general.alert("Path"+cutSliceName);
+
// Find out our extension to save image with
if (fileType == "j_") {
imageExtension = ".jpg";
@@ -132,12 +134,13 @@
// Loop over all the factors and save the lines to a lineBuffer
array
for (var i = 0; i < this.factors.length; i++) {
+ var fileName = sliceName.trim().substring(sliceName.lastIndexOf('/')+1);
var name = this.factors[i].folder,
scale = this.factors[i].scale,
suffix = this.factors[i].suffix,
version = this.copyLayerWithFactor(slice, scale),
- relativeFileName = cutSliceName + suffix + imageExtension,
- absoluteFileName = this.baseDir + "/" +
this.defaultAssetFolder + "/" + cutSliceName + ".imageset/" + cutSliceName
+ suffix + imageExtension;
+ relativeFileName = fileName + suffix + imageExtension,
+ absoluteFileName = this.baseDir + "/" +
this.defaultAssetFolder + "/" + cutSliceName + ".imageset/" + fileName +
suffix + imageExtension;
[doc saveArtboardOrSlice:version toFile:absoluteFileName];
I cannot attach sample files here. Where should I send them to?
It's quite simple: If you have a folder with graphics in it (group) and then create a slice for exporting those graphics and that slice is in the same folder (and has only export group contents checked), the script hides the layers in that folder.
If you just comment line 46 in main.js:
//this.hideLayers(root, layer);
it's exporting the folder's contents all right. But this of course breaks other things. ;)
Basically need something like this.hideLayersExceptFromGroup(root, layer, currentGroup);
instead of this.hideLayers(root, layer);
.
Currently just getting rid of this.hideLayers(root, layer);
means it'll include everything in exported asset (i.e. layers from outside the group).
@cmyk Here you go:
if (target.className() == "MSSliceLayer" && currentLayer == [target parentGroup]) {
continue;
}
Insert this below var currentLayer = [[root layers] objectAtIndex:k];
in hideLayers
function. If all goes well, I'll make a pull request for this. Let me know.
@Gurpartap Great, it works! Thx!
The plugin doesn't export slice layers correctly. The images are blank. A normal sketch export, exports the same slice layers correctly.
The plugin only seems to work on group/object exports. I can send you a little sample file, if you want.