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();
}
}
}