Sg2.9
Drawing on new Document Issues
Recent RSS
Drawing on new Document Issues
From:  Greg Miller
Date:  24. August 2010, 20:29

I am trying to make numbers 1 through 99 in a different document using a script, but I have issues with drawing onto the document after it has been opened. The script uses a symbol library of each number artwork and places and positions it on the document. It seems like when I go to actually draw something on the document it thinks the document doesn't exist. So when I create the new PlacedSymbol is comes back undefined even though the OneSymbol comes back with a definite symbol. Is there something I am missing when creating a new document?

for(i=0; i<2; i++){
for(j=0; j<2; j++){
if (i != 0){
var file = new File('Users/gmill6/Documents/Script/template.ai');
var doc = new Document(file);
doc.activate();

//set artboard to 2000 x 2000
var myArtboard = doc.activeArtboard;
myArtboard.bounds = Rectangle([0,0,2000,2000]);

create artboard border for ai saves
var nullSwatch = doc.swatches['[None]'];
var myBorder = new Rectangle(0,0,2000,2000);
myBorder.strokeColor = "#000000";
myBorder.fillColor = nullSwatch.color;
myBorder.strokeWidth = .25;

//Intialize Variables
var spacing = parseInt(kstandard);
var hstandard = parseInt(hstandard);
var oneSymbol = doc.symbols[parseInt(i)];
var twoSymbol = doc.symbols[parseInt(j)];

print(oneSymbol);

var placedFirst = new PlacedSymbol(oneSymbol);
placedFirst.position = new Point(1000, 1000);
print(placedFirst);
var placedSec = new PlacedSymbol(twoSymbol);
placedSec.position = new Point(1500, 1000);

//Get Symbols Height and Width
var oHeight1 = placedFirst.bounds.height;
var oWidth1 = placedFirst.bounds.width;
var oHeight2 = placedSec.bounds.height;
var oWidth2 = placedSec.bounds.width;

//Initialize Symbol Size
placedFirst.size = new Size(oWidth1, oHeight1);
placedSec.size = new Size(oWidth2, oHeight2);

//Symbol Scaling
var nWidth = proportions(oHeight, hstandard);
placedFirst.scale(nWidth);
placedSec.scale(nWidth);

//New Width Initialized
var nWidth1 = placedFirst.bounds.width;
var nWidth2 = placedSec.bounds.width;

//Symbol Kerning
var kerning = letterspace(nWidth1, nWidth2, spacing);
placedSec.position = new Point(kerning, 1000);

//Group Creation and Center
var combined = new Group([placedFirst, placedSec]);
combined.position = new Point(1000, 1000);
doc.save();
doc.close();
}
}
}

Scripts
08.08.14, 15:24
15.05.14, 14:23
02.03.14, 19:16
18.11.13, 14:48
22.03.13, 03:05
22.02.13, 15:45
Posts
10.01.17, 16:37
19.02.16, 06:03
19.02.16, 06:00
17.01.16, 11:00
12.01.16, 13:10
25.11.15, 08:19
Script of the Moment
Stroke <-> Fill 09.01.08