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

What is Framer? Join the Community
Return to index
John Grendon Enderby
Posted Jul 06 - Read on Facebook

Hi guys, if I have two artboards that are named differently, but the layers within are named the same (i.e. Artboard_1 > button and Artboard_2 > button) how do i store buttons into variable for use in demos?

If i use button = sketch.button there is no functionality, which I assume is because the layers are named the same.

How do i store them into separate variables? tried button = sketch.Artboard_1.button but doesn't work... Would love some help please :)

5 Comments

Benjamin Den Boer

Heya John - here's a way you could go about it. First, make sure that any artboards created after your first one are made visible in Framer. Then, you could loop over the subLayers of a specific artboard, and select the layer there. See below. :-)

Benjamin Den Boer

And if your artboards contains multiple layers, it's also possible to target the layer directly by referencing its array index. Like this:

print sketch.artboardB.subLayers[0] (first layer)

John Grendon Enderby

So there is no way to do this by name without renaming the layers in the sketchfile?

Benjamin Den Boer

John true. If you want to reference them by name directly, the names need to be unique. :-)

John Grendon Enderby

OK cool, thanks for your help :)

Read the entire post on Facebook