Highlighted

Are functions like toComp() and toWorld() available in scripts?

New Here ,
Oct 02, 2017

Copy link to clipboard

Copied

I've stumbled upon these really useful functions, but they only seem to work for me in expressions, and when I try to use them in my script, I get the function undefined message. It would be really weird if they didn't implement this feature for scripts..

Am I missing something?

Unfortunately, you are not missing anything.

The easiest and safest workaround is to add a temporary Point Control (or 3D Point Control for toWorld) somewhere with the appropriate expression, harvest the result, and remove the control.

You can also try to write your own, it's possible but quite some work.

Xavier

TOPICS
Scripting

Views

876

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

Are functions like toComp() and toWorld() available in scripts?

New Here ,
Oct 02, 2017

Copy link to clipboard

Copied

I've stumbled upon these really useful functions, but they only seem to work for me in expressions, and when I try to use them in my script, I get the function undefined message. It would be really weird if they didn't implement this feature for scripts..

Am I missing something?

Unfortunately, you are not missing anything.

The easiest and safest workaround is to add a temporary Point Control (or 3D Point Control for toWorld) somewhere with the appropriate expression, harvest the result, and remove the control.

You can also try to write your own, it's possible but quite some work.

Xavier

TOPICS
Scripting

Views

877

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
Oct 02, 2017 0
Advocate ,
Oct 02, 2017

Copy link to clipboard

Copied

Unfortunately, you are not missing anything.

The easiest and safest workaround is to add a temporary Point Control (or 3D Point Control for toWorld) somewhere with the appropriate expression, harvest the result, and remove the control.

You can also try to write your own, it's possible but quite some work.

Xavier

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
Reply
Loading...
Oct 02, 2017 0
New Here ,
Oct 02, 2017

Copy link to clipboard

Copied

Thanks for confirming that there really is no such function.. it's just really weird and embarrassing, in my opinion, that it doesn't exist.

I've actually come up with a workaround, so for given 3D coordinates (let's say x,y,z = 100,200,300 for simplicity) I do this:

nullLayer.property("Transform").property("Position").expression = "myOtherLayer.toComp([100, 200, 300]);"

which assigns the expression to the null layer's position.

After that I just read that value like this:

pos2D = nullLayer.property("Transform").property("Position").value;

Which looks exactly like what you've described, but without Point Control, so I would like to ask you whether you think Point Control has any benefits over what I'm doing?

Thanks!

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
Reply
Loading...
Oct 02, 2017 0
Advocate ,
Oct 02, 2017

Copy link to clipboard

Copied

To set the expression, you need a host property. If you already have a free 2D/3D property to use (like the null position)  then you can it of course, but in some situations you might have to add something (a Point Control, or a Null).

Xavier

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
Reply
Loading...
Oct 02, 2017 1
Adobe Community Professional ,
Jun 20, 2020

Copy link to clipboard

Copied

If anyone is still looking for methods to get layers coordinates via ExtendScript, look no further - I've reverse engineered toWorld() and toComp() methods and created a separate class for it https://github.com/rendertom/LST

 

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
Reply
Loading...
Jun 20, 2020 1