jsx script not working as it is in regular script illustrator cc 2019
I'm using illustrator cc 2019
I currently have a script that's evaluating a script from cep to jsx.
var csi = new CSInterface();
var retString = 'blah'
csi.evalScript("platePlacement(" + retString + ")")
This runs the method platePlacement located in my jsx. Full code is this:
function platePlacement(plateData) {
alert('blah blah');
// open the template
var f = new File("/Users/Desktop/test.ai");
var doc = app.open (f);
// here we set color of text
var col = new RGBColor();
col.red = 255;
col.green = 0;
col.blue = 0;
// activate current document
var aDoc = app.activeDocument;
// aDoc.rulerOrigin = [0, 0];
// aDoc.pageOrigin = [0, 0];
var bkgrndPlate = new File("/Users/Desktop/test2.ai");
var placeFiles = aDoc.placedItems.add();
// place linked file on document
placementMeasurements = {top1: -4.5, left1: 4.8};
placeFiles.file = bkgrndPlate;
placeFiles.top = placementMeasurements.top1;
placeFiles.left = placementMeasurements.left1;
// placeFiles.position = [4.863, 50];
// place text on document
var text = aDoc.textFrames.add();
text.textRange.size = 49;
text.textRange.characterAttributes.fillColor = col;
text.textRange.characterAttributes.horizontalScale = 80;
text.contents = "blah blah";
text.textRange.characterAttributes.textFont = textFonts.getByName("Helvetica");
text.textRange.justification = Justification.CENTER;
// calcuate left side placement of text
var textWidth = text.width;
var plateWidth = 288;
text.top = -43.4;
text.left = calculateLeftPlacement(textWidth, plateWidth);
function calculateLeftPlacement(textWidth, plateWidth) {
var widthCalculation = ((plateWidth - textWidth) / 2) + 4.8;
return widthCalculation;
}
}
The program skips the alert, then loads the file test2.ai and that's all. There are no errors, it just stops executing. When I run this exact script from Scripts in illustrator cc it works perfect. What am I missing here?
