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

How to ensure the key object remains stationary (at the first of sel)?

Guide ,
Oct 03, 2025 Oct 03, 2025

Ensure the key object is always the first element in “sel”.
Other objects should always be positioned to the right.

 

I intend to set sel[j].geometricBounds so that the keyObject remains stationary while the others are arranged to its right.

The code below doesn't seem to be working.

0025.png

var sel = app.documents[0].selection;
var key = app.selectionKeyObject;
var sb = key.visibleBounds;
sel.sort(function (a, b) {
var a = key.visibleBounds;
var b = b.visibleBounds;
if (a[1] > b[1]) {
return 1;
} else if (a[1] < b[1]) {
return -1;
}
});

 

TOPICS
How to , Scripting
46
Translate
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
Guide ,
Oct 03, 2025 Oct 03, 2025
LATEST

It turns out you need to use move.

The ideal approach, of course, is to keep keyobj stationary while aligning the elements before and after it.
This seems difficult.

Translate
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