Skip to content

Scripts for 2D packing of page items onto Adobe Illustrator artboards and Adobe Indesign pages.

License

Notifications You must be signed in to change notification settings

mark1bean/bin-packing-for-illustrator-and-indesign

Repository files navigation

Bin Packing For Illustrator and Indesign

Scripts that perform 2D bin packing on Adobe Illustrator artboards and Adobe Indesign pages, automating the process of arranging selected page items into artboards or pages, with the aim of achieve a reasonably tight packing.

Demo of Bin Packing Script

Update 2024-10-23: showing new Allow Any Rotation capability:

Demo with rotation

Show your support

Profile Picture

If this project will save you time, please consider supporting me:

Donate


Installation

Step 1: Download the Scripts

Download script files (zipped):

Download

The repository contains the following script files:

  • Bin Packing--Artboards.js (for Adobe Illustrator)
  • Bin Packing--Pages.js (for Adobe InDesign)
  • Packer.js (required helper script)
  • packer-blocks.js (required helper script)

Note: Ensure that Packer.js and packer-blocks.js are located in the same directory as the main script you want to run.

Step 2: Place the Scripts in the Appropriate Folder

Move the downloaded files to your Adobe application's ExtendScript folder.

See How To Install Scripts in Adobe Illustrator and How To Install Scripts in Adobe Indesign.

Step 3: Run the Script

  1. Open your Adobe Illustrator or InDesign application.
  2. Add artboards or pages as needed. The script will try to pack the items into these "bins". If you do not have enough bins, the script may not find a solution.
  3. Select the items you want to pack.
  4. Open the Scripts panel from Window > Utilities > Scripts (InDesign) or from the File > Scripts menu (Illustrator).
  5. Choose either Bin Packing--Artboards.js or Bin Packing--Pages.js to execute the script.

Usage

  1. Prepare your document: Open an Adobe InDesign document and select the items you wish to pack.

  2. Run the script: Execute the script, which will pack your selected items onto the available pages.

  3. Options:

    • Space between items: The space between packed items.
    • Margin: The space between packed items and the bin's outer edges.
    • Divide Bins at Guides: (Indesign only) Whether to use guides in the document to split pages into multiple bins.
    • Maximum attempts: The number of attempts to make before giving up. Note: the script will only reach this maximum if no packing has been successful, or if Try harder is enabled.
    • Try Harder: Whether to continue testing new attempts even after all items are successfully packed. Do this if you are looking for a better packing result.
    • Random Packing: Perform a single random-shuffle packing for an aesthetic or experimental result.
    • Custom Scoring: Choose to prefer either packing more items or maximizing the packed area.
    • Allow 90° rotation Allow items to be rotated by 90° during packing.
    • Allow any rotation Allow items to be rotated so that they fit best into a rectangle. This will generally achieve tighter packing, but will rotate the items by arbitrary amount between 0 and 90°.

Script User Interface


Author

Created by Mark Bean ("m1b"), inspired by this community discussion. The scripts rely on the 2D bin packing algorithm shared by Trentium (see acknowledgements below).

Acknowledgements

The 2D bin packing algorithm is by Stackoverflow user trentium published here and for which I am very grateful.

I also acknowledge Adobe community forum user "MarioRossiGD" for support the development of the Indesign version of the original script.

License

This project is open-source and available under the MIT License. See the LICENSE file for details.

About

Scripts for 2D packing of page items onto Adobe Illustrator artboards and Adobe Indesign pages.

Resources

License

Stars

Watchers

Forks

Packages

No packages published