//フォントを変更してアンカーポイント・位置を真ん中に
function anchorCenter(textLayerObj,fs){
//フォントサイズの変更
var cNTextTd = textLayerObj.property("ADBE Text Properties").property("ADBE Text Document").value; //テキストドキュメント
cNTextTd.fontSize = fs;
textLayerObj.property("ADBE Text Properties").property("ADBE Text Document").setValue(cNTextTd);
//アンカーを真ん中に変更
var curTime = app.project.activeItem.time;
var myAnchor = textLayerObj.property("ADBE Transform Group").property("ADBE Anchor Point");
var tl = textLayerObj.sourceRectAtTime(curTime, false).left; //テキストの左側の座標 l
var tw =textLayerObj.sourceRectAtTime(curTime, false).width; //テキストの全体の幅 b
var tt = textLayerObj.sourceRectAtTime(curTime, false).top;//テキスト上の座標 c
var th = textLayerObj.sourceRectAtTime(curTime, false).height; //テキスト全体の高さ d
var lv=myAnchor.value;
var setX=roundFloat((tw/2)+tl);
var setY=roundFloat((th/2)+tt);
var setA = myAnchor.setValue([setX,setY]);
//位置を真ん中に
px = div(myComp.width,2);
py = div(myComp.height,2);
textLayerObj.property("ADBE Transform Group").property("ADBE Position").setValue([px,py])
function roundFloat(number) {
var _pow = Math.pow( 10 , 4 );
return Math.round( number * _pow ) / _pow;
}
function div(n,num){
return n / num;
}
}
app.beginUndoGroup("");
var myComp = app.project.activeItem;
var selLay = myComp.selectedLayers;
for (var i = 0 ; i <selLay.length; i++ ){
var myLay = selLay[i];
if (myLay instanceof TextLayer ){
anchorCenter(selLay[i],130)
}
}
app.endUndoGroup();