【注意】ffxは古いバージョンのAEで作ること!!最新のAEで作ったら古いAEからは開けない。
var f = File("ffxファイルパス");f.encoding = 'BINARY'f.open('e');
var binary;binary = f.read().toSource();
var myFile = new File("~/Desktop/binaryOutput.txt");myFile.open("w");myFile.encoding = "BINARY";myFile.write(binary);myFile.close();
$.writeln(binary);
f.close();
上記を実行すると出てくるファイルを開いて (new String(この部分)) をコピー。下記の’BINARY’の部分にコピペ
var pseudoEffectData = { name: "YourScriptName", matchName: "Pseudo/YourScriptName", binary: 'BINARY'}
んで下記のような関数で処理をする。先程バイナリ化したffxから任意のフォルダにffxを生成してそれを使う、みたいな流れ。生成先フォルダはFolder.UserDataのaescriptsフォルダ内にしている。
function applyPseudoEffect(pseudoEffectData, effectsProp) { var pseudoEffect, ffxFile, writeFile = function (pathToFile, content, encoding) { var fileObject = new File(pathToFile); fileObject.encoding = encoding || "utf-8"; fileObject.open("w"); fileObject.write(content); fileObject.close(); return fileObject; }, makePseudoEffectLive = function (ffxFile) { var tempComp, tempLayer; tempComp = app.project.items.addComp("tempComp", 100, 100, 1, 1, 24); tempLayer = tempComp.layers.addShape(); tempLayer.applyPreset(ffxFile); tempComp.remove(); };
if (!effectsProp.canAddProperty(pseudoEffectData.matchName)) { var dataPath = Folder.decode(Folder.userData) + '/aescripts/YourScriptName'; var f = new Folder(dataPath); if (!f.exists) f.create();
ffxFile = writeFile(Folder.userData.fsName + "/aescripts/YourScriptName/" + pseudoEffectData.name + ".ffx", pseudoEffectData.binary, "BINARY"); makePseudoEffectLive(ffxFile); }
pseudoEffect = effectsProp.addProperty(pseudoEffectData.matchName); return pseudoEffect;}
applyPseudoEffect(pseudoEffectData, textLayer.effect);
ref: 📝After Effects Scripting Tutorial: Embed FFX File in Script