選択されているフレームの種類を表示する

■プログラム説明(ソースコード説明)
 最前面のドキュメント上で選択されているフレームの種類を表示します。種類は文字でなく数値で返されるので注意が必要です。

■ソースコード
sel = app.activeDocument.selection;
for (i=0; i<sel.length; i++)
{
alert(i+"番目は"+sel[i].contentType+"です");
}

■使い方
1:スクリプトを実行します。
2:ドキュメント内で選択されている項目のフレームの種類が表示されます。


■ポイント
 contentTypeには以下の種類を指定できます。

割り当てなし ContentType.unassigned 1970168179
グラフィック ContentType.graphicType 1735553140
テキスト   ContentType.textType 1952412773

また、種類を調べた場合には対応した数値が返されるので注意が必要です。これは将来的には好ましくない方法なので、スクリプトの先頭で変数などに対応する値を入れておき、それを参照して利用するようにするのが良いでしょう。これは以下のようにします。

cContentType_unassigned = 1970168179;
cContentType_graphicType = 1735553140;
cContentType_textType = 1952412773;
sel = app.activeDocument.selection;
for (i=0; i<sel.length; i++)
{
if (sel[i].contentType == cContentType_unassigned) str = "unassigned";
if (sel[i].contentType == cContentType_graphicType) str = "graphicType";
if (sel[i].contentType == cContentType_textType) str = "textType";
alert(i+"番目は"+str+"です");
}

■実際のスクリプトをダウンロード(sample.js.zip)