-
【脚本案例】表达式小助手
界面 使用 快速保存与读取存储的表达式内容。丢在Scripts\ScriptUI Panels内就有面板了 保存 选中一个带表达式的属性,单击保存即可保存到配置文件 删除 删除当前下拉列表的表达式 应用 把表达式应用到所选的所有属性上 弹窗 如果把配置文件的user_info中的alert后面改为true 。则保存表达式时会弹窗,否则不弹窗 源码 // 名称: 表达式小助手1.1 // 源码: https://www.yuelili.com/?p=17940 // 构建UI Panel 函数 var panelGlobal = this; var palette = (function () { // JSON的polyfill "object" != typeof JSON && (JSON = {}), function () { "use strict"; var rx_one = /^[\],:{}\s]*$/, rx_two = /\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, rx_three = /"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, rx_four = /(?:^|:|,)(?:\s*\[)+/g, rx_escapable = /[\\"\u0000-\u001f\u007f-\u009f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g, rx_dangerous = /[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g, gap, indent, meta, rep; function f(t) { return t < 10 ? "0" + t : t } function this_value() { return this.valueOf() } function quote(t) { return rx_escapable.lastIndex = 0, rx_escapable.test(t) ? '"' + t.replace(rx_escapable, function (t) { var e = meta[t]; return "string" == typeof e ? e : "\\u" + ("0000" + t.charCodeAt(0).toString(16)).slice(-4) }) + '"' : '"' + t + '"' } function str(t, e) { var r, n, o, u, f, a = gap, i = e[t]; switch (i && "object" == typeof i && "function" == typeof i.toJSON && (i = i.toJSON(t)), "function" == typeof rep && (i = rep.call(e, t, i)), typeof i) { case "string": return quote(i); case "number": return isFinite(i) ? String(i) : "null"; case "boolean": case "null": return String(i); case "object": if…- 0
- 3
- 2.5k
-
【AE脚本】自动全景变焦 PAN & ZOOM | 免费
来源 https://www.motionboutique.com 用法 执行脚本,然后在电脑上选择一个图像文件夹。还是可以研究下源码的 源码 // PanZoom.jsx // Copyright (c) 2011 Motion Boutique function createPanZoom(comp, layer) { var rulesOfThirdsPoints = [[1 / 3, 1 / 3], [2 / 3, 1 / 3], [1 / 3, 2 / 3], [2 / 3, 2 / 3]]; // points of interest in image var zoomModes = ["IN", "OUT"]; var rdIdx = Math.floor(Math.random() * rulesOfThirdsPoints.length); var f = rulesOfThirdsPoints[rdIdx]; var deltaZoomPoint = [f[0] * comp.width, f[1] * comp.height] - [comp.width / 2, comp.height / 2]; var rdIdx = Math.floor(Math.random() * zoomModes.length); var zoomMode = zoomModes[rdIdx]; var keyTimes = [panZoomStart, panZoomEnd]; var keyValues; switch (zoomMode) { case "IN": keyValues = [[100, 100], [150, 150]]; break; case "OUT": keyValues = [[150, 150], [100, 100]]; break; default: break; } var nullL = comp.layers.addNull(); layer.scale.expression = "sx = 100 * thisComp.width / width; \r" + "sy = 100 * thisComp.height / height; \r" + "s = Math.max(sx,sy); \r" + "[s,s];"; layer.parent = nullL; nullL.anchorPoint.setValue(nullL.anchorPoint.value + deltaZoomPoint); nullL.position.setValue(nullL.position.value + deltaZoomPoint); nullL.scale.setValuesAtTimes(keyTimes, keyValues); } function isInArray(array, element) { var found = false; for (var i = 0; !found && i < array.length; i++) { if (array[i] == element) found = true; } return found; } function isImageFile(fileName) { var ext…- 0
- 0
- 652
-
【AE脚本】怎么设置渲染输出的模板和路径?
var templateName = "png" //写入你自己建的模板的名字 var myRQ= app.project.renderQueue; var numItems=app.project.renderQueue.numItems; var DefaultFolderPath="/c/output/" //设置你渲染的路径 for(var i=1;i<=myRQ.numItems;i++){ app.project.renderQueue.item(i).outputModule(1).applyTemplate(templateName); var oldName=myRQ.item(i).outputModule(1).file.name; myRQ.item(i).outputModule(1).file=new File(DefaultFolderPath+"/"+oldName); }- 0
- 0
- 580
-
【AE脚本示例】如何从aep文件中提取其中的素材路径
function aepToPaths(aepFile){ var paths = [] aepFile.encoding = "BINARY"; aepFile.open ("r"); var content = aepFile.read(); aepFile.close(); content.replace(/\"fullpath\":\"([^"]*)\"/g,function(mstr,s1){ paths.push(File.decode(escape(s1))) return mstr }) return paths } var paths = aepToPaths(File("~/Desktop/abc.aep"))- 0
- 0
- 567
-
AE脚本管理器
{ // rd_ScriptLauncher.jsx // Copyright (c) 2005-2016 redefinery (Jeffrey R. Almasol). All rights reserved. // check it: www.redefinery.com // // Name: rd_ScriptLauncher // Version: 2.5 // // Description: // This script displays a palette of the installed scripts // in the selected Scripts folder (and subfolders). Only // scripts with .jsx, and .jsxbin extensions are // displayed. Double-click a script to launch it. Scripts // located in subfolders whose names are enclosed in // parentheses are ignored. You can change the // Scripts folder at any time, and refresh the scripts // list if the contents of the folder have changed. The // selected scripts folder is stored as a setting, so you // don't have to reselect it every time you reopen this palette. // // Note: The palette cannot detect any errors in the scripts // that you run from it. It's just a quick way of launching // scripts without restarting AE or using ExtendScript // Toolkit (i.e., switching away from AE). // // If a PNG file of a similar name and same folder as the // script file (but with a .png file name extension) exists, // it will appear next to the script name…- 0
- 0
- 546
-
【脚本相关】关于callSystem踩坑记录与解决方法探索
来看看 system.callSystem 在文档里的描述,这边只讨论CMD用法,下面梳理了几种情况,感兴趣可以继续往下看。欢迎指出遗落错误之处 需要注意:脚本传递中文给CMD会造成乱码,包括文件路径带有中文,这是AE(UTF8)与CMD(GBK)编码不同导致的。 我这边写了一个脚本字符串占位函数,这样就不用+"'来痛苦连接了 function str2cmd(str, list) { var cmd = str; for (i = 0, ii = list.length; i < ii; i++) { var tmp = '"' + list[i] + '"'; // var tmp = list[i]; cmd = cmd.toString().replace("${" + (i + 1) + "}", tmp); } return cmd; } var AutoHotkey = "AutoHotkeyU64.exe"; var autoSavePreset = "autoSavePreset.ahk"; var jsxPath = File($.fileName).parent.fsName; var ahkPath = jsxPath + "\\(pwcode)\\AutoHotkey\\"; var cmd = str2cmd('cmd /c start "" /d ${1} ${2} ${3}', [ahkPath, AutoHotkey, autoSavePreset]); 占位符格式是 ${Number} 其中Number是数字,从1开始,有几个参数就有几个数字,这样比较人性化。 str2cmd() 函数只有两个参数,第一个参数是字符串,第二个是一个数组,存放占位对象的字符串数据。其实函数功能就是占位对象的字符串内容替换掉${Number}而已,非常简单。 首先代码语句示范如下,其中用双引号括起来的字符串是命令行调用指令,那么具体该怎么写呢? var cmd = ""; system.callSystem(cmd); 我们不先急着写 cmd.exe /c 指令,而是试试用 echo 在控制台打印消息,因为echo本身是cmd的内置命令之一,算是测试这个函数是不是本身调用CMD然后运行传入的字符串,为此我们需要在语句后面添加 & pause 来暂停观察。 var cmd = "echo Hello jsx & pause"; 那么会发生什么呢?AE弹出报错(截图如下),我特意用手机手写乱码内容,然后找了一个在线恢复乱码网站,报错信息翻译过来是“系统找不到指定的文件”。 至于为啥会乱码,可能跟CMD本身的编码与AE编码不一致有关,CMD使用GBK,而AE使用UTF-8。 回归正题,我们可以肯定函数本身没有调用CMD,如果我们想要用CMD写指令,需要手动添加 cmd.exe /c 来运行指令。还有一部分参数目前用不到就不放了 cmd [/c | /k] [<string>] /c 执行字符串指令,结束后关闭命令窗口,大概是close缩写。 /k 执行字符串,结束后不关闭命令窗口,大概是keep缩写,一般情况用不到这个指令。 <string>是字符串指令,可以发现我们用system.callSystem()函数传入的内容其实就是字符串,等于字符串里面还有一个字符串。 因为字符串指令需要用双引号括起来,可以简写成外面的字符串用单引号,避免冲突。如果想全部用双引号,需要在双引号前面添加 \ 转义一下,比如 \" 。另外文件路径的\也需要转义成\。 var cmd = 'cmd.exe /c "echo Hello jsx & pause"'; // 推荐这个 var cmd = "cmd.exe /c \"echo Hello jsx & pause\""; // 容易搞混 那么如果<string>里面还有字符串呢?为了方便观察我们先把双引号改成[[" "]],如下: system.callSystem([[" cmd /c [[" [["C:\\Program Files\\~\\xxx.exe"]] [["D:\\my docs\\new title.txt"> "]] "]]) 可以看的出来,CMD的双引号只要成双成对就可以无限嵌套。 需要注意这些特殊字符需要用双引号括起来:圆括号() 中括号[] 花括号{} 空格 不知道叫啥^ 等号= 分号; 感叹号! 单引号' 加号+ 逗号, 反单引号` 波浪号~ 连接符& 。 因为这些特殊字符在CMD里有特殊含义,会被当成运算符等指令运行的,因此需要用双引号引用起来变成普通字符串。下面简单说一下常见的特殊字符功能: & …- 0
- 0
- 411
-
【脚本案例】提醒保存小助手V1.1
名称:提醒保存小助手 功能:单击开启提醒,shift单击关闭提醒(如果没开启,按住shift则会开启提醒) 1分钟检测一次,如果已保存,则计时器归零。因此,提醒保存时长必须超过1分钟 注意: 只是提醒你保存, 并不会自动保存! 这样可以防止工程过大产生的卡死 脚本可以直接丢UI panel文件夹里 使用条件 已测版本:AE2020 更新 V1.1: 原版本有点逻辑问题,写2分钟,实际会3分钟提醒 知识点 app.scheduleTask:定时函数的应用 源码 /** * 名称:提醒保存小助手 * 功能:单击开启提醒,shift单击关闭提醒(如果没开启,按住shift则会开启提醒) * V1.1: 原版本有点逻辑问题,写2分钟,实际会3分钟提醒 * V1.0 * 源码:https://www.yuelili.com/?p=18056 */ var n = 1 // 初始化计时器 var t = 10// 默认多少分钟弹出保存 var id = 0 timerIt = function () { // 判断当前项目是否保存,保存则计时器归零 if (!app.project.dirty) { n = 0 } if (n == t) { n = 0 // 计时器归零 alert("记得ctrl s保存工程哟") //弹出保存对话框 } n = n + 1 } var panelGlobal = this; var main = (function () { // MAIN // ==== var main = (panelGlobal instanceof Panel) ? panelGlobal : new Window("palette"); if (!(panelGlobal instanceof Panel)) main.text = "提醒保存小助手"; main.orientation = "row"; main.alignChildren = ["center", "top"]; main.spacing = 10; main.margins = 16; var edittext1 = main.add('edittext {properties: {name: "edittext1"'); edittext1.text = "10"; var alert_btn = main.add("button", undefined, undefined, { name: "alert_btn" }); alert_btn.text = "计时"; alert_btn.helpTip = "单击开启,按住shift单击关闭"; alert_btn.preferredSize.width = 50; alert_btn.onClick = start function start() { t = parseInt(edittext1.text) var shiftHeld = ScriptUI.environment.keyboardState.shiftKey; if (shiftHeld && id) { alert("已关闭提醒") app.cancelTask(id) } else { alert("已打开提醒小助手:" + edittext1.text + "分钟提醒一次哦") id = app.scheduleTask("timerIt()", 60000, true) // 60秒 也就是1分钟检测一次 } } main.layout.layout(true); main.layout.resize(); main.onResizing = main.onResize = function () {…- 0
- 0
- 401
-
【AE脚本】怎么用AE脚本给文件重命名?
答:@草哥 获取文件夹,获取此文件的里面的文件,for循环一个个改名。 var newFolder=Folder('/D/MediaTools/output/'); var allFiles=newFolder.getFiles (); for(var i=0;i<allFiles.length;i++) { allFiles[i].rename(allFiles[i].displayName.split('_')[0]+'.jpg'); }- 0
- 0
- 391
-
【脚本案例】自定义导入序列
需求 遍历目标文件夹,将制定文件夹内的序列文件导入AE,并且预合成,放入当前选择文件夹下的01_cel文件夹与_footage内 知识点 遍历本地文件夹并判断、遍历项目面板文件夹、AE项目文件夹的父子关系、导入设置、创建合成等相关知识。 UI的话 在线构建就行:https://scriptui.joonas.me/ 如何使用 新建:创建“导入序列.txt”并打开,复制源码,粘贴入该txt。 重命名:把“导入序列.txt”改为“导入序列.jsx” 放置:丢在AE根目录下的 Scripts\ScriptUI Panels内即可 其他:其他自定义内容,请看 源码 - “用户自定义”区 难点 由于openDlg获取文件夹对话框太难用了,这里使用saveDlg,然后重新New 一个Folder对象 源码 // Author:Yueli // 源码:https://www.yuelili.com/?p=17943 // Vision: 1.2 var panelGlobal = this; var palette = (function () { // UI 界面 var palette = (panelGlobal instanceof Panel) ? panelGlobal : new Window("palette"); if (!(panelGlobal instanceof Panel)) palette.text = "导入序列"; palette.orientation = "column"; palette.alignChildren = ["center", "top"]; palette.spacing = 10; palette.margins = 16; var seq_import = palette.add("button", undefined, undefined, { name: "seq_import" }); seq_import.text = "导入"; seq_import.onClick = import_seq // 主函数区 function import_seq() { // 用户自定义区 // 1.导入文件夹名称 var name_list = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q"] var footage_list = ["png", "tga"] // 2.初始加载文件夹(就是对话框文件夹)默认为根目录 你可以把 ~ 改成诸如 "F:\\work\\AE project" var folderObj = new Folder('') // 3.是否弹窗:true则错误操作弹窗 false则不弹窗 var user_alert = false // 判断项目面板选择的文件夹 var proj = app.project; var trg_folder var footage_folder var cel_folder var comp_stage for (var i = 1; i <= proj.numItems; i++) { var itm = proj.item(i) if (itm.selected) { trg_folder = itm } } // 文件夹遍历加判断 function folder_recursive(folderGroup) { for (var i = 1; i <= folderGroup.numItems; i++) { var items = folderGroup.item(i); // 判断当前属性是否为文件夹,如果是,则继续遍历 if (items instanceof…- 0
- 2
- 385
-
【AE脚本】QTMD混合模式
源码 一键生成当前图层的16种混合模式,并且保存到本地桌面,不用瞎几把试了 var BLEND = [{ "name": "Normal", "name_zh": "正常", "cmd": BlendingMode.NORMAL }, { "name": "Dissolve", "name_zh": "溶解", "cmd": BlendingMode.DISSOLVE }, { "name": "Dancing Dissolve", "name_zh": "动态抖动溶解", "cmd": BlendingMode.DANCING_DISSOLVE }, { "name": "Darken", "name_zh": "变暗", "cmd": BlendingMode.DARKEN }, { "name": "Multiply", "name_zh": "相乘", "cmd": BlendingMode.MULTIPLY }, { "name": "Color burn", "name_zh": "颜色加深", "cmd": BlendingMode.COLOR_BURN }, { "name": "Classic Color Burn", "name_zh": "经典颜色加深", "cmd": BlendingMode.CLASSIC_COLOR_BURN }, { "name": "Linear Burn", "name_zh": "线性加深", "cmd": BlendingMode.LINEAR_BURN }, { "name": "Darker Color", "name_zh": "较深的颜色", "cmd": BlendingMode.DARKER_COLOR }, { "name": "Add", "name_zh": "相加", "cmd": BlendingMode.ADD }, { "name": "Lighten", "name_zh": "变亮", "cmd": BlendingMode.LIGHTEN }, { "name": "Screen", "name_zh": "屏幕", "cmd": BlendingMode.SCREEN }, { "name": "Color Dodge", "name_zh": "颜色减淡", "cmd": BlendingMode.COLOR_DODGE }, { "name": "Classic Color Dodge", "name_zh": "经典颜色减淡", "cmd": BlendingMode.CLASSIC_COLOR_DODGE }, { "name": "Linear Dodge", "name_zh": "线性减淡", "cmd": BlendingMode.LINEAR_DODGE }, { "name": "Lighter Color", "name_zh": "较浅的颜色", "cmd": BlendingMode.LIGHTER_COLOR }, { "name": "Overlay", "name_zh": "叠加", "cmd": BlendingMode.OVERLAY }, { "name": "Soft Light", "name_zh": "柔光", "cmd": BlendingMode.SILHOUETTE_LUMA }, { "name": "Hard Light", "name_zh": "强光", "cmd": BlendingMode.HARD_LIGHT }, { "name": "Linear Light", "name_zh": "线性光", "cmd": BlendingMode.LINEAR_LIGHT }, { "name": "Vivid Light", "name_zh": "亮光", "cmd": BlendingMode.VIVID_LIGHT }, { "name": "Pin Light", "name_zh": "点光", "cmd": BlendingMode.PIN_LIGHT }, { "name": "Hard…- 0
- 0
- 378
-
【脚本相关】使用脚本来半自动化保存预设
受限于AE提供的功能限制,目前后半部分只能由用户来手动操作,下面是具体代码: 我们可以用selected来判断某插件是否被用户选中,另外保存预设时需要在效果控件选中插件(可多选),如果不选中插件模拟点击时就不会有反应。 var comp = app.project.activeItem; // 获取合成 var layer = comp.selectedLayers; // 获取选中图层 var effect = layer[0].property("ADBE Effect Parade"); // 获取图层的效果列表 var num = effect.numProperties; // 获取效果列表的数量 var plug = effect.property(1); // 序号可以用for遍历,或者用name、matchName查找 // 用名称或者元属性名的时候,如果没找到返回null var isSeleEffect = plug.selected; //检测是否在效果控件选中插件 var presetPath = "c:\\temp.ffx"; // 声明一个ffx文件的保存全路径 copyToClipboard(presetPath); // 把内容推送到系统的剪贴板 // https://www.yuelili.com/ae-script-case-transferring-information-to-the-system-clipboard/ app.executeCommand(3075); // 模拟点击 菜单栏的保存预设功能 跳转copyToClipboard 可以看到本文重点是这个 app.executeCommand(3075); 接下来会弹出一个保存预设的文件窗口,因为之前我把文件路径内容拷贝到剪贴板,这时候只需Ctrl+V粘贴出来然后保存即可。 初次保存预设,会有一个提示弹窗,下面可以设置成永久不提示。- 0
- 0
- 343
-
【脚本案例】素材本地文件重命名
介绍 在项目面板选择一个素材文件,输入替换内容,即可一键重命名,并且重新读取该文件。 源码 /** * 功能:在项目面板选择一个素材文件,输入替换内容,即可一键重命名,并且重新读取该文件 * 源码:https://www.yuelili.com/?p=17988 */ var panelGlobal = this; var palette = (function () { // UI 界面 可以不管 var palette = (panelGlobal instanceof Panel) ? panelGlobal : new Window("palette"); if (!(panelGlobal instanceof Panel)) palette.text = "素材重命名"; palette.orientation = "row"; palette.alignChildren = ["center", "top"]; palette.spacing = 10; palette.margins = 16; var save_name = palette.add('edittext {properties: {name: "save_name"'); save_name.text = "77"; save_name.helpTip = "输入新名称"; save_name.preferredSize.width = 100; var rename = palette.add("button", undefined, undefined, { name: "rename" }); rename.helpTip = "选择一个素材,然后单击"; rename.text = "重命名"; rename.preferredSize.width = 50; rename.onClick = rename_it function rename_it() { // 当前项目选择的文件 var selItem = app.project.selection[0] // 判断文件是否有本地文件 if (selItem.mainSource instanceof FileSource) { // 获取素材本地文件对象 var source_File = File(selItem.file.path + "/" + selItem.name) // 获取文件后缀 inx = selItem.name.lastIndexOf(".") endfix = selItem.name.substr(inx, 9) // 判断输入内容是否为空 if (save_name.text.length == 0) { alert("重命名后的名称不能为空") } else { // 本地文件重命名 source_File.rename(save_name.text + endfix) // 替换本地文件 selItem.replace(source_File) } } else { alert("当前文件无本地文件源") } } palette.layout.layout(true); palette.layout.resize(); palette.onResizing = palette.onResize = function () { this.layout.resize(); } if (palette instanceof Window) palette.show(); return palette; }());- 0
- 1
- 326
-
【脚本案例】批量另存工程
介绍 * 在项目面板选择一个合成,比如:主合成 * 设置好起始数字与结束数字 * 则会另存一堆工程,并且工程当前选择的合成也会自动改名 * 主合成 001.aep 对应的主合成名称也会变成 主合成 001 其他 你可以在代码86行,命名规则更改 源码 * 名称:批量另存工程 * 介绍: * 在项目面板选择一个合成,比如:主合成 * 设置好起始数字与结束数字 * 则会另存一堆工程,并且工程当前选择的合成也会自动改名 * 主合成 001.aep 对应的主合成名称也会变成 主合成 001 * https://www.yuelili.com/?p=18020 */ var panelGlobal = this; var main = (function () { /* Code for Import https://scriptui.joonas.me — (Triple click to select): {"activeId":4,"items":{"item-0":{"id":0,"type":"Dialog","parentId":false,"style":{"enabled":true,"varName":"main","windowType":"Palette","creationProps":{"su1PanelCoordinates":false,"maximizeButton":false,"minimizeButton":false,"independent":false,"closeButton":true,"borderless":false,"resizeable":false},"text":"批量另存合成并改名","preferredSize":[0,0],"margins":16,"orientation":"column","spacing":10,"alignChildren":["center","top"],"item-1":{"id":1,"type":"Button","parentId":0,"style":{"enabled":true,"varName":"copy_btn","text":"一键另存","justify":"center","preferredSize":[0,0],"alignment":null,"helpTip":null,"item-2":{"id":2,"type":"EditText","parentId":3,"style":{"enabled":true,"varName":"start_num","creationProps":{"noecho":false,"readonly":false,"multiline":false,"scrollable":false,"borderless":false,"enterKeySignalsOnChange":false},"softWrap":true,"text":"1","justify":"left","preferredSize":[35,0],"alignment":null,"helpTip":null,"item-3":{"id":3,"type":"Group","parentId":0,"style":{"enabled":true,"varName":null,"preferredSize":[0,0],"margins":0,"orientation":"row","spacing":10,"alignChildren":["left","center"],"alignment":null,"item-4":{"id":4,"type":"EditText","parentId":3,"style":{"enabled":true,"varName":"end_num","creationProps":{"noecho":false,"readonly":false,"multiline":false,"scrollable":false,"borderless":false,"enterKeySignalsOnChange":false},"softWrap":true,"text":"5","justify":"left","preferredSize":[35,0],"alignment":null,"helpTip":null,"item-5":{"id":5,"type":"StaticText","parentId":3,"style":{"enabled":true,"varName":"static01","creationProps":{"truncate":"none","multiline":false,"scrolling":false},"softWrap":false,"text":"起始","justify":"left","preferredSize":[0,0],"alignment":"center","helpTip":null,"item-7":{"id":7,"type":"StaticText","parentId":3,"style":{"enabled":true,"varName":null,"creationProps":{"truncate":"none","multiline":false,"scrolling":false},"softWrap":false,"text":"结束","justify":"left","preferredSize":[0,0],"alignment":null,"helpTip":null},"order":[0,3,5,2,7,4,1],"settings":{"importJSON":true,"indentSize":false,"cepExport":false,"includeCSSJS":true,"showDialog":true,"functionWrapper":true,"afterEffectsDockable":true,"itemReferenceList":"None" */ // MAIN // ==== var main = (panelGlobal instanceof Panel) ? panelGlobal : new Window("palette"); if ( !(panelGlobal instanceof Panel) ) main.text = "批量另存合成并改名"; main.orientation = "column"; main.alignChildren = ["center","top"]; main.spacing = 10; main.margins = 16; // GROUP1 // ====== var group1 = main.add("group", undefined, {name: "group1"}); group1.orientation = "row"; group1.alignChildren = ["left","center"]; group1.spacing = 10; group1.margins = 0; var static01 = group1.add("group"); static01.orientation = "column"; static01.alignChildren = ["left","center"]; static01.margins = [0,0,0,25]; static01.alignment = ["left","center"]; static01.add("statictext", undefined, "", {name: "static01"}); static01.add("statictext", undefined, "起始", {name: "static01"}); var start_num = group1.add('edittext {properties: {name: "start_num"'); start_num.text = "1"; start_num.preferredSize.width = 35; var statictext1 = group1.add("group"); statictext1.orientation = "column"; statictext1.alignChildren = ["left","center"]; statictext1.spacing = 0; statictext1.margins = [0,0,0,15]; statictext1.add("statictext", undefined, "", {name: "statictext1"}); statictext1.add("statictext", undefined, "结束", {name: "statictext1"}); var end_num = group1.add('edittext {properties: {name: "end_num"'); end_num.text = "5"; end_num.preferredSize.width = 35; // MAIN // ==== var copy_btn = main.add("button", undefined, undefined, {name: "copy_btn"}); copy_btn.text =…- 0
- 0
- 288
-
【脚本案例】Adobe 颜色板(圆)
源码 ; (function () { /* * ColorPicker v2.0 for Adobe scripting. * 2016-5-11 -> 2016-7-24 * * By: smallpath * Email: smallpath2013@gmail.com * Github: https://github.com/smallpath/adobe-color-picker * 源码:https://www.yuelili.com/?p=18072 * * This is a rebuilt color picker for Adobe scripting. * Support all Adobe softwares such as PS,AI,PR and so on. * * See usage on github.com/Smallpath/AdobeColorPicker */ function colorPicker(inputColour, options) { if (!(this instanceof colorPicker)) return new colorPicker(inputColour, options) this.options = { name: "Adobe Color Picker ", version: "v2.0", shouldUpdateCursor: false, backupLocation: [], windowType: "dialog", // "dialog","palette" and the reference of Panel } if (options && colorPicker.isType(options, "Object")) { for (var i in options) this.options[i] = options[i]; } this.inputColour = colorPicker.parseColor(inputColour); this.outputColour = this.inputColour.slice(0); this.initSetting(); return this.showColorPicker(); } colorPicker.parseColor = function (inputValue) { if (!inputValue) return [1, 1, 1]; if (colorPicker.isRgb(inputValue)) //[0,0,0] - [1,1,1] return colorPicker.parseRgb(inputValue); else if (colorPicker.isLargeRgb(inputValue)) //[0,0,0] - [255,255,255] return colorPicker.parseLargeRgb(inputValue); else if (colorPicker.isHex(inputValue)) //FFFFFF return colorPicker.parseHex(inputValue); else if (colorPicker.isShortHex(inputValue)) //FFF return colorPicker.parseShortHex(inputValue); else if (colorPicker.isHsb(inputValue)) //[0,0,0,'hsb'] - [360,100,100,'hsb'] return colorPicker.parseHsb(inputValue); else return [1, 1, 1]; } colorPicker.prototype.showColorPicker = function () { var win = this.initWindow(); if (win.type == "dialog" || win.type == "palette") { if (this.haveSetting("location")) { win.location = this.getSetting("location").split(","); if (win.location.length != 2) win.center(); else…- 0
- 0
- 276
-
【AE脚本】怎么把图片变成代码写入脚本?
var path='/c/test/'; var f= File(path+"1.png" ); f.encoding='BINARY'; f.open('e'); var binary; binary =f.read().toSource(); var myFile=new File ("/c/test/1.txt"); myFile.open("w"); myFile.encoding = "UTF-8"; myFile.write(binary); myFile.close(); $.writeln(binary); f.close();- 0
- 0
- 266
-
【脚本问答】获取文件夹路径,比如说工程的文件夹,渲染输出的文件夹?
//获取项目工程的路径 app.project.file.fsName //设置渲染的路径 var Path = "/c/output/" var myRQ = proj.renderQueue; myRQ.item(i).outputModule(1).file=new File(Path); //获取渲染路径 myRQ.item(i).outputModule(1).file.fsName;- 0
- 0
- 243
-
【AE脚本】案例:把信息传递到系统剪贴板
介绍 提供一个函数,可以把内容反馈到Windows 或者 Mac 剪切板 知识点 判断是windows 还是 mac cmd命令的调用 源码 方法1(不能带\n) // 名称:复制信息到系统剪切板 // 作者: Adobe 社区 // 源码:https://www.yuelili.com/?p=10424 // from Adobe 社区 function copyToClipboard(string) { var cmd, isWindows; // 判断是不是字符串 string = (typeof string === 'string') ? string : string.toString(); isWindows = $.os.indexOf('Windows') !== -1; //OS的命令 cmd = 'echo "' + string + '" | pbcopy'; //windows的cmd命令 if (isWindows) { cmd = 'cmd.exe /c start /min /b cmd.exe /c "echo ' + string + ' | clip"'; //cmd = 'cmd.exe /c cmd.exe /c "echo ' + string + ' | clip"'; } system.callSystem(cmd); } // 比如 把AE版本名复制到粘贴板 copyToClipboard(app.buildName) 方法2(不能带\n) // 使用fs验证 function copyToClipboard(text) { text = "hello world" if (Folder.fs === "Windows") { var cmdCommand = 'cmd.exe /c cmd.exe /c "echo ' + text + ' | clip"'; system.callSystem(cmdCommand); } else if (Folder.fs === "Macintosh") { // macOS var osaCommand = 'echo "' + text + '" | pbcopy'; system.callSystem("osascript -e '" + osaCommand + "'"); } else { alert("Unsupported operating system."); } } 方法3(能带\n) function copyToClipboard(text) { // 创建临时文本文件 var tempFile = new File(Folder.temp.fullName + "/temp.txt"); tempFile.open("w"); tempFile.write(text); tempFile.close(); if (Folder.fs === "Windows") { var cmdCommand = 'cmd.exe /c cmd.exe /c "type ' + tempFile.fsName + '…- 0
- 5
- 242
-
【脚本案例】渲染指定图层 rd_Render Layers
介绍 基本上渲染参数都玩明白了,拆一下,大有裨益 源码 // rd_RenderLayers.jsx // Copyright (c) 2006-2013 redefinery (Jeffrey R. Almasol). All rights reserved. // check it: www.redefinery.com // // Name: rd_RenderLayers // Version: 3.1 // // Description: // This script renders each of the selected layers separately. You might // find this script useful if layers represent different versions of an // effect or different parts of an effect that you want to render as // separate "passes" for flexibility in how they get composited. // // Rendering uses existing render settings and output module template, so // be sure to create them beforehand. When you run this script, you can // select the templates to use; select the range of frames for each selected // layer to render; control if unselected, adjustment, active camera, and // light layers should be rendered as well; and define the name for each // rendered output. Each rendered layer will generate separate "render // finished" sounds. // // The Output Name Template can be defined with the same properties // available in the File Name Templates dialog box, with the following // additions: // [layerName] - Current layer's name // [layerNumber] - Current layer's index number // // Note: If…- 0
- 0
- 235
-
【AE脚本】打开当前工程文件夹
// @source:https://github.com/ff6347/after-effects-script-snippets/blob/master/open-project-folder.jsx (function(thisObj) { if (app.project.file !=null){ app.project.file.parent.execute();// 打开 }else{ alert('这个工程尚未保存过'); } }(this));- 0
- 0
- 223
-
【AE脚本】设置所有渲染队列的输出文件夹
/** * Set the output file for all outputmodules for all items in the renderque * https://github.com/ff6347/after-effects-script-snippets/blob/master/set-om-location.jsx * @return {[type]} [description] */ var main = function() { var p = app.project; var rq = p.renderQueue; //定义渲染队列 var targetFolder = Folder.selectDialog('选择输出文件夹'); //定义输入文件夹 if (targetFolder === null) { return; } //遍历 app.beginUndoGroup('Set OM output location'); for (var i = 1; i- 0
- 0
- 210
-
【AE脚本】如何用脚本打开一个网页
// 源码: https://www.yuelili.com/?p=13025 function urlOpen(url){ $.writeln(system.osName); if ( $.os.indexOf("Windows") != -1 ) { //Windows系统 system.callSystem("cmd.exe /c\"start "+url+"\"" ); }else{ //MAC系统 system.callSystem("open http://"+url+ "\""); } } //调用 urlOpen('https://baidu.com')- 0
- 0
- 188
-
【AE脚本】怎么获取系统时间?
function getTime(){ var myDate = new Date(); var thisYear=myDate.getFullYear() ;//获取当前年份(2位) var thisMonth=myDate.getMonth(); var thisDate=myDate.getDate(); //获取当前日(1-31) var thisHours=myDate.getHours(); //获取当前小时数(0-23) var thisMinutes=myDate.getMinutes(); //获取当前分钟数(0-59) var thisSeconds=myDate.getSeconds(); //获取当前秒数(0-59) var thisTime=thisYear+"/"+(parseInt(thisMonth)+1)+"/"+thisDate+"/"+thisHours+":"+thisMinutes;//+":"+thisSeconds; return thisTime; }- 0
- 0
- 164