Skip to main content
amirwerth
Participant
February 11, 2019
Question

Ordering objects by size

  • February 11, 2019
  • 3 replies
  • 1550 views

Is there any way or method to order objects by size?  I have a bunch of closed, filled shapes (random circles and squares) and I would like to order them by area.  If there isn't a way to do it just in illustrator, could I export them to another program and do it there and then return them to illustrator?

This topic has been closed for replies.

3 replies

Disposition_Dev
Legend
February 13, 2019

when you say "order", what do you mean? stacking order like in the layers panel? arranged from left to right or top to bottom?

i'll assume the first option, but let me know if i'm wrong. here's some pseudocode. not necessarily the best way. but it is one way.

run script

var items = [selected items or all children of a layer or layers.. basically the items you want to sort by size]

var sortedItems = []; //empty array for storing items sorted by size

var largest;

while items.length

     largest = items[0];

     for each item, starting at 1

          if current item is larger than largest

               set largest to current item

    

     sortedItems.push(current item);

     splice current item from items array

for each item in sortedItems

     current item: bring to front

pixxxelschubser
Community Expert
Community Expert
February 13, 2019

Hi williama,

unfortunately, this scenario will presumably only works with simple closed paths (no compound path or clipped paths or or or …).

Disposition_Dev
Legend
February 13, 2019

compoundPathItems, groupItems, textFrames etc all still have width and height properties. In the event of a clipping mask, you just need to isolate the top level path that has clipped = true and then use the dimensions of that path to determine the size of the whole clipping mask.

I'm using this exact same method of sorting objects in production right now.

Jacob Bugge
Community Expert
Community Expert
February 13, 2019

Amir,

I believe there is a script for it.

Maybe Carlos or Theunis sees this soon, but in any case you may also ask in the Scripting forum,

Illustrator Scripting

Srishti_Bali
Legend
February 13, 2019

As Jacob said it could be possible through Scripts, I am moving this discussion to Illustrator Scripting

Srishti_Bali
Legend
February 12, 2019

Hi Amir,

I am afraid right now there no option to do this in Illustrator apart from doing it manually. You may raise this feature request here: Adobe Illustrator Feedback. This is the best way of communicating with the Engineering and Product Management teams regarding issues and suggestions so they can be implemented in future releases.

Regards,

Srishti