How do I access all of the top-level layers from an imported Sketch file? (I.e., programmatically rather than by name—I want to loop through them). sketch.children doesn't seem to work (my imported sketch file is assigned the name "sketch"). Thanks!
I know there's an example around here somewhere, I saw it a while back, haven't found it though, might be by Jordan Robert Dobson? I'm trying to do the same thing right now.
topLevel = (layer for layer in Framer.CurrentContext.layers when not layer.parent?) (just make sure to do this before creating layers within framer)
if your Sketch document is organized in such a way that the top-level layers are the artboards, then you can also use:
artboards = (layer for layer in Framer.CurrentContext.layers when layer._info.kind is "artboard")
This one is pretty money, Utils.globalLayers(sketch) turns all your sketch layers into layers you can call by name. SO to Adam Armstead for the tip.
I've ran into the same problem, Utils.globalLayers worked for me too
Thanks all, these suggestions were all useful.