A dozen of times I came across this question which is conformable to the topic of the present tutorial. I also participated in discussions couple of times trying to solve this problem. And only today I’ve got the answer the key question - How? I’m sure, some designers distribute objects within another object manually, but we’d prefer to do everything quickly and automatically, wouldn’t we?
To distribute objects inside another object we’ll need three scripts, which will be introduced in the process of their application. In the meanwhile, download the zip archive with scripts by clicking on the Download button. Unpack the archive and place its contents into the system folder with scripts, for example:
For Windows: C:\Program Files\Adobe\Adobe Illustrator CS5\Presets\en_GB\Scripts
For Mac: Applications / Adobe\Adobe Illustrator CS5\Presets\en_GB\Scripts
Restart Adobe Illustrator in case it was running at the time of scripts’ installation. All the scripts were successfully tested in Adobe Illustrator CS5, CS6 and CC.
Create a path with no fill; we will place our objects inside it.
After our scripts were installed, their names appeared in the menu File > Script > …. Select the created path (by the way, it can be open and compound path), then go to the File > Script > Circle Fill. In the opened dialog box set the maximum and the minimum value of circles as percentage to the size of an external object and a minimal distance between the circles.
You also have an opportunity to choose the color of circles from the drop down list; however, this option won’t be useful in this tutorial.
A cool effect was obtained within a couple of seconds, but we’d like to use other objects to fill space within the form. Let’s create an object with which we want to replace the circle. First, I created a very simple soap bubble, which is a group of black circle and a white highlight form. Before using the next script, please make sure that our bubble is placed above the circles and that these circles are not grouped. These obligatory conditions allow our script to work.
Select the circle and the bubble, then go to the File > Script > FindAndReplaceGraphic_TransformToFit.
As you can see, the object switch was performed successfully, while the size of initial circles, which formed a shape of heart, was taken into consideration.
And now let’s try to replace the circles with an object of a more complex shape. The most important is that the height and the width of this object were not equal.
Select all the objects, then go to the File > Script > FindAndReplaceGraphic_TransformToFit.
As you can see, after replacement the objects were deformed. This deformation will be higher, the bigger the difference between the height and width of the replacing object. To get rid of this deformation, I suggest your attention one trick. Create a circle with no fill and no stroke, so the object is located inside this circle.
Group the object and the circle with no fill and no stroke, then repeat the circles’ switch (File > Script > FindAndReplaceGraphic_TransformToFit). Now, we have no deformation.
Don’t forget that you can always rotate and move the received objects in random order with the help of the Transform Each function (Object > Transform > Transform Each…)
If you came across similar illustrations, then you know that the outer form is often filled with a couple of objects, and not with one as in our case. No problem. The Random Select script can select all the objects in random order (File > Script > Random Select). After the script starts, the Script prompt opens, where you need to enter a percentage ratio of selected objects.
Select a new object while keeping the earlier objects selected.
Start the script FindAndReplaceGraphic.
Personally, I’d like to receive higher dense objects inside a filled form. That’s why if you have other solutions of this problem, please share your experience with us.