Photoshop CS3〜CC2014編 選択されたレイヤーやドキュメントの内部情報を表示する

今回は、Photoshopで選択されたレイヤーの内部情報を表示する開発者向けのスクリプトです。
Photoshopの場合、Illustratorと違ってあまり融通がききません。そこで、レイヤー情報とドキュメント情報、アプリケーション情報を表示するようにしてあります。

GUIで編集エリアに出力されるので、表示されたオブジェクト内容をコピーすることができます。閲覧時にはホイールマウスを使うとスムーズに内容を確認できます。

// 選択したレイヤーの詳細な情報を表示する
(function(){
var selObj = app.activeDocument.activeLayer;
// 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 parentBtn = winObj.add("button", [10, 10, 110, 40], "親オブジェクト");
var docBtn = winObj.add("button", [130, 10, 320, 40], "documentオブジェクト");
var appBtn = winObj.add("button", [340, 10, 470, 40], "appオブジェクト");
statusArea.text = getObjectInformation(selObj);
parentBtn.onClick = function(){
statusArea.text = getObjectInformation(selObj.parent);
}
docBtn.onClick = function(){
statusArea.text = getObjectInformation(app.activeDocument);
}
appBtn.onClick = function(){
statusArea.text = getObjectInformation(app);
}
winObj.center();
winObj.show();
// オブジェクトの情報を取得
function getObjectInformation(obj){
if (!obj){ return; }
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";
}
}
}
// Arrayの場合
if (t == "Array"){
for(var j=0; j<obj[i].length; j++){
var t2 = checkType(obj[i][j]);
text = text + "  "+j+":"+obj[i][j]+ " | " + t2 +"\n";
// objectの場合
if (t2 == "object"){
for(var k in obj[i][j]){
try{
text = text + "    " + k + " = " + obj[i][j][k] + "\n";
}catch(e){
text = text + k + "【取得不可】\n";
}
}
}
}
}
}catch(e){
text = text + i + " | " + t + "【取得不可】\n";
}
}
return text;
}
// オブジェクトの型を調べる
function checkType(targetObj){
//$.writeln(targetObj);
if (targetObj instanceof Array){
return "Array";
}
return typeof(targetObj);
}
})();


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