Skip to main content
Known Participant
August 4, 2009
Answered

Move selected object to layer shortcut

  • August 4, 2009
  • 2 replies
  • 5987 views

Hi everyone,

I'd like to be able to invoke a script that would simply shift the selected object (text frame or picture frame) to another layer without me having to open the layers panel, select the tiny dot and drag to another layer. I find this fiddly and awkward especially on repetition.

I previously asked people here how I could run a script that looked for objects with an assigned attribute and retrospectively move them all to one layer. But I'd prefer to be able to hit a command with the object selected that pushed the object on to a specific layer.

To me, this really should be an inbuilt shortcut, such as command-alt-up/down arrow. As far as I can tell this isn't assigned to anything and would come in really handy!

Can anyone suggest a solution for this, script or otherwise?

Many thanks!

Lewis

This topic has been closed for replies.
Correct answer Jongware

How about this Dynamic Duo?

//DESCRIPTION: One Layer Down

for (s=0; s<app.selection.length; s++)
{
if (app.selection.itemLayer.index < app.activeDocument.layers.length-1)
  app.selection.itemLayer = app.activeDocument.layers.nextItem(app.selection.itemLayer);
}

//DESCRIPTION: One Layer Up
for (s=0; s<app.selection.length; s++)
{
if (app.selection.itemLayer.index > 0)
  app.selection.itemLayer = app.activeDocument.layers.previousItem(app.selection.itemLayer);
}

It works, even with a multiple selection on different layers.

Be warned that without the Layer panel open, you might not be aware of your current active layer! This changes as a selection is moved from one layer to another.

2 replies

Inspiring
August 4, 2009

no way to beat [Jongware]

this toggles thru all layers.

Ralf


Message was edited by: liedzeit

I give up. Cannot insert code...

Jongware
Community Expert
JongwareCommunity ExpertCorrect answer
Community Expert
August 4, 2009

How about this Dynamic Duo?

//DESCRIPTION: One Layer Down

for (s=0; s<app.selection.length; s++)
{
if (app.selection.itemLayer.index < app.activeDocument.layers.length-1)
  app.selection.itemLayer = app.activeDocument.layers.nextItem(app.selection.itemLayer);
}

//DESCRIPTION: One Layer Up
for (s=0; s<app.selection.length; s++)
{
if (app.selection.itemLayer.index > 0)
  app.selection.itemLayer = app.activeDocument.layers.previousItem(app.selection.itemLayer);
}

It works, even with a multiple selection on different layers.

Be warned that without the Layer panel open, you might not be aware of your current active layer! This changes as a selection is moved from one layer to another.

Known Participant
August 4, 2009

Thanks very much Jongware,

I'll try this out and see how it goes. Do you know if its possible to tweak this so that it allow moving to a locked layer? The same way that holding the command key allows when dragging between layers? That way I could keep my destination layer (and any others) locked so as to isolate myself to one layer, the only unlocked one?

Could be a solution to pitfall you mention if it can be done...

Cheers,

Lewis

Known Participant
August 4, 2009

Thanks for your advice on this, it works a treat. In fact it actually allows you to move the object over to a locked layer (although not back out again).

I have the two scripts assigned to command-alt-up and command-alt-down and this will speed up my workflow immensely.

Thanks again.

Lewis