GeometricBounds and Coordinates - ff6347/extendscript GitHub Wiki
The property geometricBounds always expects an array of 4 numbers. This represents the points of the upper left corner and the lower right corner, measured from the upper and the left edge of the page in basic setting. This can be changed in the app.documents.item(0).viewPreferences.rulerOrigin property.
Important the y coordinate is defined before the x coordinate.
var y1 = 0; // upper left Y-Coordinate
var x1 = 0; // upper left X-Coordinate
var y2 = 10; // lower right Y-Coordinate
var x2 = 10; // lower right X-Coordinate
var geometricBounds = [ y1 , x1 , y2 , x2 ]
You can apply this within the script like this
var doc;
// if there is no doc create one
// if there is one - use it
if(app.documents.length < 1){
doc = app.documents.add();
}else{
doc = app.activeDocument;
}
var rect = doc.pages.item(0).rectangles.add();
var y1 = 10;
var x1 = 10;
var y2 = y1 + 100;
var x2 = x1 + 100;
var gb = [y1, x1, y2, x2];
rect.geometricBounds = gb;