Skip to main content
Participating Frequently
May 4, 2021
Question

How to fill an object in random tileable way with other objects

  • May 4, 2021
  • 2 replies
  • 3977 views

Does anyone know by any chance if there are any script that can play it ,or any action plan for this?
here is an illustration what I mean, basically filling an object by creating grids from random object

its done in after effect here is the source: workbench

This topic has been closed for replies.

2 replies

femkeblanco
Brainiac
May 6, 2021

Replacing tiles with random items is easy with scripting (if a bit pernickety); filling a path with tiles isn't. Doing the latter manually is easy though. This is a basic idea:

 

Step one, filling a path with tiles:

  1. Select the path and apply a fill to the path.
  2. Click Object > Rasterize.
  3. Click object > Create Object Mosaic.
  4. Ungroup the tiles.
  5. Select and delete the blank and unwanted tiles.

 

 

Step two, replacing tiles with random items:

  1. Import or create the paths to randomly replace the tiles.
  2. Bring the paths to randomly replace the tiles to the front (Ctrl + Shift + ]), i.e. they should be at the top of the layers panel.  This is a key step. 
  3. Select all.
  4. Run the script:

 

var n = prompt("", 8, "No. of items to randomly replace tiles:");
for (var i = app.selection.length - 1; i > n - 1; i--) {
    var pos = app.selection[i].position,
    w = app.selection[i].width,
    h = app.selection[i].height;
    app.selection[i].remove();
    var index = Math.floor(Math.random() * n);
    var duple = app.selection[index].duplicate(app.activeDocument, ElementPlacement.PLACEATEND);
    duple.position = pos;
    duple.width = w;
    duple.height = h;
}

 

Ton Frederiks
Community Expert
May 6, 2021

Thank you femkeblanco.

A simple elegant script, it works!

I have been searching for someting like this, but could not find it.

Monika Gause
Community Expert
May 4, 2021

The options to fill are:

- plugin Phantasm: does a good job with the grid, can do custom objects in the grid, but only one of them.

- plugins ColliderScribe and Stipplism: do a good job with randomization, but the positions will also be random and not a grid.

 

So what you can do is first create the grid with Object > Create object mosaic

Then use a script or the plugin FindReplace to select random objects and replace them by symbols using the Replace script by kelsocartography.com

Participating Frequently
May 4, 2021

thanks but I dont have the plugin

Monika Gause
Community Expert
May 4, 2021

There are scripts for random selection, such as: https://github.com/marcusguttenplan/adobe_scripts