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

84

Likes

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

Likes

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);

Likes

Translate

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

Likes

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

LATEST

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);

Likes

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
Adobe Community Professional ,
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

Likes

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