Closed jelias closed 10 years ago
Are you using your fork or mine? I think your branch has the artboard check first, which will behave this way if an artboard is selected.
No I downloaded the most recent version (v 0.2) 20 minutes before creating the issue.
I pushed up a test document that works on my system. Can you try to reproduce with that?
Also what locale is your system? One of the changes I made was to use the Cocoa APIs for string comparison, so I could have screwed that up.
Is this an artboard with a Preview
slice within it? I've only tested a Preview
slice that's not in an artboard, so that could also be the problem.
Yeah it was an artboard with Preview slice inside.
So then I made a new document, no artboards, made a beautiful rectangle, and made a preview slice. Worked perfectly. Guess previewing selected layers is out.
I added an artboard with its own Preview slice to the test document, but that one works for me too. Is that a reasonable approximation of what you were doing? Or are you trying to be able to select a layer within an Artboard and preview just that layer?
Or are you trying to be able to select a layer within an Artboard and preview just that layer?
Bingo. I was just playing with the plugin and wanted to see if you could preview only a certain layer within an artboard. Like if you were making a logo and wanted to preview it, but only the logo, no backgrounds, nothing else.
I don't see anything that looks like current selection or layer. However there is an isSelected
property on MSLayer
, so it might be possible to iterate on the layers for the current artboard and find the one where that property is true. Assuming that works, I can think of a couple issues.
@import
directive that would facilitate this, but I don't think Sketch is on that version yet, and I don't know if something similar is possible with older versions.I don't see anything that looks like current selection or layer. However there is an
isSelected
property onMSLayer
, so it might be possible to iterate on the layers for the current artboard and find the one where that property is true.
Maybe I'm just being thick here, but what about selection
?
It's an NSArray
of the selected layers, and you can easily iterate through it by either using JavaScript style for...loops:
for (var i=0; i < [selection length] ; i++) {
var item = selection[i]
}
or by using Obj-C style iterators:
var iterator = [selection objectEnumerator]
while (item = iterator.nextObject()) {
// do something with item
}
@bomberstudios I think you're correct. Thanks for pointing that out. I also see from your plugins that #import
would solve my duplication concerns. Lots of good stuff in there, I'm going to have to study what you've done.
@jelias What do you think about positioning? I assume you'd want the layer to show up wherever it'd be in the full screen mockup.
@marcisme feel free to browse my code and take what you need : )
I was testing the plugin today, and found that even when I have slices named
Preview
the plugin still exports the entire artboard to Skala Preview.