Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

How to check the rotated spreads?

Contributor ,
Apr 16, 2009 Apr 16, 2009

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/

TOPICS
Scripting
4.1K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Apr 17, 2009 Apr 17, 2009

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 17, 2009 Apr 17, 2009

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 17, 2009 Apr 17, 2009

> 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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Apr 17, 2009 Apr 17, 2009

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 17, 2009 Apr 17, 2009

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Apr 17, 2009 Apr 17, 2009

Thank you!

This is good method for only check.

I can stop myscript, if the spreads is rotate.

function spread_angle(page_obj) {

     //The bounds of the Page, in the format [y1, x1, y2, x2].

     var my_page_bounds = page_obj.bounds;

     var y1 = my_page_bounds[0];

     var x1 = my_page_bounds[1];

     var y2 = my_page_bounds[2];

     var x2 = my_page_bounds[3];

     if((y1 == 0) && (x1 == 0)) {

          return 0;

     } else if ((y1 == 0) && (x2 == 0)) {

          return 90;

     } else if ((y2 == 0) && (x2 == 0)) {

          return 180;

     } else if ((x1 == 0) && (y2 == 0)) {

          return 270;

     }

}

var my_page = app.layoutWindows[0].activePage;

spread_angle(my_page);

>We  need this changed...

I agreed too...

Again, thanks.

--

http://www.seuzo.jp/

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 17, 2009 Apr 17, 2009

Just make sure the zeroPoint is set to , 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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Apr 17, 2009 Apr 17, 2009

Thank you, Harbs.

Oops!

I had overlooked some matters. It is as you say.

This is OK?

function spread_angle(spread_obj) {

     var my_document = app.activeDocument;

     var my_old_ruler_origin = false;//

     if (my_document.viewPreferences.rulerOrigin != 1380143215) {//not page

          my_old_ruler_origin = my_document.viewPreferences.rulerOrigin;//current setting

          my_document.viewPreferences.rulerOrigin = 1380143215;//change

     }

     var my_old_zeroPoint = false;

     if (my_document.zeroPoint != [0, 0]) {

          my_old_zeroPoint = my_document.zeroPoint;

          my_document.zeroPoint = [0,0];

     }

     var my_page = spread_obj.pages[0];

     var my_page_bounds = my_page.bounds;

     var my_angle = -1;

     if((my_page_bounds[0] == 0) && (my_page_bounds[1] == 0)) {

          my_angle = 0;

     } else if ((my_page_bounds[0] == 0) && (my_page_bounds[3] == 0)) {

          my_angle = 90;

     } else if ((my_page_bounds[2] == 0) && (my_page_bounds[3] == 0)) {

          my_angle = 180;

     } else if ((my_page_bounds[1] == 0) && (my_page_bounds[2] == 0)) {

          my_angle = 270;

     }

     if(my_old_ruler_origin) {my_document.viewPreferences.rulerOrigin = my_old_ruler_origin}

     if(my_old_zeroPoint) {my_document.zeroPoint = my_old_zeroPoint}

     return my_angle

}

var my_spread = app.layoutWindows[0].activeSpread;

spread_angle(my_spread);

--

seuzo

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 19, 2009 Apr 19, 2009

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);
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Apr 20, 2009 Apr 20, 2009

Hi Harbs.

Thank you for rewriting my code.

I see, the object passed to the function might not be activeDocumetnt's.

--

Seuzo

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Jul 31, 2011 Jul 31, 2011
LATEST

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines