Skip navigation
Home/Support/

Forums

1204 Views 11 Replies Latest reply: Jul 31, 2011 9:58 AM by Marc Autret RSS
seuzo-oJiFme User 87 posts since
Jan 12, 2002
Currently Being Moderated

Apr 17, 2009 12:02 AM

How to check the rotated spreads?

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/

  • Dave Saunders Participant 420 posts since
    Jul 6, 2006
    Currently Being Moderated
    1. Apr 17, 2009 6:06 AM (in response to seuzo-oJiFme)
    Re: How to check the rotated spreads?

    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

  • Harbs. Contributor 4,940 posts since
    Apr 19, 2004
    Currently Being Moderated
    2. Apr 17, 2009 7:05 AM (in response to Dave Saunders)
    Re: How to check the rotated spreads?

    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

  • Peter Kahrel Participant 1,747 posts since
    Oct 18, 2006
    Currently Being Moderated
    3. Apr 17, 2009 7:02 AM (in response to Dave Saunders)
    Re: How to check the rotated spreads?

    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

  • Peter Kahrel Participant 1,747 posts since
    Oct 18, 2006
    Currently Being Moderated
    4. Apr 17, 2009 7:05 AM (in response to Harbs.)
    Re: How to check the rotated spreads?

    > 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

  • Harbs. Contributor 4,940 posts since
    Apr 19, 2004
    Currently Being Moderated
    6. Apr 17, 2009 9:02 AM (in response to seuzo-oJiFme)
    Re: How to check the rotated spreads?

    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

  • Dave Saunders Participant 420 posts since
    Jul 6, 2006
    Currently Being Moderated
    7. Apr 17, 2009 9:51 AM (in response to Harbs.)
    Re: How to check the rotated spreads?

    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

  • Harbs. Contributor 4,940 posts since
    Apr 19, 2004
    Currently Being Moderated
    9. Apr 19, 2009 4:08 PM (in response to seuzo-oJiFme)
    Re: How to check the rotated spreads?

    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);
    
  • Marc Autret Participant 382 posts since
    Jun 12, 2009
    Currently Being Moderated
    11. Jul 31, 2011 9:58 AM (in response to seuzo-oJiFme)
    Re: How to check the rotated spreads?
    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

More Like This

  • Retrieving data ...

Bookmarked By (0)

Legend

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