I have a programmable keyboard that I am using to assign shortcuts and nmacros to for various programs. One of the things I want to do is move selected objects to a named layer.

I always have four layers consistent throughout most of my documents


I have scripts that select one of these layers when I want to work on them and I've applied a shortcut to it through an action.

var aDoc = app.activeDocument;
aDoc.activeLayer = aDoc.layers.getByName("Artwork");

Sometimes while working I forget to change layers and on big projects, this can be problematic and I need a quick way to move the selected objects to a named layer by pressing one key.

I'm sure this can be done with a script but I do not know anything about Javascript, I have read the documentation, but I cannot understand it.

Any help on this would be appreciated

  • Objects have a method xalled move that moves them.in hierarchy. While the function to move in cancas space is called translate
    – joojaa
    Commented Jul 4, 2020 at 10:55

1 Answer 1


You can move the selected objects to a layer named "Target" using this script:

var docSelected = app.activeDocument.selection;  
var targetLayer = app.activeDocument.layers["Target"];

for (s = 0; s < docSelected.length; s++) {  
     myPath = docSelected[s];
     myPath.move(targetLayer, ElementPlacement.PLACEATBEGINNING);

You just have to modify the "Target" name in the second line. Create four scripts each with the four layer names and assign a different shortcut for each one.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.