Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • EspaƱol
      • FranƧais
      • PortuguĆŖs
  • ę—„ęœ¬čŖžć‚³ćƒŸćƒ„ćƒ‹ćƒ†ć‚£
  • ķ•œźµ­ ģ»¤ė®¤ė‹ˆķ‹°
0

Top/Left Value of Point Text Relative to Composition?

Contributor ,
Apr 27, 2016 Apr 27, 2016

So since the width and height of a point text layer is

--always the size of the composition

--calculateTransformFromPoints can only set and not read a set of values

-- a point text layer's sourceRectatTime top and left values (as well as baselineLoc values)  are relative, as far as I can tell, to its... anchor point? And

-- I can't rely on its anchor point since a) end users move the anchor point and b) we have other functions that periodically center the anchor point of every layer,

I was wondering if there were some other way to calculate the top and left values of a point text layer relative to the composition?

Do I have to draw a mask that is the full size of the layer and then derive the values from its vertices?

TOPICS
Scripting
1.4K
Translate
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

Community Expert , Mar 01, 2017 Mar 01, 2017

sourceRectatTime gives you the corners in layer space. Unfortunately scripting has no build-in function to convert layer space to comp space (expressions have it). Either you can hack using expressions (create an expression that computes the layer to comp space calculation and read its value) or you need to implement it yourself (i.e. recursively going over the layer and all its parents transform properties and compute how they change the position).

Translate
Contributor ,
Mar 01, 2017 Mar 01, 2017

bueller?

Translate
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 01, 2017 Mar 01, 2017

sourceRectatTime gives you the corners in layer space. Unfortunately scripting has no build-in function to convert layer space to comp space (expressions have it). Either you can hack using expressions (create an expression that computes the layer to comp space calculation and read its value) or you need to implement it yourself (i.e. recursively going over the layer and all its parents transform properties and compute how they change the position).

Mathias Mƶhl - Developer of tools like BeatEdit and Automation Blocks for Premiere Pro and After Effects
Translate
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
Contributor ,
Mar 01, 2017 Mar 01, 2017

Thanks. Ugh. This is what I was afraid of. I have been trying sourcePointToComp() but I can find no documentation anywhere as to what parameters this method should take. comp.layer(1).sourcePointToComp() certainly doesn't work.

Translate
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
Contributor ,
Mar 01, 2017 Mar 01, 2017

oh, never mind. I see that you should pass boxTextPos

Translate
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
Advocate ,
Mar 01, 2017 Mar 01, 2017

You can use sourcePointToComp this way:

var time = comp.time;

var rect = comp.layer(1).sourceRectAtTime(time, false);

var pos = comp.layer(1).sourcePointToComp([rec.left, rect.top]);

Oddly enough, it doesnt take a time parameter, only a 2D point.

So you should set the comp.time to the one you want before using.

Xavier

Translate
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
Contributor ,
Mar 01, 2017 Mar 01, 2017
LATEST

thanks. I ended up passing sourceText.value.boxTextPos but I need to handle keyframe values, so it looks like sourceRectAtTime() will be the  way to go

Translate
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