• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

How to quickly (may be single click will be best) rearrange stacking order by its position?

Engaged ,
Sep 09, 2024 Sep 09, 2024

Copy link to clipboard

Copied

Hello,

How to rearrange selected objects stacking order by its postion left to right, by any trick or script?

the top-left object should be at top level in stacking order. and this trick should be work on any type of object Raster/Vector/Group/Text item

jkhakase_0-1725942029512.png

 

TOPICS
How-to , Scripting

Views

288

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe
Community Expert ,
Sep 10, 2024 Sep 10, 2024

Copy link to clipboard

Copied

J,

 

I am sure there is a script for that, but until someone presents/makes it, you can apply a simple Move to Back action, if that is manageable (you have a limited number). The action could just consist of Cut and Paste in Back (Ctrl/Cmd+X+B), to be applied to each object (set) from right to left, in other words in reverse order.

 

Such an action can also be used, and even called for under more woolly circumstances where a simple script would fail, such as multiple ungrouped objects on top of one another to be moved together without changing their internal  order, including objects on top of one another to be kept together in the stacking order even with one/some being to the right of an unrelated obejct.

 

With a script it could be nice, or needed, to have a choice of reference point, left/centre/right.

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Sep 11, 2024 Sep 11, 2024

Copy link to clipboard

Copied

Thanks, but I am looking very quick solution, due to there may be huge items in furure.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 12, 2024 Sep 12, 2024

Copy link to clipboard

Copied

I quite understand, J.

 

I can see that you have set it as a Scripting topic, so I wonder why no scripter friend has answered.

 

Any scripter?

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 15, 2024 Sep 15, 2024

Copy link to clipboard

Copied

Make a new layer. Make a rectangle in this layer. Duplicate the layer as many times as you need. Place the image layer at the bottom. Select the top image and the rectangle (this will select the top rectangle). Group/Ungroup. The image is now on the top layer. Hide this layer and do the same with the next image and the next layer. You use that when grouping, everything goes to the layer of that object, which is highest in the stack.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Sep 15, 2024 Sep 15, 2024

Copy link to clipboard

Copied

var sel = app.activeDocument.selection;

var items = [];
for (var i = 0; i < sel.length; i++) {
  var item = sel[i];
  items.push({item: item, x: item.position[0]});
}

items.sort(function(a, b) { return a.x < b.x; }); // or use `>` to reverse order

for (var i = 0; i < items.length; i++) {
  items[i].item.zOrder(ZOrderMethod.BRINGTOFRONT);
}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Sep 19, 2024 Sep 19, 2024

Copy link to clipboard

Copied

@hhas01 thank you the reply.

top-left image/object should be stay at top level at stacking order. accordingly other object's all the stacking order should be update. which is not happening by current code.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Sep 21, 2024 Sep 21, 2024

Copy link to clipboard

Copied

LATEST

The previous script moved the leftmost selected object to the top of the stacking order.

 

This keeps the leftmost selected object at its current position in the stacking order:

 

var sel = app.activeDocument.selection;

if (sel.length < 2) {
	alert("Please select 2 or more items.");
} else {
	var items = [];
	for (var i = 0; i < sel.length; i++) {
	  var item = sel[i];
	  items.push({item: item, x: item.position[0]});
	}

	items.sort(function(a, b) { return a.x < b.x; });
	var topItem = items.pop().item;

	while (items.length > 0) {
	   items.shift().item.move(topItem, ElementPlacement.PLACEAFTER);
	}
}

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines