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

Strange behaviour when trying to rotate around (0,0) point ??

Community Expert ,
Sep 21, 2023 Sep 21, 2023

Copy link to clipboard

Copied

(0,0) is set in TOP LEFT corner of the page...

 

https://youtu.be/9XABq_EgBOo

 

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?

 

Uploaded by ID-Tasker on 2023-09-21.
TOPICS
Bug , Scripting

Views

983

Translate

Translate

Report

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

correct answers 1 Correct answer

Guide , Sep 22, 2023 Sep 22, 2023

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:

 

2023-09-22-13-23-23.gif

 

Code:

var doc = app.properties.activeDocument;
doc.layoutWindows[0].transfor
...

Votes

Translate

Translate
Community Expert ,
Sep 21, 2023 Sep 21, 2023

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

Votes

Translate

Translate

Report

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 ,
Sep 21, 2023 Sep 21, 2023

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

Votes

Translate

Translate

Report

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 ,
Sep 21, 2023 Sep 21, 2023

Copy link to clipboard

Copied

Thanks for the confirmation. 

 

So no one ever before experienced this bug?

 

Votes

Translate

Translate

Report

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 ,
Sep 21, 2023 Sep 21, 2023

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... 

 

Votes

Translate

Translate

Report

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 ,
Sep 21, 2023 Sep 21, 2023

Copy link to clipboard

Copied

Hi all,

 

The location [0,0] refers to the origin of the pasteboard space.

→ Pasteboard Coordinate 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:

→ Syntax of a Location 

 

(I don't see the bug you're talking about. Maybe I didn't understand the problem…)

 

Best,

Marc

Votes

Translate

Translate

Report

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 ,
Sep 21, 2023 Sep 21, 2023

Copy link to clipboard

Copied

@Marc Autret 

 

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.

 

Votes

Translate

Translate

Report

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 ,
Sep 21, 2023 Sep 21, 2023

Copy link to clipboard

Copied

Hi Robert,

 

quote

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

Votes

Translate

Translate

Report

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 ,
Sep 21, 2023 Sep 21, 2023

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. 

 

Votes

Translate

Translate

Report

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 ,
Sep 21, 2023 Sep 21, 2023

Copy link to clipboard

Copied

quote

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

Votes

Translate

Translate

Report

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 ,
Sep 21, 2023 Sep 21, 2023

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

Votes

Translate

Translate

Report

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 ,
Sep 21, 2023 Sep 21, 2023

Copy link to clipboard

Copied

Yeah, @Marc Autret's pdf is amazing - saw it before - but for some reason I don't like matrices... 

 

Votes

Translate

Translate

Report

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 ,
Sep 21, 2023 Sep 21, 2023

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.

Votes

Translate

Translate

Report

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 ,
Sep 21, 2023 Sep 21, 2023

Copy link to clipboard

Copied

quote

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.

Votes

Translate

Translate

Report

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 ,
Sep 21, 2023 Sep 21, 2023

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

 

Votes

Translate

Translate

Report

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 ,
Sep 21, 2023 Sep 21, 2023

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

Votes

Translate

Translate

Report

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 ,
Sep 22, 2023 Sep 22, 2023

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?

 

Votes

Translate

Translate

Report

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 ,
Sep 21, 2023 Sep 21, 2023

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. 

 

Votes

Translate

Translate

Report

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 ,
Sep 21, 2023 Sep 21, 2023

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.

Votes

Translate

Translate

Report

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 ,
Sep 21, 2023 Sep 21, 2023

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. 

 

Votes

Translate

Translate

Report

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 ,
Sep 21, 2023 Sep 21, 2023

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

Votes

Translate

Translate

Report

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 ,
Sep 22, 2023 Sep 22, 2023

Copy link to clipboard

Copied

@m1b, but I'm not using Transform and Matrices - I'm going the "old" way - directly changing RotationAngle.

 

Votes

Translate

Translate

Report

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 ,
Sep 22, 2023 Sep 22, 2023

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 )

Votes

Translate

Translate

Report

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 ,
Sep 22, 2023 Sep 22, 2023

Copy link to clipboard

Copied

@Laubender, I did - and it behaved like the (0,0) was still on the 1st page...

 

Votes

Translate

Translate

Report

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
New Here ,
Sep 22, 2023 Sep 22, 2023

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 )

Votes

Translate

Translate

Report

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