やりたい事
テキストレイヤーにアニメーターを追加し範囲セレクター設定する。
※単位はインデックスに設定する。
分かった事
高度の単位をパーセントかインデックスに変えた場合
範囲セレクター1のプロパティが変わる。
失敗しながらやってみよう!
まずは間違ったコード
var myComp = app.project.activeItem;
var myLayer = myComp.selectedLayers[0];
var myText = myLayer.property("ADBE Text Properties").property("ADBE Text Document").value;
var text = myText.toString (myText);
var text_array = text.split(' ');
var text_ani=myLayer.property("ADBE Text Properties").property("ADBE Text Animators").addProperty("ADBE Text Animator");
text_ani.property("ADBE Text Animator Properties").addProperty("ADBE Text Opacity");
var sel=text_ani.property("ADBE Text Selectors").addProperty("ADBE Text Selector");
sel.property("ADBE Text Percent End").setValue(text_array.length);
sel.property("ADBE Text Range Advanced").property("ADBE Text Range Units").setValue(2); //1パーセント 2インデックス
インデックスの設定は正しく設定されていますが、終了がtext_arrayに入っている7で設定したはずが訳の分からない数字に設定されてしまいました。
コードを確認してみます。
上から10行目が設定してるコードです。
sel.property("ADBE Text Percent End").setValue(text_array.length);
ADBE Text Percent End
なるほどパーセント エンドですね。
調べると
("ADBE Text Percent End")
("ADBE Text Index End")
の2種類が範囲セレクター内のプロパティには存在するという事です。
それを理解したので修正してみました
var myComp = app.project.activeItem;
var myLayer = myComp.selectedLayers[0];
var myText = myLayer.property("ADBE Text Properties").property("ADBE Text Document").value;
var text = myText.toString (myText);
var text_array = text.split(' ');
var text_ani=myLayer.property("ADBE Text Properties").property("ADBE Text Animators").addProperty("ADBE Text Animator");
text_ani.property("ADBE Text Animator Properties").addProperty("ADBE Text Opacity");
var sel=text_ani.property("ADBE Text Selectors").addProperty("ADBE Text Selector");
sel.property("ADBE Text Index End").setValue(text_array.length);//ココをインデックスエンドに変更しました。
sel.property("ADBE Text Range Advanced").property("ADBE Text Range Units").setValue(2); //1パーセント 2インデックス
これを実行すると・・・
エラー:プロパティまたは親のプロパティがhiddenです。
コードを確認します。
sel.property("ADBE Text Index End").setValue(text_array.length);//ココをインデックスエンドに変更しました。
sel.property("ADBE Text Range Advanced").property("ADBE Text Range Units").setValue(2); //1パーセント 2インデックス
そりゃそうですね。
このコードだとインデックスの数字を先に設定しているので、この状態ではまだパーセントエンドになっているわけです。
なので順番を変えます。
これで正しいコードが出来上がりました!
var myComp = app.project.activeItem;
var myLayer = myComp.selectedLayers[0];
var myText = myLayer.property("ADBE Text Properties").property("ADBE Text Document").value;
var text = myText.toString (myText);
var text_array = text.split(' ');
var text_ani=myLayer.property("ADBE Text Properties").property("ADBE Text Animators").addProperty("ADBE Text Animator");
text_ani.property("ADBE Text Animator Properties").addProperty("ADBE Text Opacity");
var sel=text_ani.property("ADBE Text Selectors").addProperty("ADBE Text Selector");
sel.property("ADBE Text Range Advanced").property("ADBE Text Range Units").setValue(2); //1パーセント 2インデックス
sel.property("ADBE Text Index End").setValue(text_array.length);
問題なくやりたい事が出来ました。
おまけに単位や基準等のvalue設定もメモ
//単位
sel.property("ADBE Text Range Advanced").property("ADBE Text Range Units").setValue(2); //1パーセント 2インデックス
//基準
sel.property("ADBE Text Range Advanced").property("ADBE Text Range Type2").setValue(4); //1 文字 2スペースを除いた文字 3単語 4行
//モード
sel.property("ADBE Text Range Advanced").property("ADBE Text Selector Mode").setValue(2); //1 加算 2減算 3・・・~6まで
//シェイプ
sel.property("ADBE Text Range Advanced").property("ADBE Text Range Shape").setValue(2); //1 ~6まで