Copy link to clipboard
Copied
(0,0) is set in TOP LEFT corner of the page...
It's not shown on the Video - but it's like rotation point is in the middle of the Left edge of the first page ?? But it's still dancing ??
What is even worse - objects on the 2nd spread - behave like (0,0) point is still on the 1st Page / Spread ??
This is part to set TransformReferencePoint:
myInDi.ActiveDocument.LayoutWindows.Item(1).TransformReferencePoint = Array(0, 0)
And this is to rotate:
myInDi.ActiveDocument.Selection.Item(a).RotationAngle = myInDi.ActiveDocument.Selection.Item(a).RotationAngle + myLAngle
It's in a loop so when only one item is selected - a=1.
Doesn't matter what RulerOrigin I set, doesn't matter if I manually move (0,0) point in the InDesign - when I'm trying to rotate object via scripting - it's like (0,0) point is in the middle of the left edge of the first page???
If I try to rotate by Object's reference point - it's perfectly fine.
What am I doing wrong? Or it's fine in JavaScript?
Hi Robert,
Not using transform and matrices explicitly does not mean that coordinate spaces are not involved behind the scenes. In fact, they always are, since InDesign works that way. The critical part of your code is the transformReferencePoint assignment, which explicitly refers to the origin of the pasteboard coordinate space. And this determines the center point of the rotation. Maybe a picture will make it clear:
Code:
var doc = app.properties.activeDocument;
doc.layoutWindows[0].transfor
...
Copy link to clipboard
Copied
Hi @Robert at ID-Tasker, I can confirm the same problem. Using this script:
var item = app.activeDocument.selection[0];
var tm = app.transformationMatrices.add({
counterclockwiseRotationAngle: 10,
});
item.transform(
// CoordinateSpaces.INNER_COORDINATES,
// CoordinateSpaces.PAGE_COORDINATES,
// CoordinateSpaces.PARENT_COORDINATES,
// CoordinateSpaces.PASTEBOARD_COORDINATES,
// CoordinateSpaces.SPREAD_COORDINATES,
CoordinateSpaces.PASTEBOARD_COORDINATES,
[0, 0],
tm,
);
I get the same results you describe and changing the coordinateSpace argument of transform method makes no difference.
@Marc Autret, you have a great knowledge of coordinate spaces in Indesign. Any ideas about this? Are we doing something wrong here?
@Robert at ID-Tasker, a workaround may be (assuming that the mysterious [0,0] point can be reliably determined—is it centre of pasteboard?) to move the item to that position (offset according to your actual desired fulcrum point), rotate it, and then move it back to where it was (offset by how much it moved from the [0,0] point). This is similar to what I have to do in Illustrator to transform around a point.
- Mark
Copy link to clipboard
Copied
It seems that the [0,0] point is the centre of the combined bounds of every page on the first spread.
- Mark
Copy link to clipboard
Copied
Thanks for the confirmation.
So no one ever before experienced this bug?
Copy link to clipboard
Copied
@m1b, about your workaround - the thing is, that I want to let user select few objects - and turn all of them around the same point at the same time - so I've thought that the simplest solution would be to let user set (0,0) point as the center of the rotation and then rotate all selected objects around it.
Next step - another Rule - would be to move selected objects away / towards the same (0,0) point.
But if location of the (0,0) is so broken...
Copy link to clipboard
Copied
Hi all,
The location [0,0] refers to the origin of the pasteboard space.
If you need to apply a rotation relative to the center anchor of the object, use the location AnchorPoint.centerAnchor or any equivalent specifier:
(I don't see the bug you're talking about. Maybe I didn't understand the problem…)
Best,
Marc
Copy link to clipboard
Copied
I'm not using Transform and Matrices - please check my opening post and @m1b confirmation in JavaScript but he IS using Transform and Matrices...
I'm just changing RotationAngle AFTER setting ReferencePoint.
Rotation around center - or any other point of the object - works perfectly fine.
It doesn't work when you try to rotate around (0,0) point - wherever you place it and whatever you set as RulerOrigin.
Copy link to clipboard
Copied
Hi Robert,
Rotation around center - or any other point of the object - works perfectly fine.
It doesn't work when you try to rotate around (0,0) point - wherever you place it and whatever you set as RulerOrigin.
IMHO, your VBS code
myInDi.ActiveDocument.LayoutWindows.Item(1).TransformReferencePoint = Array(0, 0)
just sets the reference point at the origin of the pasteboard coordinate space, as would do the JS code
myDoc.layoutWindows[0].transformReferencePoint = [0,0];
So I still don't see what is wrong 😕 The rotation is processed relative to that temporary origin, which is (usually) not the center point of the object—which explains why it moves during the procedure. Or did I miss something else?
(Sorry if I misunderstood the issue. Maybe my mind isn't wide awake 😉
Best,
Marc
Copy link to clipboard
Copied
The thing is - it doesn't rotate around (0,0) point - but around middle of the left edge of the 1st page - completely ignores location of the (0,0) point - you can move (0,0) point manually in the InDesign anywhere - but it will still rotate around the middle of the left edge of the first page.
Copy link to clipboard
Copied
The thing is - it doesn't rotate around (0,0) point - but around middle of the left edge of the 1st page - completely ignores location of the (0,0) point - you can move (0,0) point manually in the InDesign anywhere - but it will still rotate around the middle of the left edge of the first page.
That is, around the origin of the pasteboard coordinate space. This is what I have been trying to explain since the beginning of this discussion. Well, I probably didn't manage to express myself clearly. For my part I don't see any bug, in all the examples given here the Scripting DOM behaves as I would expect.
Best,
Marc
Copy link to clipboard
Copied
Hi @Marc Autret, your guide to coordinate spaces and transformations is amazing! Thank you! I will refer to that when I get time.
In the case of this simple matter of just rotating a page item around a specified point on the page... what is wrong with my script above? Are you saying that, for you, my script rotates the selected item around the top-left corner of its spread? For me it doesn't do that, but I expected it to.
- Mark
Copy link to clipboard
Copied
Yeah, @Marc Autret's pdf is amazing - saw it before - but for some reason I don't like matrices...
Copy link to clipboard
Copied
Also @Marc Autret, note that changing the CoordinateSpace argument doesn't change the transformation no matter which I use. Strange.
Copy link to clipboard
Copied
note that changing the CoordinateSpace argument doesn't change the transformation no matter which I use. Strange.
Not strange at all… as soon as you know what the CoordinateSpace argument actually means in the transform method 😉 I did my best to explain this in Chapter 5. Most of the time, the “perspective space” of a rotation (in short, the associated bounding box) has no particular consequence.
Copy link to clipboard
Copied
Hi Mark,
Thanks!
Your code use the pattern
item.transform(<anySpace>, [0, 0], <rotMatrix>);
which strictly means: “transform that object relative to the origin of the pasteboard in the perspective of <anySpace>”. [0,0] is not the origin of <anySpace>, it is a location specifier that has a fixed syntax and meaning. Of course you can use any other location specifier.
→ More on this topic: The transform space enigma
Hope that helps,
Best,
Marc
Copy link to clipboard
Copied
Yes! That explains the first argument—interesting!—and in my simple case I will just use pasteboard coordinate space. So with your patient help I finally got it!
To behave the way I expect, this would be my simple example script:
var item = app.activeDocument.selection[0];
var tm = app.transformationMatrices.add({
counterclockwiseRotationAngle: 10,
});
item.transform(
CoordinateSpaces.PASTEBOARD_COORDINATES,
[[0, 0], BoundingBoxLimits.GEOMETRIC_PATH_BOUNDS, CoordinateSpaces.PAGE_COORDINATES],
tm,
);
Thanks, Marc, so much for your help—this has been a great learning experience for me. 🙂
- Mark
Copy link to clipboard
Copied
@Marc Autret, I have never questioned your knowledge and I appreciate your PDF - but it looks like there is a bug when doing it the "old fashion" way?
Copy link to clipboard
Copied
Ok, I think I've found a solution - workaround - I'll just create a new Rule, that will analyse all selected objects - their center (x,y) or a total area - get the "middle point" and use it as a (0,0) point for rotation / expansion.
Or user will have to create some temporary object - 5x5 mm rectangle with a label "center" - and center of this rectangle will be (0,0) point.
There is always more than one way to skin a cat.
Copy link to clipboard
Copied
Robert, I don't understand how this is a solution. Your problem wasn't finding the middle point, it was rotating an item around an arbitrary point.
Copy link to clipboard
Copied
@m1b, It's not a solution to the problem in InDesign - it's just a solution for what I want to achieve... it looks like a quite serious bug but I can't hold my breath waiting for it to be fixed, so - my workaround.
Copy link to clipboard
Copied
Hi @Robert at ID-Tasker, just to summarise my new understanding with Marc's help: it isn't a bug, it is just a complex idea that is very poorly documented in the OMV—much of my problem came down to not understanding what the OMV meant with the gibberish about arrays or reals or arrays of arrays of blah blah. Marc's document clears that up so that my simple example script now.
- Mark
Copy link to clipboard
Copied
@m1b, but I'm not using Transform and Matrices - I'm going the "old" way - directly changing RotationAngle.
Copy link to clipboard
Copied
Hi @Robert at ID-Tasker ,
I would urge you to test your code on objects that are not on the first spread of a document!
Regards,
Uwe Laubender
( Adobe Community Expert )
Copy link to clipboard
Copied
@Laubender, I did - and it behaved like the (0,0) was still on the 1st page...
Copy link to clipboard
Copied
@Robert at ID-Taskersaid: "…I did - and it behaved like the (0,0) was still on the 1st page..."
I expected that.
You can think of this as the zero point of the document.
Nothing really new. And no bug.
Regards,
Uwe Laubender
( Adobe Community Expert )