after-effects:将指令从node.js发送到After Effects脚本环境

  • d5_315294
  • 34.9KB
  • zip
  • 0
  • VIP专享
  • 0
  • 2022-05-01 08:32
后遗症 为什么? 您正在运行安装了After Effects的node.js服务器,并且希望在服务器端运行渲染命令。 您在本地使用node.js,并且不希望通过ExtendScript工具箱运行AE脚本。 您想使用ES6语法运行和创建AE脚本。 因为它激怒了您虔诚的母亲,您想叛逆。 要求 显然,您需要在计算机上安装After Effects。 此外,在After Effects首选项中,启用: 首选项->常规->允许脚本写入文件和访问网络 基本用法 var ae = require("after-effects"); 塔达阿(Ta Daaaa) 。 本自述文件的其余部分假定ae是After Effects模块。 要在After Effects中执行一些代码: ae(() => alert("Hello!\nFrom node.js")); 真有趣! 只要在您的Applica
  • after-effects-master
  • lib
  • includes
  • es5-shim.jsx
  • get.jsx
  • console.jsx
  • platform-mac.js
  • platform-win.js
  • command.js
  • .eslintrc.json
  • .npmignore
  • .gitignore
  • index.js
  • package-lock.json
  • package.json
# after-effects ___ ## Why? * You're running a node.js server with After Effects installed, and you'd like to run render commands server-side. * You use node.js locally, and prefer not to run AE scripts with the ExtendScript toolkit. * You'd like to run and create AE scripts using ES6 syntax. * Because it angers your religious mother, and you want to be rebellious. ## Requirements Obviously, you need After Effects installed on your machine. Additionally, in your After Effects preferences, enable: *Preferences -> General -> Allow Scripts to Write Files and Access Network* ___ ## Basic Usage var ae = require("after-effects"); _Ta Daaaa_. The rest of this readme assumes ae is the after effects module. To execute some code in After Effects: ae(() => alert("Hello!\nFrom node.js")); _What fun!_ Provided that After Effects is installed in your Applications/Program directory, and that you haven't renamed any of the folders or something, this will work. ___ ## Scripting Considerations The After Effects scripting environment is a completely different engine than node.js. Node.js has no access to the After Effects environment, and vice versa: var foo = "bar"; //this will not work: ae(() => alert(foo)); If you'd like to send data from node.js to After Effects, you have to supply it as an argument along with the execute command: var foo = "bar"; ae((foo_from_node) => alert(foo_from_node), foo); What you're really doing when you use the execute method is converting the supplied function to a string and then sending it to After Effects to parse. As a result, whatever data you supply has to be convertible to JSON. You can also retrieve data from After Effects with the same restriction: var project_name = ae(() => { if (app.project.file) return; else return "(project not yet saved)"; }); console.log(project_name); Also see the [After Effects Scripting Guide]( for information about the After Effects Javascript API. ___ ## Sync vs Async The default shortcut function will run the code synchronously and block NodeJS until complete, however, you can also send code to After Effects asynchronously: //execute sends code to after effects, returning a Promise ae.execute(() => { return; }) .then(name => console.log(name)) .catch(err => console.log('No Active Item')); The default shortcut function actually is just a shortcut to ae.executeSync: function save_current_project() {; } ae.executeSync(save_current_project); //is the same as ae(save_current_project); ___ ## Options The ae object has a couple of options: ae.options.errorHandling = true; ae.options.minify = false; ae.options.program = null; ae.options.includes = [ './node_modules/after-effects/lib/includes/console.jsx', './node_modules/after-effects/lib/includes/es5-shim.jsx', './node_modules/after-effects/lib/includes/get.jsx' ] This would be how you set defaults. ### errorHandling With errorHandling enabled, errors thrown in After Effects will be suppressed and returned in the promise result: ae.options.errorHandling = true; ae.execute(() => throw new Error("FooBar got FooBarred all the way to FooBar.")) .then(result => console.log(result)) // empty .catch(err => console.log(err)); // contains error With errorHandling disabled, After Effects will create a popup and prevent further code execution until it is dealt with. ### minify If true, the code will be minified before being sent to After Effects. This is disabled by default, which is different from previous versions of this package. I feel there's little point in spending the extra time to minify code that isn't going over a network. Still, you can set minify to true if you're into that sort of thing. ae.options.minify = true; ### program By default, ae will look for an After Effects installation in your platforms default application directory. If you've installed it elsewhere, you'll have to set this to the custom app directory. ae.options.program = path.join('OtherAppDirectory','Adobe After Effects 2015'); Also handy if you've installed multiple versions of After Effects on your machine, and you'd like to target a specific one. ### includes Includes is an array which will concatanate the code from other files into your command, for use inside After Effects. The defaults are as follows: ##### _console.js_ Provides console.log to the After Effects namespace. 'console.log' inside After Effects will return logs to the node.js console when execution is complete, assuming you correctly have *Preferences -> General -> Allow Scripts to Write Files and Access Network* set inside After Effects. ##### _es5-shim.js_ The javascript environment within After Effects is very dated, pre ES5. With es5-shim included, methods and functions available in es5 will be available. ae.execute(() => { [1,2,3,4].forEach(i => alert(i)); // wont throw an error }); Also notice that you can use ES6 syntax when executing code. It's parsed through [babel]( before being sent to After Effects. ##### _get.js_ Provides a jQuery inspired selector object to work with items in After Effects inside of an object called 'get': ae.execute(() => { //finds every composition with 'final' in the name //and alerts it get.comps(/Final/) .each(comp => alert(; }); See the API for the get object below. ### Include Considerations The default options exist in their current state to benefit quickstarting. I just want to fire up atom and run an ae command without thinking too much about it. That said, there are a couple of things you can do to optimize it's usage. #### _Persistent Environment_ The scripting environment inside After Effects persists between executions, unless you manually reset it or restart After Effects. ae(()=> console.log('includes ran')); ae.options.includes = []; //Once you've run your includes, //you can disable them and still benefit from their usage in the namespace: ae(()=> ["shim","still","exists"].forEach(str => alert(str))); You have access to the After Effects global namespace, through $.global: ae(() => $.global.whoKilledKenny = "you bastards"); var who = ae(() => $.global.whoKilledKenny); console.log(who); //you bastards #### _Scripts directory_ There is a convenience method to get the scripts directory associated with the current After Effects install: console.log(ae.scriptsDir); This will throw an error if After Effects can't be found. This is useful if you want to include any scripts in the Scripts Directory that might exist. #### _Startup Folder_ Alternatively, You can copy the scripts provided in the lib folder to the After Scripts/Startup folder inside your After Effects installation. Then will be run and added to the global namespace when After Effects is starting, and will not have to be included while executing commands from ae. #### _.jsx vs .js_ If you just installed After Effects, you'll notice that all of the files in the Scripts Directory end in .jsx If you're familiar with React, you're probably wondering what the hell they're doing there. Well, long before Facebooks React, Adobe's primary javascript format was .jsx. This is because the Adobe javascript Engine has an xml literal built into it: var xml = <foo><bar/></foo> We can't take advantage of that xml literal inside nodejs because babel doesn't have a preset for it. As a result, if you try to include a .jsx file, ae will assume it's written in Adobe Javascript. ae will not babelify or minify it, otherwise it will could cause errors if the XML literal was used. ___ ## Advanced Usage If you're
    • WebSocket仿真-Node.js服务器-Node.js开发
      SockJS系列:SockJS客户端JavaScript客户端库SockJS节点Node.js服务器SockJS erlang Erlang服务器SockJS-tornado Python / Tornado服务器vert.x Java / vert.x服务器正在进行中:SockJS-ruby SockJS-netty SockJS...
    • 沙发服务器:Couch测试服务器Node.js,Typescript
    • TwittnukerGCMServer_node:Twittnuker GCM 服务器 node.js 实现
      Twittnuker 自托管 GCM 推送服务器 node.js 中的 Twittnuker GCM 推送服务器实现。 安装 npm install 去做
    • Node.js 7.x异步/等待支持演示-Node.js开发
      Node.js v7.xx附带实验性的异步/等待支持,大大简化了编写现代服务器端代码所需的样板。 该项目是Node.js v7 async / await演示的演示。这是什么? Node.js v7.xx附带实验性的异步/等待支持,大大简化了编写现代...
    • 服务器JavaScriptNode.js
    • node.js:学习 node.js
      基于一本叫node.js的教材,学习node.js服务器开发 要求 节点.js 15.2.1 npm 7.0.10 快速开始 第一个休息服务器 cd Document/ch4 node restServer.js 在控制台勾选“Server is waiting on port 8082”后,用...
    • TeonetJS:Teonet服务器Node.js模块
      在和使用的Teonet服务器node.js模块,用于将node.js服务器应用程序与Teonet连接。 安装 npm install teonet 开发人员注意事项 在构建此软件包之前使用: sudo apt-get install build-essential
    • hapi, 面向 node.js服务器框架.zip
      hapi, 面向 node.js服务器框架 Web和服务应用框架领导维护者: Eran Hammer 。是一个简单易用的配置框架,支持输入验证,缓存,认证以及其他用于构建网络和服务应用程序的重要设施。 让开发者专注于以高度模块化和...
    • monstre:首要服务器node.js
      怪物 第一台服务器node.js
    • MT4-Node.js, MT4 node.js 客户/服务器桥.zip
      MT4-Node.js, MT4 node.js 客户/服务器桥 MT4-Node.jsMT4 node.js 客户端/服务器访问企鹅 trader,从社区获得帮助这演示了如何在 node.js 服务器和MT4客户端应用程序之间快速通信。 没有延迟,连接/计算是在相同的...