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

What is Framer? Join the Community
Return to index
Taylor Palmer
Posted Apr 27 - Read on Facebook

Hi all, I have a Sketch file with multiple layers with the same name "card", but Framer brings them in as card1, card2, etc. This prevents me from being able to select them all with sketch.childrenWithName("card"). What's best practice here, without renaming all of them individually?


Dave Crow

Not sure how your sketch file is structured, but is it possible to group the card layers in Sketch and then reference them with sketch.cardGroup.children?

Taylor Palmer

Hey Dave Crow, they're actually children of separate groups that I need for functionality. Take a look at the structure here:

Dave Crow

So which layers are you wanting to target?

Taylor Palmer

At different times I want to target all of the "options" layers or all of the "artwork" layers

Nick Simonson

Simplest way would be to hard code the layers into an array and loop over them when you need to.

Celeste DeMartis

For layer in sketch.options.children ->

Dave Crow

Ditto. I think hard coding an array is the way I'd go.

Kevin Mao

Just ran into this annoying problem. I thought it only happened when importing from Figma.

I did something like this (underscores are whitespace):

for layer in
__ if'options')
____ #dosomething
__ if'artwork')
____ #dosomethingelse

Not sure if that's a better way than hard coding an array, but it worked for what I needed!

Andreas Wahlström

You can give this module a try:

Taylor Palmer

Thanks Andreas Wahlström I had used that before but forgotten about it!

The problem with hardcoding the array is that is takes just as long as renaming the layers. What if there were 100 of them? Not scalable.

Nicolai Doreng-Stearns

Populate your arrays with the function Kevin Mao wrote above

Justin Ma

If you're trying to target "personaCard" & "personaCard1", you could do that with a for loop?

eg. for card inside cards.subLayers. That should return personaCard, and personaCard1. If that sounds like it's what you're looking for, I wrote an article about how I do this with sketch and framer here :

Read the entire post on Facebook