Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Script to calculate and fill empty spaces

Explorer ,
Dec 20, 2024 Dec 20, 2024

Hello, everyone. I am familiar with scripts, but I don't have a deep understanding of js.

I need help with the following:
- I have an artboard with some objects (all groups);
- I need to fill the empty spaces on the artboard with other objects, for example, they could be rectangles measuring 5cm by 3.7598cm (but the future idea is to fill them with other files that have objects with the same dimensions);
- This filling needs to take into account the best distribution of the objects, so that they do not overlap and that they follow a spacing of 3mm; - These rectangles can be rotated 90 and 180 degrees (as the script considers the best arrangement).
- This 3mm spacing needs to be between the objects;
- There is no need for spacing between the rectangles and the artboard limits.
- The challenge is to calculate the area and calculate the possible arrangements to fill with the rectangles;
- The best arrangement is not crucial for me, the important thing is just to fill to avoid so many empty spaces.

I will leave some images to illustrate.

TOPICS
How-to , Scripting
629
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe
Community Expert ,
Dec 20, 2024 Dec 20, 2024

Hi @MarcosAdriano1994 I don't have a fully out-of-the-box solution for you, but as a start you could look at my bin packing script. It currently uses the document's artboards as the "bins", which won't work for you because you have space taken up already. A workaround could be to make artboards around your existing artwork and try the script. I tried it quickly—see screenshots below.

 

To use read instructions from the repo above, download the script files and run the script "Bin Packing--Artboards.js".

- Mark

demo.gif

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Dec 26, 2024 Dec 26, 2024
LATEST

Thank you, I will test and see if I can adapt something. Any result I get I return here to comment.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines