May 31, 2009

Working With Symbols

The available scripting operations for symbol item are almost despairingly limited in AI CS3. As follows.

symbol properties -- name, parent, typename
symbol methods -- duplicate, remove

You can not even get coordinates of it directly.

One solution is to put a symbol into a group manually, and then you can manipulate the symbol through the group.

Suppose there's a grouped symbol on the artboard, like this.

Then you can get this image by running the following script.

// ----------------------------------------------
// places groups along a circle
const RADIUS = 120;
const DIV = 12;

var gr = activeLayer.groupItems[0];
var radian = Math.PI * 2 / DIV;

for(var i = 0; i < DIV; i++){
translate( RADIUS * Math.cos(i * radian),
RADIUS * Math.sin(i * radian) );
// ----------------------------------------------

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.