This is a read-only archive of the Framer Community on Facebook.

What is Framer? Join the Community
Return to index
Dave Anderson
Posted May 18 - Read on Facebook

Hi all,

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!


Ash Adamson

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.

Ben Rodenhäuser

topLevel = (layer for layer in Framer.CurrentContext.layers when not layer.parent?) (just make sure to do this before creating layers within framer)

Ben Rodenhäuser

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")


Ash Adamson

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.

Rolando Pdl

I've ran into the same problem, Utils.globalLayers worked for me too

Dave Anderson

Thanks all, these suggestions were all useful.

Read the entire post on Facebook