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

Extendscript - Text layer alignment / anchorpoint

New Here ,
Mar 02, 2018 Mar 02, 2018

Copy link to clipboard

Copied

Hi Friends!

Neck deep building a script to batch out a bunch of numerical comps, wanting to set a text layer to be dead center. Have managed to get a justification param set and even user defined, however want to script the equivalent of using the align palette and selecting "Align Horizontally" and " Align Vertically"

Have tried to set the anchor point by inserting an expression onto the layer (via extend-script) which I've made work for an image layer, but sad times with a text layer - some of my research leads me to believe this wont work for text layers. Also tried sourceRectAtTime with no luck.

Hoping someone has some thoughts or solution for this as I'm turning out several hundred comps every time this script runs so manually setting this isn't an option.

Thanks!

TOPICS
Scripting

Views

1.7K

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
Participant ,
Feb 04, 2020 Feb 04, 2020

Copy link to clipboard

Copied

Maybe I am missing something, but shouldn't it be quiet easy doing it like this:

 

-----------------------------

// Get Comp by Name
for (i = 1; i <= app.project.numItems; i++){
if ((app.project.item(i) instanceof CompItem) && (app.project.item(i).name == "My_Test_Comp")){
var aeMyComp= app.project.item(i);
}
}

var myCompCenter = aeMyComp.width/2; // set value to comp horicontal center. Eg Comp = 1920 means myCompCenter will be 960
var theLayer = aeMyComp.layer(1); // select layer with index 1 in this example. Select what ever you need
var originalY = theLayer.position.value[1]; // position value #1 ist the 2nd array value of position aka the Y value
theLayer.position.setValue([myCompCenter,originalY]);

--------------------------

 

You have to set the anchor of your layer to 0/0 for this to work, but thats something you could even do with the script too right bevor you start the alignment.

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
Participant ,
Feb 13, 2020 Feb 13, 2020

Copy link to clipboard

Copied

LATEST

Update: I'm currently working on a solution for this problem and got a near to perfect centering with the code above plus a correction of the text-layers anchor:

 

theLayer.anchorPoint.setValue([430,originalY]);

 

I came up with 430 by fiddling around with the align tool and looking for what its been doing. It looks centered to me now, but I have no idea why 430 is the magic number...I'm working with a font size of 75 in a 1920x1080 comp, but 430...?? 2x430 would be 860, but where are the missing 100 to 960?

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