Skip to main content
Participating Frequently
September 10, 2012
Question

document.selection.length only 1000 max?

  • September 10, 2012
  • 1 reply
  • 2231 views

In adobe Illustrator CS5.1 I have a script that needs to do an action on over 1000 path objects (they are tiny squares). I noticed that my script was working very strange even though I checked over the code about 10 times to make sure it was right. In the process, I found something very interesting... even though my selection consists of over 1000 path objects (and I changed selections slightly to make sure this was the case), app.activeDocument.selection.length is always 1000 unless I go below 1000 items. Is there a limit to the number of objects that are in that array? If so, what are some solutions I might use to overcome that limitation?

Thanks!

This topic has been closed for replies.

1 reply

Inspiring
September 10, 2012

Kivak_Wolf wrote:

app.activeDocument.selection.length is always 1000 unless I go below 1000 items. Is there a limit to the number of objects that are in that array?

No.

You must have something else in your code causing it to limit things or improperly coded to meet your expectations. I just did a quick test with no problems. I am however not sure if there is a ceiling within illustrator for certain limits, surely at some point even without limits strange things may begin to occur in certain cases.

Participating Frequently
September 10, 2012

Very interesting! This is my code to simply check to make sure:

alert("total: " + app.activeDocument.selection.length );

If I select <1000 it says the correct number. If I select >1000 it says "total: 1000".

Odd isn't it?

Participating Frequently
September 10, 2012

I decided to do a little more testing... apparently I AM doing something prior that is causing a problem. I have a statement I thought wouldn't affect it what-so-ever:

var selection = app.activeDocument.selection;

If I ask app.activeDocument.selection.length before the statement, it returns >1000. However, if I do this assignment and then ask  app.activeDocument.selection.length, it reads back only max of 1000. Also! The new variable, selection, only has 1000 elements in it. It does not contain all of selection.

Anyone have any ideas why on earth this is happening? The reason I need a local reference of the selected objects is that I will be selecting specific ones later before I am doing referring to them. So I can't keep asking app.activeDocument.selection because it will be changing. Any ideas on some solutions?

Thansk for your help!