Skip to main content
Known Participant
November 7, 2024
Question

OVERLAPPING OBJECTS

  • November 7, 2024
  • 2 replies
  • 3154 views

Hi, team. I'm working with illustrator and I have a scene with many objects placed randomly. Some of these objects are overlapping. Is there a script or feature that can automatically adjust their positions to avoid overlaps and ensure a more even distribution?

2 replies

m1b
Community Expert
Community Expert
November 14, 2024

Hi @Hanschrs, this discussion inspired me to write a script that might help (but don't worry if it doesn't suit your case—I was happy to write it anyway as I've wanted to do something like this for a long time!)

 

The script is called "Distribute Items.js" and you can download it from my github repo for general scripts (it's a new repo, I just made today but I will be adding new scripts to it all the time).

 

If you try it out, try it on not-too-many page items to start with while you are experimenting with the parameters. If you like you can adjust the default parameters by editing the "settings" object in the script (it is near the start).

 

Let me know if it is useful.

- Mark

 

HanschrsAuthor
Known Participant
November 18, 2024

The program will only run if fewer than 200 objects are selected."

m1b
Community Expert
Community Expert
November 19, 2024

Mark, I tried the latest version of your script with various amounts of selected objects. So far, I'd still say that it is rather not recommended to use more than 200 or maybe 300 objects at the same time.

 

Using 400 or even more objects definitely freezes Illustrator for some time, but at least does not crash it and eventually works as intended.

 

By the way, I like slowness.


Thanks Kurt. Yes unfortunately the algorithm is very processor intensive and ExtendScript is very slow. I'm not sure how I could improve the speed at the moment. Did you see the progress bar appear? That should give a steady time estimate so you know when you can go and do some gardening while it works away at the problem.

 

Now that I have fixed the initial bug you found, I'd be surprised if Illustrator actually froze or crashed, because it is really doing the same operations—measuring between mathematical points (not DOM path item points)—over and over again without storing them in memory. So if it can do one loop, it should be able to all of them without running out of memory. And it only touches the DOM at the very last minute (once the progress bar is full).

 

The settings are critical to speed, too. In some cases we can play with the parameters with a smaller number of items first, before applying to a larger number.

 

It is unfortunate that—due to the nature of the process—it doesn't work well to do a large number of items in smaller batches because the distribution will show flaws at the intersections of those batches.

 

Monika suggested a plug-in, which has a much better chance due to being written in C+ which is blazingly fast, and especially so compared to ExtendScript.

 

Thanks again for looking at this.

- Mark

CarlosCanto
Community Expert
Community Expert
November 7, 2024

I haven't seen a script for that, can you post screnshots showing more details of what you need? or better yet can you share sample files?

HanschrsAuthor
Known Participant
November 8, 2024

When I use brushes in Illustrator to create a stippling effect, I end up with too many overlapping points and have to manually move them to achieve a more uniform shape. That image has been hand-edited to create a more balanced effect.

 

Monika Gause
Community Expert
Community Expert
November 11, 2024

You could check out the plugin Stipplism. But it's not free