Best way to create an array of objects in Illustrator?
Go to Effects -> Distort/Trasnform -> Transform... Add amount of copies you want then play with the array controls
There are a few ways to achieve this...
The quickest method is to translate, scale, or rotate an object while duplicating it. To duplicate an object in Windows, hold down the 'alt' key*. The transformation and duplication can then be repeated by pressing CTRL + D.
For greater precision, select a transformation tool from the toolbox and press enter. A dialogue should then appear, allowing you to enter numerical values, and has a 'copy' button. Again, once the dialogue has closed, you can press CTRL + D to repeat.
The Blend tool can 'step' objects, which also has an option for rotating objects to match a path.
The 'Actions' palette can record and playback multiple transformations.
Illustrator supports a number of languages for scripting, and this offers the most flexible solution but is generally more time consuming to learn and set up.
*Mac key combinations may differ slightly.
You can also use scripting. For example, this is how you can create 20 path items with random rotation and position from center.
// creating a document
var doc = app.documents.add();
// adding a new layer
var layer = doc.layers.add();
// variable declarations
var i, ray, displacement, dx, dy;
// creating 20 path items in a loop and setting their parameters
for (i = 0; i < 20; i++) {
// adding a path item and saving it to the "ray" variable
ray = layer.pathItems.add();
// defining path points
ray.setEntirePath([ [0, 0], [0, 10]]);
// generating a random angle for rotation
// note: rotation in Illustrator is counter-clockwise
ray.rotation = Math.round(Math.random() * 360);
// applying rotation to the path, using its bottom as the origin point
ray.rotate(ray.rotation, true, true, true, true, Transformation.BOTTOM);
// moving the path away from the center of the document by "displacement" amount
displacement = 10 + Math.random() * 10;
// calculating x and y coordinates from "displacement"
// (which is basically a hypotenuse)
dx = displacement * Math.sin( (180 + ray.rotation) * Math.PI / 180 );
dy = - displacement * Math.cos( (180 + ray.rotation) * Math.PI / 180 );
// translating the path
ray.translate(dx, dy);
}
You can then save this as "somefile.js" and execute by File->Scripts->Other script... Or paste it into the ExtendScript toolkit and run it from there.