Skip navigation
seuzo-oJiFme
Currently Being Moderated

How to check the rotated spreads?

Apr 17, 2009 12:02 AM

Hi all,

 

Mac OS X 10.5.6/InDesign 6.01/JavaScript or AppleScript

 

When the spreads is rotated view, the page item's visibleBounds (and geometricBounds) is change.

How to method of examining whether the spreads rotated?

example:

 

my_spread = app.layoutWindows[0].activeSpread;

my_spread.rotate; //of course, error

//I wish like this , =>ROTATE_CCW Value: 1987736183

 

 

Thanks.

--

http://www.seuzo.jp/

  • Currently Being Moderated
    Community Member
    Apr 17, 2009 6:06 AM

    I do not see a property that directly provides this information.

     

    You can work out whether or not a spread is rotated by looking at the page.bounds, but that seems a rather clumsy way to get the information.

     

    Dave

    |
    Mark as:
  • Currently Being Moderated
    Community Member
    Apr 17, 2009 7:05 AM

    You can work out whether or not a spread is rotated by looking at

    the page.bounds,

     

    Oh, no!!!

     

    I never realized that bounds were effected by page rotation. That's

    bad, bad, bad!!!

     

    This will mess up just about every script under the sun which deals

    with bounds of any kind!

     

    We  need this changed...

     

    It is just a rotated view after all, so why are the bounds effected?

     

    Harbs

    http://www.in-tools.com

    |
    Mark as:
  • Currently Being Moderated
    Community Member
    Apr 17, 2009 7:02 AM

    It's probably something to do with spread.transformValuesOf (myCoordinateSpace), but I never really got my brain round transformation matrices. They're fiendishly complicated! In the old forums there was a sticky topic by Ole on transf. matrices, but I don't see that now.

     

    Peter

    |
    Mark as:
  • Currently Being Moderated
    Community Member
    Apr 17, 2009 7:05 AM

    > We  need this changed...

     

    Agreed. Goes for the whole transformation business.

     

    > It is just a rotated view after all, so why are the bounds effected?

     

    I guess that though it's a view, the spreads are really rotated. At print time they're probably rotated back.

     

    Peter

    |
    Mark as:
  • Currently Being Moderated
    Community Member
    Apr 17, 2009 9:02 AM

    Just make sure the zeroPoint is set to Re: How to check the rotated spreads?, and the rulerOrigin is 

    page. I like to work with spread origin, in which case, you'd pass a 

    spread instead of a page...

     

    Harbs

    http://www.in-tools.com

    |
    Mark as:
  • Currently Being Moderated
    Community Member
    Apr 17, 2009 9:51 AM

    I agree that this is indeed bad, bad, bad.

     

    If the coordinates are changed by this action then I would expect at least a spread property that tells you the spread is rotated.

     

    Dave

    |
    Mark as:
  • Currently Being Moderated
    Community Member
    Apr 19, 2009 4:08 PM

    Hi Seuzo,

     

    Very well done.

     

    I took your code and cleaned it up the way I would have done it (I don't think you gain very much -- if anything, from all those "if"s). I also restructured the function to accept both Page and Spread objects. Assuming that the document is the active one is not a safe asumption. I changed that as well...

     

    function GetSpreadRotation(pageOrSpread) {//accepts a Page, Spread, or MasterSpread
      var doc = pageOrSpread.parent;// the doc will be either the parent, or the parent's parent...
      if(pageOrSpread instanceof Page){doc=doc.parent}
      //if(!(doc instanceof Document)){return null}// uncomment this to error check for the wrong type of pageOrSpread...
      var origRulerOrigin = doc.viewPreferences.rulerOrigin;
      var origZP = doc.zeroPoint;
      doc.zeroPoint=[0,0];
      doc.viewPreferences.rulerOrigin = RulerOrigin.PAGE_ORIGIN;
      var page = pageOrSpread;
      if (!(page instanceof Page)){// it must be a Spread or MasterSpread
        page=pageOrSpread.pages[0];
      }
      var pageBounds = page.bounds;
      var retAngle = 0;
      if(pageBounds[0] == 0 && pageBounds[1] == 0) {
        retAngle = 0;
      } else if (pageBounds[0] == 0 && pageBounds[3] == 0) {
        retAngle = 90;
      } else if (pageBounds[2] == 0 && pageBounds[3] == 0) {
        retAngle = 180;
      } else if (pageBounds[1] == 0 && pageBounds[2] == 0) {
        retAngle = 270;
      }
      doc.viewPreferences.rulerOrigin = origRulerOrigin;
      doc.zeroPoint = origZP;
      return retAngle;
    }
    var doc=app.documents[0];
    var spread = doc.spreads[0];
    spread_angle = GetSpreadRotation(spread);
    alert("Spread Angle: " + spread_angle);
    var page = doc.pages[0];
    spread_angle = GetSpreadRotation(page);
    alert("Page Angle: " + spread_angle);
    var masterSpread = doc.masterSpreads[0];
    spread_angle = GetSpreadRotation(masterSpread);
    alert("Master Spread Angle: " + spread_angle);
    
    |
    Mark as:
  • Currently Being Moderated
    Community Member
    Jul 31, 2011 9:58 AM
    function getSpreadRotation(/*Page|Spread|MasterSpread*/ps)
    // ---------------------------------------------------------
    //      0 => NORMAL , -90 => CW, +90 => CCW, 180 => REVERSED
    {
         return ps.
              transformValuesOf(CoordinateSpaces.pasteboardCoordinates)[0].
              counterclockwiseRotationAngle;
    }
     
     
    // Test
    // ---
    var mySpread = app.activeDocument.spreads[0];
    alert( getSpreadRotation(mySpread) );
    

     

     

    @+

    Marc

    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points