0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

[AE エクスプレッション] 現在時間のマーカーキーのインデックスを取得する

Last updated at Posted at 2020-01-09

どこかの記事でも書いてあると思うけど、これだけ欲しい時にすぐ探せるようにメモです。

ちょっとどこかで自分が良く使うエクスプレッションをまとめたエクステンションを作ろう。

function nowKey(){
	var targetLayer = thisLayer; //ここにターゲットとなるマーカーのあるレイヤーを設定する
	var KeyN = 0;
	if (targetLayer.marker.numKeys >0){
		KeyN = targetLayer.marker.nearestKey(time).index;
		if(targetLayer.marker.key(KeyN).time > time) KeyN--
	}
	return KeyN
}

これの変化形を作成

複数行のテキストにキーフレームがあり、行ごとに変化させる何らかのアニメーターを入れて
行ごとの秒数の確認をするように作ったもの

var targetcomp;
var myComp =[];

function nowKey(tl){
    var targetLayer = tl; //ここにターゲットとなるマーカーのあるレイヤーを設定する
    var KeyN = 0;
    if (targetLayer.text.animator("アニメーター 1").selector("範囲セレクター 1").start.numKeys >0){
        KeyN = targetLayer.text.animator("アニメーター 1").selector("範囲セレクター 1").start.nearestKey(time).index;
        if(targetLayer.text.animator("アニメーター 1").selector("範囲セレクター 1").start.key(KeyN).time > time) KeyN--
    }
    return KeyN
}

function nextKey(tl){
    var targetLayer = tl; //ここにターゲットとなるマーカーのあるレイヤーを設定する
    var KeyN = 0;
    if (targetLayer.text.animator("アニメーター 1").selector("範囲セレクター 1").start.numKeys >0){
        KeyN = targetLayer.text.animator("アニメーター 1").selector("範囲セレクター 1").start.nearestKey(time).index;
        if(targetLayer.text.animator("アニメーター 1").selector("範囲セレクター 1").start.key(KeyN).time <= time) KeyN++
    }
    return KeyN
}

for( var i = thisComp.numLayers ; i >= 1; i--){
	if ( (thisComp.layer(i).active == true) ){
		try{
			myComp.push(thisComp.layer(i).index)
			thisTimeLayer = thisComp.layer(myComp[myComp.length-2]);![Adobe-After-Effects-2022-Z__CoconalaCustomer_gjtmpdt55_AE_telop.aep-2022-01-15-11-18-15.gif](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/178061/f2bc9943-3f6f-a80c-05b9-11ef7b779a10.gif)

			thisTimeLayer.text.animator("アニメーター 1").selector("範囲セレクター 1").start;
			nowKey(thisTimeLayer);
			layerConvertArray =thisTimeLayer.text.sourceText.split("\r");
			nowViewText = layerConvertArray[nowKey(thisTimeLayer)-1];
			if ( nowViewText == "" ){
				nowViewText = "空白行"
			}else{
				nowViewText
			}
			
//時間の計算
		nowKeyTime = thisTimeLayer.text.animator("アニメーター 1").selector("範囲セレクター 1").start.key(nowKey(thisTimeLayer)).time;
		nextKeytime = thisTimeLayer.text.animator("アニメーター 1").selector("範囲セレクター 1").start.key(nextKey(thisTimeLayer)).time;
		resultText = nowViewText.replace(/\s+/g, "");
		resultText +"\r"+ sub(nextKeytime,nowKeyTime)+""
		}catch(e){
			""
		}
	}
}

Adobe-After-Effects-2022-Z__CoconalaCustomer_gjtmpdt55_AE_telop.aep-2022-01-15-11-18-15.gif

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?