1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

[aftereffects] コンポ内レイヤープロパティ情報をテキストに書き出すスクリプト

Last updated at Posted at 2020-12-09
※記事に関しましてご注意下さい
他記事作成時など実験時に使用したスクリプトのメモです。
間違い・勘違いが含まれている可能性もありますので予めご了承ください。

内容

コンポ内レイヤープロパティ情報をテキストに書き出すスクリプト

主にプロパティの階層構造と matchName、properyIndex の確認用です。
スクリプト本体は 最後尾のソースコード です。

以前に投降した以下記事
effect("スライダー制御")("スライダー") で起こる多言語トラブルの原因
を含め度々調べることになるためスクリプト化したものです。
部分的に書き換えれば他にも流用可能かと思います。

実行前の注意点

設定で以下が有効である必要があります。

メニュー > 編集 > 環境設定 > 一般設定 >
スクリプトによるファイルへの書き込みとネットワークへのアクセスを許可

※または
メニュー > 編集 > 環境設定 > スクリプトとエクスプレッション >
スクリプトによるファイルへの書き込みとネットワークへのアクセスを許可

Please select "Allow Scripts To Write Files" option.

Menu > Edit > Preferences > General >
Allow Scripts to Write Files and Access Network

* or
Menu > Edit > Preferences > Scripting & Expressions >
Allow Scripts to Write Files and Access Network

実行例

適当なコンポジションと用意し、プロパティを選択して実行します。

RDJ_reportPropertyInfo_example.png

終了するとメモ帳なり関連付けされたアプリで結果が表示されます。

aftereffects_property_report.txt
(propertyDepth) propertyIndex: name [matchName]

+ 1 : 異なるマット [ADBE Difference Matte2]
++ 1 : 表示 [ADBE Difference Matte2-0001]
++ 2 : 異なるレイヤー [ADBE Difference Matte2-0002]
++ 3 : レイヤーサイズが異なる場合 [ADBE Difference Matte2-0003]
++ 4 : マッチングの許容度 [ADBE Difference Matte2-0004]
++ 5 : マッチングの柔軟度 [ADBE Difference Matte2-0005]
++ 6 : 異なる前にブラー [ADBE Difference Matte2-0006]
++ 7 : コンポジットオプション [ADBE Effect Built In Params]
+++ 1 : マスク [ADBE Effect Mask Parade]
+++ 2 : エフェクトの不透明度 [ADBE Effect Mask Opacity]

同じプロパティを english モードの aftereffects で実行した結果

aftereffects_property_report.txt
(propertyDepth) propertyIndex: name [matchName]

+ 1 : Difference Matte [ADBE Difference Matte2]
++ 1 : View [ADBE Difference Matte2-0001]
++ 2 : Difference Layer [ADBE Difference Matte2-0002]
++ 3 : If Layer Sizes Differ [ADBE Difference Matte2-0003]
++ 4 : Matching Tolerance [ADBE Difference Matte2-0004]
++ 5 : Matching Softness [ADBE Difference Matte2-0005]
++ 6 : Blur Before Difference [ADBE Difference Matte2-0006]
++ 7 : Compositing Options [ADBE Effect Built In Params]
+++ 1 : Masks [ADBE Effect Mask Parade]
+++ 2 : Effect Opacity [ADBE Effect Mask Opacity]

ソースコード

RDJ_reportPropertyInfo.jsx
//-----------------------------------
// report property infos from selected properties
//
// author: https://qiita.com/rdj_masato
//-----------------------------------
(function (me)
{
	// ----------------
	var _propInfo = function(prop) {
		var ret = [ {
			'depth': prop.propertyDepth,
			'index': prop.propertyIndex,
			'name': prop.name,
			'matchName': prop.matchName,
		} ];
		if (! prop.hasOwnProperty('numProperties')) return ret;
		for (var i = 0; i < prop.numProperties; i ++) ret.push.apply(ret, _propInfo(prop.property(i + 1)));
		return ret;
	};

	// ---------------- collection & validation
	var comp = app.project.activeItem;
	if (! (comp instanceof CompItem)) {
		Window.alert('Please open composition first.', 'Warning');
		return;
	}
	var props = [];
	for (var i = 0; i < comp.selectedProperties.length; i ++) {
		var prop = comp.selectedProperties[i];
		// removing duplicates
		for (var j = 0; j < props.length; j ++) {
			if (props[j] != prop.parentProperty) continue;
			props.splice(j, 1);
		}
		props.push(prop);
	}
	if (props.length < 1) {
		Window.alert('Please select the properties you need.', 'Warning');
		return;
	}

	// ---------------- extraction
	var infos = [];
	for (var i = 0; i < props.length; i ++) infos.push.apply(infos, _propInfo(props[i]));

	// ---------------- integration
	var path = [Folder.temp.fullName, 'aftereffects_property_report.txt'].join('/');

	var lines = [];
	// header
	lines.push( ['(propertyDepth) propertyIndex: name [matchName]'].join('\t') );
	lines.push( '' );
	// body
	for (var i = 0; i < infos.length; i ++) {
		var item = infos[i];
		lines.push( (new Array(item.depth)).join('+') + ' ' + item.index + ' : ' + item.name + ' [' + item.matchName + ']' );
	}

	var fd = new File(path);
	if (! fd.open('w')) {
		Window.alert('Failed to write file to disk.', 'Warning');
		return;
	}
	for (var i = 0; i < lines.length; i ++) fd.writeln(lines[i]);
	fd.close();

	fd.execute();
}
)(this);
//-----------------------------------
1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?