Closed mikegowen closed 10 years ago
I think I remember having trouble with that in the past. I'm fuzzy on the details, but I know I couldn't get the initial version of plugin to work reliably without explicitly specifying the slice to export. With recent versions of Sketch I haven't had any problems though. Note that I use the App Store version of Sketch.
You do need to have an artboard or a layer within an artboard selected for currentArtboard
to return anything. If you've just opened the document or click on a layer outside of an artboard, currentArtboard
will start returning nil
. I've done zero testing with multi-page documents, so it could also be that currentPage
is returning nil
, or having multiple pages could be messing something up.
Well, I can do [[[doc currentPage] artboards] firstObject]
without issue. Just not currentArtboard
. The only way I can get this code or any of the forks to work is to use the Preview label on a slice...except for the one random time it worked. But then after a restart of the app, it stopped working. Odd.
Seems like the page isn't the issue then.
What versions of Sketch and Skala Preview are you using? Can you clone this repo and see if the Sketch document in the test directory works for you? That will help determine if it's version, environment or document related.
I've actually modified it to use Cloudapp, but I'm not even running that part of the code. Just isolating and outputting currentArtboard
to the log and I can't get it to return anything but nil. I'm using the version of Sketch that was released today, but did most of the testing today on the version just before the new one. Same behavior with your test file.
If you have a second see if this works for you: https://gist.github.com/mikegowen/9149321 Save as test.sketchplugin or whatever and run it on your test file. Always nil for me.
I just tried the gist with 2.4.2, upgraded to 2.4.3, and it worked with both. Do you have the MAS version or the direct download?
I wouldn't think it'd matter, but I'm using OS X 10.9.1.
Wow, ok. Well at least that gives me hope that it's fixable :) I have an App Store install and I'm on 10.9.1.
I also have Sketch Beta running alongside it. Going to uninstall and reinstall new version and see if that fixes it.
It might be worth backing up the ~/Library/Containers/com.bohemiancoding.sketch
directory and deleting it to see if that changes anything. If both versions are using the same directory, something in there could be changed in a way that breaks something in the older version.
Actually that worked! Must have missed it when I did the re-install. Thought I had gotten rid of everything.
Thanks for helping me track it down. Appreciate it.
Great. Glad you got it working.
I forked this repo from another fork and attempted to set the filename to the name of the current artboard. After digging in for quite awhile I discovered that this line never seems to return anything:
I actually got it to work one time, but then couldn't repro what I did. Reasonably sure it's a bug in the API. Have you seen this?