Copy link to clipboard
Copied
Hi everyone, I'd like to share a script.
Some time ago I wrote a script for bin-packing in Illustrator (posted here on the forum) and recently another user asked me if I could make a version for Indesign, which I have now done and I've published to github (the repo has scripts for both Indesign and Illustrator).
To read more about the scripts, including instructions, you can visit the github repo or to jump right in you can directly download the scripts.
What is bin packing?
Bin packing is arranging things so that they fit into "bins". In Illustrator, the bins are artboards, and in Indesign the bins are pages.
This is the sort of thing you can do in Illustrator (packing 35 items into 2 artboards):
And here's an Indesign example, packing 146 items onto 4 pages:
(This animation is using the option "Divide Bins at Guides", which keeps the items clear of the guides by a set margin.)
I hope someone will find the scripts useful. Feel free to leave feedback here or via the github repo.
- Mark
I have a problem with the display of the degree sign in the UI. I changed it to Unicode "Allow 90\u00b0 rotation".
New test:
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Hi @Sergey Osokin thanks for checking it out. Yes it is a basic algorithm that only works with rectangles—I did look at the more sophisticated algorithms but they were a major time investment to understand!
When I look at your "test 1.jpg" it gives me an idea to add an improvement—watch this space!
And your "test.jpg" shows a strange bug which I haven't noticed. I will look into that. Thanks again!
- Mark
Copy link to clipboard
Copied
It seems to me that ExtendScript would be too slow if the goal is to maximize compact packaging. I know that printing companies buy specialized software for this, which is not cheap.
Copy link to clipboard
Copied
Hi @Sergey Osokin, yes, and libaries like svgnest that are amazing, but too complex for me to port to ExtendScript.
But for now, I've improved my script's capabilities by (optionally) first rotating each item so that it fits within the smallest rectangle possible. This can make a big difference when packing arbitrary shapes.
I've updated the code on github.
- Mark
P.S. Here's an example of the new functionality:
Copy link to clipboard
Copied
I have a problem with the display of the degree sign in the UI. I changed it to Unicode "Allow 90\u00b0 rotation".
New test:
Copy link to clipboard
Copied
Thanks again @Sergey Osokin, I have made your change to the repo. As you can see the algorithm is "dumb" in the sense that it has no idea which item is best to pack next. That is why the scripts simply do a bunch of different sorts and then random shuffles. If you think of a good sorting scheme let me know!
- Mark
Copy link to clipboard
Copied
This is nice! Thanks for sharing @m1b!