クリエイター手抜きプロジェクト[414]AfterEffects CS3〜CC 2014編 選択された項目やレイヤーの内部情報を表示する
── 古籏一浩 ──

投稿:  著者:



今回は、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);
}
})();


【古籏一浩】openspc@alpha.ocn.ne.jp
< http://www.openspc2.org/
>

AfterEffectsはいいんですが、同じAdobeのアプリケーションでもInDesignはGUIにバグがあって、こういうツールはうまく動作しません。

Ingress、もうすぐLevel 8になれそう。田舎なのでレゾネーターが全部Level 8になることが滅多にありません。田舎でなく少し大きい地方都市まで遠征に行くと、Level 8が8本ささったポータルがたくさんあります。

さすが、松本市。塩尻市とは違う。ということで仕事の帰りにたくさんポータルをハック。撮影帰りにハック、税務署帰りにハック。もう、確定深刻じゃなくて確定申告終わったので気は楽です。

・Adobe JavaScriptリファレンス
< http://www.amazon.co.jp/dp/B00FZEK6J6/
>

・Illustrator自動化基本編
< http://www.amazon.co.jp/dp/B00R5MZ1PA
>

・ExtendScript Toolkit(ESTK)基本編
< http://www.amazon.co.jp/dp/B00JUBQKKY/
>

・Mac : JavaScript for Automation(JXA)例文辞典
< http://www.openspc2.org/reibun/JXA/Yosemite/
>

・jQuery+jQuery UI+jQuery Mobile逆引きハンドブック
< http://www.amazon.co.jp/dp/486354149X
>

・jQueryプラグイン逆引きハンドブック
< http://www.amazon.co.jp/dp/4863541619/
>

・データビジュアライゼーションのためのD3.js徹底入門
< http://www.amazon.co.jp/dp/4797368861
>

・4K/ハイビジョン映像素材集
< http://www.openspc2.org/HDTV/
>

・JavaScript逆引きハンドブック
< http://www.amazon.co.jp/dp/4863541082
>

・クリエイター手抜きプロジェクト
< http://www.openspc2.org/projectX/
>

・Adobe Illustrator CS3 + JavaScript 自動化サンプル集
< https://www.ddc.co.jp/estore/cgi/item/start.cgi?m=DetailViewer&record_id=243
>
吉田印刷所の「印刷の泉」でも購入できるようになりました。