2 Replies Latest reply on Jan 5, 2017 9:19 PM by Manan Joshi

    Understanding the transform functionality

    Manan Joshi Level 4

      Hello All,


      I am trying to play around with the transform method in InDesign scripting api, but am a bit tangled now by the results i get. I am using the following code on a document that i have uploaded via the link given below


      var pb = app.selection[0].transformValuesOf(CoordinateSpaces.PASTEBOARD_COORDINATES)[0].matrixValu es;

      var sp = app.selection[0].transformValuesOf(CoordinateSpaces.SPREAD_COORDINATES)[0].matrixValues;

      var pa = app.selection[0].transformValuesOf(CoordinateSpaces.PARENT_COORDINATES)[0].matrixValues;

      var inn = app.selection[0].transformValuesOf(CoordinateSpaces.INNER_COORDINATES)[0].matrixValues;

      $.writeln(pb) //0.86602540378444,-0.5,0.5,0.86602540378444,-288.605715851499,697.524047358083

      $.writeln(sp) //0.86602540378444,-0.5,0.5,0.86602540378444,-288.605715851499,117.524047358083

      $.writeln(pa) //0.86602540378444,-0.5,0.5,0.86602540378444,-288.605715851499,117.524047358083

      $.writeln(inn) //1,0,0,1,0,0

      //app.selection[0].transform(CoordinateSpaces.SPREAD_COORDINATES, AnchorPoint.BOTTOM_RIGHT_ANCHOR, [0.86602540378444,-0.5,0.5,0.86602540378444,-288.605715851499,697.524047358083],MatrixCon tent.ROTATION_VALUE);

      //app.selection[0].transform(CoordinateSpaces.SPREAD_COORDINATES, AnchorPoint.BOTTOM_RIGHT_ANCHOR, [0.86602540378444,-0.5,0.5,0.86602540378444,-288.605715851499,117.524047358083],MatrixCon tent.ROTATION_VALUE);


      Some observations are as follows

      1. The results of the writeln are as per the selection of the rectangle when its is rotated by 30 degrees, makes sense as the values relative to spread and parent are the same, since parent is also the spread.
      2. However when i use any of the matrix values, in the transform method the result is the same irrespective of the value of the first argument of transform method.
      3. Also without specifying the last argument, the results show a totally different results. What is its significance?


      What i am trying to do is clear all the transformations on a page item, do some work and then reapply the original transformation. For this i see that we need AnchorPoint in the transform method, is this saved in the transformation matrix? How do i achieve this, as an alternative i tried to play around with transformation matrix but got the above mentioned results.


      P.S. :- For point 2 and 3 remove change the rotation of the rectangle to 0 using the UI and run the script by uncommenting one of the last two lines and changing the first and last arguments.

      P.S. :- I also tried cleartransformations method, but it seems that it removes the transformations w.r.t. the centre anchor point.

      Document link https://dl.dropboxusercontent.com/u/55921329/Transformation.indd