Copy link to clipboard
Copied
For example:
I want sel[j] to be positioned above sel[j-1];
var doc = app.activeDocument;
var item = doc.selection;
sel = items;
for (var i = 0; i < sel.length; i++) {
};
Do you want to move a page item up in the containing layer’s stacking order?
Here there are 3 page items in Layer 1 (there’s only 1 Document Layer). To move the selected item up 1 place in Layer 1’s stacking order (there is also s.bringToFront(), s.sendToBack(), s.sendBackward()):
var s = app.activeDocument.selection[0]
s.bringForward()
Hi @dublove this function can set the stacking order. I am using a left-then-top sorting function, but you can use any criteria for sorting.
- Mark
/**
* @file Set Item Stacking Order.js
* @author m1b
* @version 2025-10-25
*/
function main() {
var doc = app.activeDocument;
var items = doc.selection;
// must update `items` with new item references
items = setItemStackingOrder(doc, items, sortByLeftTop);
};
app.doScript(main, ScriptLanguage.JAVASCRIPT, undefined, UndoMode...
how do I use it?
var d = app.activeDocument
//a selection on the bottom layer
var s = d.selection[0]
//this doesn’t do anything because s
//is the only object on the item Layer named "Gray"
s.bringForward()
//make a new layer
var ns = makeLayer(d, "New Gray Layer");
//moves the selected page item to New Gray Layer
// note that the parameter has to be a reference to an item Layer
s.move(ns)
/**
* Makes a new named Layer
* @ param the document to add the layer
* @ param layer name
* Copy link to clipboard
Copied
Alright then, I'll look into it when I have some free time.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now