Skip to main content
Community Expert
January 2, 2017
Question

Understanding the transform functionality

  • January 2, 2017
  • 1 reply
  • 660 views

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].matrixValues;

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],MatrixContent.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],MatrixContent.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

This topic has been closed for replies.

1 reply

Loic.Aigon
Legend
January 3, 2017
Community Expert
January 6, 2017

Hi Loic,

I did go through the text mentioned by you, its brilliant but does not directly deal with Anchor Points role in transformations and how they can be passed into the transform method as an argument. One of the main question that i am finding answers is

  1. How to know which anchor point was used during a transformation.

The text mentioned by you might have touched this topic but its too much to take in for a single read, so it would be great if you or @Marc Autret could shed some light on which sections of the text to reread to gain some insight.

Thanks,

-Manan

-Manan