Creator:  Shanfan Huang
Date:  4. January 2012, 11:04

This is a very straight forward tool that generates four kinds of grid. You type in the number of rows and columns, and the size of the unit, then click a button.

While those grids might seem basic to mathematicians, I thought it'd be handy to have something like this in AI for graphic artists. Something looking basic at first can be creatively altered and became something interesting. I attached two quick-dirty mockups just to demonstrate some possibilities.

My favorite trick is to use the raster.getAverageColor() function to layout a rich and abstract color combination. If you feel like to try, copy the code below to the end of my scripts:

  • -----------------------------------

// Pickup colors from a raster//
//NOTE: An image must be placed within the artboard and rasterized//

var rasters = document.getItems({
type: Raster,
selected: true
});

var paths = document.getItems({
type: Path,
selected: true
});

if(rasters.length >0 && paths.length >0){
var raster = rasters[0];
for(var i=0; i<paths.length; i++) {
var path = paths[i];
var color = raster.getAverageColor(path);
path.fillColor = color;
}
}else{
Dialog.alert('Please select at least one rasterized image and one path overlapping on top.');
}

  • -------------------------------------------

UPDATE: 01/10/2012
I uploaded the above lines as a separate script.

Re: Grid Generator
From:  Shanfan Huang
Date:  18. February 2012, 19:32

Yep. The Gird Generator didn't just draw lines. It draws all the triangles or hexagons, so that it could be colored later. You're welcome :)

Re: Grid Generator
From:  Rian
Date:  20. February 2012, 12:13

kinda obvious now that you've said that :]#
Cheers!! :]#

Re: Grid Generator
From:  berto
Date:  21. February 2012, 09:39

Someone can tell me how i can have Octagon grid?

Re: Grid Generator
From:  Craige
Date:  23. February 2012, 16:01

Nicely done; surprisingly, I have needed grids of various kinds and had to make them (inaccurately) in PSD and then ported them. Thanks!

Re: Grid Generator
From:  DP
Date:  8. March 2012, 21:19

I have a question I've tried on cs4 and cs5 however I keep getting the following error:

"Error 22: Palette does not have a constructor. Line: 174 -> var palette = new Palette('Grid Generator',components, def);

Any ideas? Thanks in advance.

Re: Grid Generator
From:  Lukasz
Date:  11. March 2012, 15:36

I have the same problem, the same error...

Re: Grid Generator
From:  Gregorio Gasperi
Date:  15. March 2012, 09:21

Scriptographer actually requires you to download it before you can execute the scripts. So do that first, install it, and then try running this.

@Shanfan Huang, thank you so much for this, it's amazing. :)

Re: Grid Generator
From:  diggeridoo
Date:  16. March 2012, 14:15

Hi, Thanks for this fantastic script! Long time looking for something like this :)
I have a doubt:
Can I rotate the hexagons/triangle shapes? To make a isometric cube-like (rotated 30º)
This is shown in your example imgs but there isn't option in the script.
Do I have to make this manually?
Thanks!

Re: Grid Generator
From:  nadif
Date:  15. April 2012, 15:12

Hi, I also have a question. I keep getting the following error on cs5 as some of you:

"Error 22: Palette does not have a constructor. Line: 174 -> var palette = new Palette('Grid Generator',components, def);

I have installed Scriptographer but still getting the same error.

Some suggestions? Thanks in advance.

Re: Grid Generator
From:  Tom
Date:  25. April 2012, 16:46

I really want to do the average colour trick, but every time I run the script it gives me an error message saying I have to select a raster and a path...which I am doing!

What could be going wrong?!