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

PlacedItem matrix TX & TY nowhere near actual position

New Here ,
Mar 15, 2022 Mar 15, 2022

Copy link to clipboard

Copied

I'm writing a tool to export PlacedItems' pos/rot/scale out to a JSON file, then reading them into a proprietary app. I get the transform matrix, no problem. However, the matrix values don't make sense.

In the poperties panel, the linked object's transform is [0, 0].

In the object's matrix, [mValueTX, mValueTY] are [-3314, -2537].

How do I reconcile these numbers?

Ian23598363t8yj_0-1647358951048.pngIan23598363t8yj_1-1647358966187.png

 

TOPICS
Scripting

Views

230

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 2 Correct answers

Contributor , Mar 15, 2022 Mar 15, 2022

Hello, 

I'm not sure if this will be the case, but try tinkering with Application.CoordinateSystem (CoordinateSystem)
There are two of them - Artboard and Document.
You could also use Document.convertCoordinate function, to recalculate the position, if you don't want to change it in whole Application for some reason.

 

While running Artboard coordinate system, then placement is calculated relative to artboard starting point, for Document - placement is calculated globally.

 

I don't remember which one

...

Votes

Translate

Translate
New Here , Mar 18, 2022 Mar 18, 2022

Lumenn, worked great!
The documents have multiple Artboards, so I ended up using the conversion script.

sourceDoc.artboards.setActiveArtboardIndex(index);
var pos = sourceDoc.convertCoordinate(
	item.position, 
	CoordinateSystem.DOCUMENTCOORDINATESYSTEM,
	CoordinateSystem.ARTBOARDCOORDINATESYSTEM);

Votes

Translate

Translate
Adobe
Contributor ,
Mar 15, 2022 Mar 15, 2022

Copy link to clipboard

Copied

Hello, 

I'm not sure if this will be the case, but try tinkering with Application.CoordinateSystem (CoordinateSystem)
There are two of them - Artboard and Document.
You could also use Document.convertCoordinate function, to recalculate the position, if you don't want to change it in whole Application for some reason.

 

While running Artboard coordinate system, then placement is calculated relative to artboard starting point, for Document - placement is calculated globally.

 

I don't remember which one was the default, but i know when i was working on some position translating scripts it saved me a lot of time.

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 ,
Mar 18, 2022 Mar 18, 2022

Copy link to clipboard

Copied

Lumenn, worked great!
The documents have multiple Artboards, so I ended up using the conversion script.

sourceDoc.artboards.setActiveArtboardIndex(index);
var pos = sourceDoc.convertCoordinate(
	item.position, 
	CoordinateSystem.DOCUMENTCOORDINATESYSTEM,
	CoordinateSystem.ARTBOARDCOORDINATESYSTEM);

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 ,
Mar 15, 2022 Mar 15, 2022

Copy link to clipboard

Copied

I think @Lumenn's answer is right. You might prefer to use the artboard coordinate system though if you only have one artboard, but otherwise the document coordinate system is the more robust.

- 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 Beginner ,
May 31, 2022 May 31, 2022

Copy link to clipboard

Copied

Hi, I have the matrix of TextFrame. I tried to get the normal TX & TY but it didnt work.
Do you have any  idea why or how should I do it?

 

The Text:

m0riya_3-1654025013008.png

 

The Matrix:

m0riya_0-1654024825950.png

The Geometric Bounds:

[  60.701171875,   
-47.81591796875,
501.041015625,
-224.4404296875  ]

 

 The Code:

var  matrix = selection[0].matrix, 
        pos= [ matrix.mValueTX, matrix.mValueTY];
app.activeDocument.convertCoordinate(pos ,CoordinateSystem.DOCUMENTCOORDINATESYSTEM ,CoordinateSystem.ARTBOARDCOORDINATESYSTEM)

 The Result:

m0riya_2-1654024910905.png

 

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 ,
May 31, 2022 May 31, 2022

Copy link to clipboard

Copied

LATEST

Hi @m0riya, good question and we didn't answer the OP's question. I had a poke around and I couldn't find any property or method of anything that shows or provides a relationship between the matrix T values and the document or artboard coordinate spaces. If I translate the text frame by inverted T values (so they are both zero) it puts the item down *near* the bottom right corner of my artboard (but not exactly in the corner!). Sorry I couldn't find an answer.

 

However, as this thread explores, perhaps there are other ways?

- Mark

 

Edit: ignore my previous post requesting a new question—you are perfectly correct to ask in this thread.

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