Skip to content

GeometricBounds and Coordinates

fabiantheblind edited this page Apr 11, 2013 · 3 revisions

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 coordiante is defined before the x coordinate

    var y1 = 0; // upper left  Y-Ccoordiante  
    var x1 = 0; // upper left  X-Coordiante  
    var y2 = 10; // lower right Y-Coordiante  
    var x2 = 10; // lower right X-Coordiante  
    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;

Clone this wiki locally