Adobe AfterEffects CS3〜CC2014編 選択された項目やレイヤーの内部情報を表示する

今回はAfterEffectsで選択されたプロジェクト内の項目かタイムラインウィンドウで選択されたレイヤーの内部情報を表示するスクリプトです。AfterEffectsはプロジェクト内の項目が選択されている場合とタイムラインでレイヤーが選択されている場合で若干異なります。また、appオブジェクト、projectオブジェクトもボタンクリックで表示できるようになっています。


// 選択した項目やレイヤーの詳細な情報を表示する
(function(){
var selObj = app.project.selection;
if (selObj.length < 1){
if (app.project.activeItem.selectedLayers.length < 1){
alert("情報を表示したい対象を複数選択してから実行してください");
return;
}else{
selObj = app.project.activeItem.selectedLayers;
}
}
// GUI
var winObj = new Window("dialog", "ステータス表示", [0, 0, 800, 640]);
winObj.add("button", [ 10, 50, winObj.frameSize.width-10, 70 ], "完了", { name : "ok" });
var statusArea = winObj.add("edittext",
[ 10, 100, winObj.frameSize.width-10, winObj.frameSize.height-40]);
var prevBtn = winObj.add("button", [10, 10, 110, 40], "前の項目");
var nextBtn = winObj.add("button", [150, 10, 250, 40], "次の項目");
var appBtn = winObj.add("button", [300, 10, 450, 40], "appオブジェクト");
var projectBtn = winObj.add("button", [500, 10, 650, 40], "projectオブジェクト");
var index = 0; // 選択した項目/レイヤーの参照番号
statusArea.text = getObjectInformation(selObj[index]);
prevBtn.onClick = function(){
index = index - 1;
if (index < 0){ index = 0; }
statusArea.text = getObjectInformation(selObj[index]);
}
nextBtn.onClick = function(){
index = index + 1;
if (index >= selObj.length){ index = selObj.length -1; }
statusArea.text = getObjectInformation(selObj[index]);
}
appBtn.onClick = function(){
statusArea.text = getObjectInformation(app);
}
projectBtn.onClick = function(){
statusArea.text = getObjectInformation(app.project);
}
winObj.center();
winObj.show();
// オブジェクトの情報を取得
function getObjectInformation(obj){
var text = "";
for(var i in obj){
try{ var t = checkType(obj[i]);
}catch(e){ t = "【種類不明】"; }
try{
text = text + i + " = " + obj[i] + " | " + t + "n";
// objectの場合
if (t == "object"){
// 1階層のみ処理する
for(var j in obj[i]){
try{ var t1 = checkType(obj[i]);
}catch(e){ t1 = "【不明】"; }
try{
text = text + "  " + j + " = " + obj[i][j] + " | " + t1 + "n";
}catch(e){
text = text + j + "【取得不可】n";
}
}
}
}catch(e){
text = text + i + " | " + t + "【取得不可】n";
}
}
return text;
}
// オブジェクトの型を調べる
function checkType(targetObj){
//$.writeln(targetObj);
if (targetObj instanceof Array){
return "Array";
}
return typeof(targetObj);
}
})();

[サンプルをダウンロード]