2 Replies Latest reply on Mar 28, 2010 6:38 PM by pbear*

    Ovals changing size [JS CS4]

    pbear* Level 1

      I create an oval and set it to be 10 inches in diameter as follows:

       

      var thisDoc = app.documents.add();
      thisDoc.documentPreferences.pageHeight = "11i";
      thisDoc.documentPreferences.pageWidth = "11i";
      thisDoc.documentPreferences.pageOrientation = PageOrientation.landscape;
      thisDoc.documentPreferences.facingPages = false;
      var thisPage = thisDoc.pages[0];

      var inputValue = 100;
      var valueToInches = inputValue * 0.05;  // 5

      var circleXY = 5 - valueToInches;  // 5 - 5 = 0.5
      var circleWH = 2 * valueToInches;  // 2 * 5 = 10

      var useXY = circleXY + "i";  // specifying number in inches
      var useWH = circleWH + "i";

      var myCircle = thisPage.ovals.add({geometricBounds:[useXY, useXY, useWH, useWH]});

      //  top left placed at 0, 0        -- as expected
      // resulting circle is 10 x 10 in. -- as expected

       

      When I offset it to center it on the page, the oval is created 0.5 inches smaller:

       

      var thisDoc = app.documents.add();
      thisDoc.documentPreferences.pageHeight = "11i";
      thisDoc.documentPreferences.pageWidth = "11i";
      thisDoc.documentPreferences.pageOrientation = PageOrientation.landscape;
      thisDoc.documentPreferences.facingPages = false;
      var thisPage = thisDoc.pages[0];

      var inputValue = 100;
      var valueToInches = inputValue * 0.05;  // 5

      var circleXY = 5.5 - valueToInches;  // 5.5 - 5 = 0.5
      var circleWH = 2 * valueToInches;    // 2 * 5 = 10

      // specifying number in inches
      var useXY = circleXY + "i";
      var useWH = circleWH + "i";

      // debug:
      $.writeln(circleXY);  // "0.5"
      $.writeln(circleWH);  // "10"
      $.writeln(useXY);     // "0.5i"
      $.writeln(useWH);     // "10i"

      var myCircle = thisPage.ovals.add({geometricBounds:[useXY, useXY, useWH, useWH]});

      //  top left placed at 0.5, 0.5      -- as expected
      // resulting circle is 9.5 x 9.5 in. -- not expected

       

       

      Perplexing. Any clues as to what I'm obviously doing wrong here?