How to select a layer from a script

Hello!
I am currently researching script.

As you can see from the image, there are two selection states for the layer, 1 and 2.

Is there any way to go to the 2 selection state (yellow box) other than by mouse click?
For example, from a script or shortcut.

I tried looking up the API in layer.md, but it was not clear.

Thank you for reading.
qa_ase2

Maybe app.command.GotoNextLayer() and app.command.GotoPreviousLayer() would suffice for you?

Oh, I see now, you want second selected state with yellow frame. Well, why do you need it?

1 Like

Thanks for the reply.

The main reason is to improve the efficiency of my work.

In my work, “move all frames in a layer at once” is frequently used.
To do this, I have to use the Move Tool in 2⃣ layer states.
This means that I have to go back and forth between the canvas and the timeline frequently.
Doing this over and over again was quite a burden.

I thought that if I could use a shortcut to specify 1⃣ and 2⃣ arbitrarily, I could narrow down the range of pen movement and work more efficiently.

I tried app.command.GotoNextLayer() and app.command.GotoPreviousLayer(), but they didn’t do what I was looking for because they moved the pen in the 1⃣ state.

Translated with www.DeepL.com/Translator (free version)

You can select all required cels (not layers, but dots at crossings between layers and frames numbers) with mouse (LClick+drag and Shift+LClick+drag) and use Move Tool (V key) on them all at once.

1 Like

Thanks for the reply.

What I want to do is to select all frame cells in a layer at once without dragging selection with the mouse.
If the name of the layer in the timeline is surrounded by a yellow frame, then all the cells in that frame are selected, so there is no need for dragging.

So, it would be nice if there is an API or shortcut to make the yellow frame state.
I took a video of this, if you would like to see it.
youtube_Aseprite_select_layer

Translated with www.DeepL.com/Translator (free version)

Sounds like a rare extra. If you want a super automated way to do this you can write script that will move pixels of your layers directly by reading/writing them in correct order without use of Move Tool.

1 Like

I don’t know enough about Lua to script a method that doesn’t use the move tool.
I’ll do some more research on my own.
Thank you very much for your support.

1 Like

I think you can manipulate cel’s position for all layers and frames you want to emulate Move Tool.

See here: api/cel.md at main · aseprite/api · GitHub
Search for: Cel.position

This will work much faster than reading/writing pixels from script. In fact Move Tool works just like this.

1 Like

Thanks for the info!
I’ll check it out.

We’ve made some progress.
There seems to be a variable that holds the type of the selection.
Also, there was a function to clear the selection state.


image

1 Like

I’ve finally come up with a solution!
Thank you very much for all your help and advice.
image

2 Likes