-
[AE脚本开发]合并多条路径为一条
使用方法 选择要合并的路径, 运行脚本即可 脚本源码 'use strict'; var comp = app.project.activeItem; if (comp && comp instanceof CompItem) { var selectedShapes = comp.selectedProperties; var extend = function extend(array1, array2) { var newArray = []; for (var index = 0; index < array1.length; index++) { newArray.push(array1[index]); } for (var index = 0; index < array2.length; index++) { newArray.push(array2[index]); } return newArray; }; var selectedShapes = comp.selectedProperties; var propertyArrays = { featherInterps: [], featherRadii: [], featherRelCornerAngles: [], featherRelSegLocs: [], featherSegLocs: [], featherTensions: [], featherTypes: [], inTangents: [], outTangents: [], vertices: [], closed: false, }; for (var i = 0; i < selectedShapes.length; i++) { var prop = selectedShapes[i]; if (prop.matchName === 'ADBE Vector Shape') { var propV = prop.value; for (var key in propertyArrays) { if (key == 'closed') { propertyArrays[key] = propV[key]; continue; } if (propertyArrays.hasOwnProperty(key)) { propertyArrays[key] = extend(propertyArrays[key], propV[key]); } } } } var myShape = new Shape(); for (var key in propertyArrays) { if (propertyArrays.hasOwnProperty(key) && (propertyArrays[key].length > 0 || key == 'closed')) { myShape[key] = propertyArrays[key]; } } var newShapeLayer = comp.layers.addShape(); newShapeLayer.name = 'Merged Shapes'; var shapeGroup = newShapeLayer.property('ADBE Root Vectors Group'); var pGroup = shapeGroup.addProperty('ADBE Vector Shape - Group'); pGroup.property('ADBE Vector Shape').setValue(myShape); } else { alert('请在合成中选择路径!'); }…- 0
- 0
- 174
-
【脚本案例】rd_Slicer 图层切割为矩阵
介绍 源码 // AES:https://aescripts.com/rd-slicer/ // 中文:https://www.yuelili.com/?p=18046 // rd_Slicer.jsx // Copyright (c) 2006-2013 redefinery (Jeffrey R. Almasol). All rights reserved. // check it: www.redefinery.com // // Name: rd_Slicer // Version: 3.0 // // Description: // This script displays a palette with controls for slicing the selected layer // into a grid. Slicing works best with non-rotated layers. If a parent null // layer is created, it will be anchored at the layer's current anchor point. // // You can shrink each slice's mask by increasing the Margin value (in pixels), // and rounding its corners by increasing the Roundness value (percentage of // half the shorter of the layer's width or height). // // Note: This version of the script requires After Effects CS5 // or later. It can be used as a dockable panel by placing the // script in a ScriptUI Panels subfolder of the Scripts folder, // and then choosing this script from the Window menu. // // Originally requested by Anthony Lassiter and Chris Meyer. // Enhancements requested by Matt Silverman. // // Legal stuff: // This script is provided "as is," without warranty of any kind, expressed // or implied. In no event shall the author…- 0
- 0
- 243
-
【AE脚本】路径反向 | JimWho | 开源
https://www.bilibili.com/video/BV12q4y1P77w/ AE脚本 - 路径反向 ReversePath 没有UI直接使用 ReversePath-UI 在Kbar打开是不带UI的,其他情况是有个按钮界面 支持选中关键帧反向,不选中是全部反向 //author: Charles Bordenave (www.nabscripts.com)(https://aescripts.com/reversemaskpath/) //modified by JimWho (https://space.bilibili.com/3345602) (function(thisobj) { function main(){ var thisComp = app.project.activeItem; var props = thisComp.selectedProperties; if (props.length < 1) { alert("Please select at least one Path !") } app.beginUndoGroup("Reverse Shape"); for (var i = 0; i < props.length; i++){ var isShapePath = matchMatchName(props[i],"ADBE Vector Shape - Group"); var isMaskPath = props[i].isMask; if (isShapePath || isMaskPath) { if (props[i].isMask){ var selpath = props[i].maskPath; }else{ var selpath = props[i].path; } if (selpath.numKeys == 0){ var myshape = selpath.value; selpath.setValue(ReverseShape(myshape)); }else{ var keyTimes = new Array(); var shapes = new Array(); if (selpath.selectedKeys.length == 0){ for (var k = 1; k <= selpath.numKeys; k++) { var keyTime = selpath.keyTime(k); var shape = selpath.valueAtTime(keyTime, false); keyTimes.push(keyTime); shapes.push(ReverseShape(shape)); } selpath.setValuesAtTimes(keyTimes, shapes); }else{ for (var k = 1; k <= selpath.numKeys; k++) { if (selpath.keySelected(k)) { var keyTime = selpath.keyTime(k); var shape = selpath.valueAtTime(keyTime, false); keyTimes.push(keyTime); shapes.push(ReverseShape(shape)); } } selpath.setValuesAtTimes(keyTimes, shapes); } //no keys selected, change only first key //var shape = selpath.keyValue(1); //selpath.setValueAtKey(1, ReverseShape(shape)); } app.endUndoGroup(); } function matchMatchName(targetEffect, matchNameString) { if (targetEffect != null && targetEffect.matchName === matchNameString) { return targetEffect } else { return null } } function…- 0
- 0
- 391
-
【脚本示例】给选定形状图层添加修建路径
/** * souce:https://github.com/zlovatt/zl_Scriptlets * Adds Trim Paths to selected shape layers, including a keyframe to start and one to end the animation. * 给选定形状图层添加修建路径,并创建2个关键帧 * 按住shift键运行,则不添加添加关键帧. * * @author Zack Lovatt <zack@zacklovatt.com> * @version 1.3.1 */ (function addTrimPaths() { var addKeys = !ScriptUI.environment.keyboardState.shiftKey; var comp = app.project.activeItem; if (!(comp && comp instanceof CompItem)) { alert("请先选择合成"); return; } var layers = comp.selectedLayers; if (layers.length === 0) { alert("请先选择形状图层"); return; } app.beginUndoGroup("Add Trim Paths"); for (var ii = 0, il = layers.length; ii < il; ii++) { var layer = layers[ii]; if (layer.matchName !== "ADBE Vector Layer") { continue; } var contents = layer.property("ADBE Root Vectors Group"); if (!contents.canAddProperty("ADBE Vector Filter - Trim")) { continue; } var trimProp = contents.addProperty("ADBE Vector Filter - Trim"); if (!addKeys) { continue; } var trimEnd = trimProp.property("ADBE Vector Trim End"); var trimTimes = [layer.inPoint, layer.inPoint + 1]; var trimValues = [0, 100]; trimEnd.setValuesAtTimes(trimTimes, trimValues); } app.endUndoGroup(); })();- 0
- 0
- 128
-
【AE脚本】批量分离mask或者更改mask模式
// by 熊喵 app.beginUndoGroup(mask操作) var p = app.project.activeItem.selectedProperties; var l = app.project.activeItem.selectedLayers; if(p.length|l.length){ if(p.length&&p[0].isMask){ //如果选中了mask,则批量将mask模式改为无 for(var i=0; i<p.length; i++){ p[i].maskMode = MaskMode.NONE } }else{ //如果没有选中mask,则分离所有选中图层的mask for(var i=l.length-1; i>=0; i--){ //处理所有选中的图层,因为会删除选中的层,所以反向遍历 go(l[i]) } } }else{ alert(请先选中图层或mask!,提示:) } app.endUndoGroup() function go(layer){ if(layer.mask.numProperties>1){ //mask数量至少大于1才做处理 for(var i=1; i<=layer.mask.numProperties; i++){ deleteMask(layer.duplicate(),i) //处理复制后的图层 } layer.remove(); } } function deleteMask(layer,index){ for(var i=layer.mask.numProperties; i>0; i--){ //遍历mask然后删除,因为会删除mask,所以反向遍历 if(i != index){ //排除指定的mask layer.mask(i).remove() } } }- 0
- 0
- 194
-
【AE脚本】手柄控制升级版 Create Nulls From Paths
Create Nulls From Paths EXTENDED在 AE 2018 中,Adobe 引入了使用表达式控制路径的可能性,与该版本一起出现的是由 Adobe 创建的 Create Nulls From Paths。 这是对 After Effects 的路径功能一个很好的补充,但缺少一些功能。这和Create Nulls From Paths师出同源,但它扩展了一些更多的功能。 除了对脚本的一些小改进外,添加的功能还有:从选定的创建路径、手柄控件、使用定位器,可以更精确控制路径,也可以方便制作贝塞尔曲线可视化。 该脚本适用于 AE 2018 及更高版本,由Thor Sarup添加了这些重大改进。 /* Create Nulls From Paths.jsx v.0.5 Attach nulls to shape and mask vertices, and vice-versa. Changes: - wraps it all in an IIFE - fixes call to missing method array.indexOf */ /* Extended version by crunchycph.dk - youtube.com/c/crunchycphdk Added features: - Add controls for bezier handles - Use locators instead of nulls - Create path from nulls - Uniform bezierepath - Auto soft / round corners - Close path - Save settings - Responsive interface Possibly upcoming features: - Parent nulls to shape layer - Remove controls from path - Option to create locator master style */ /* Modified by Thor Sarup - Ability to rotate / scale points (handles follow) - locked rotation and scaling of handles (only for indicators) - sets handles to shy - renamed script to Path tools to save precious panel space :) */ /* Update by crunchy 30. oct. 2017 - Fixed bug when both handle controls and use locators was selected for Create Path From Selected - Renamed the plugin back to it's original, since…- 0
- 0
- 815
-
【AE脚本库】Path to Path
选择路径,使用本脚本,可以连接到新的路径。 选项:路径拐点尺寸、手柄尺寸、手柄描边、填充、描边 // by 头号咸鱼 var thisComp = app.project.activeItem; var userLayers = thisComp.selectedLayers; var props = thisComp.selectedProperties; //var selpath = props[0].path; //var pointNum = selpath.value.vertices.length; function matchMatchName(targetEffect,matchNameString){ if (targetEffect != null && targetEffect.matchName === matchNameString) { return targetEffect } else { return null } } var isShapePath = matchMatchName(props[0],ADBE Vector Shape - Group); if(isShapePath != null){ var selpath = props[0].path; var pointNum = selpath.value.vertices.length; }else{ var selpath = props[0].maskPath; var pointNum = selpath.value.vertices.length; } var PSString = s = effect(\Point Size\)(1);\n[s,s]; var HSString = s = effect(\Handle Size\)(1);\n[s,s];; var SWString = effect(\Stroke\)(1);; var SCString = effect(\Stroke - Color\)(1);; var FCString = effect(\Fill - Color\)(1);; var FPSString = s = effect(\Point Size\)(1)*1.8;\n[s,s]; var AnPosString = p = thisProperty.propertyGroup(1).propertyGroup(1).content(1)(3).value; var RotString = l = thisLayer;\nlr = l.transform.rotation;\nwhile(1)\n{\nif(l.hasParent)\n{\nl = l.parent;\nlr = lr-l.transform.rotation;\n}\nelse\n{\nbreak;\n}\n}\nlr-thisLayer.transform.rotation*2;; var PPString = path = thisLayer.content(1).content(1)('ADBE Vector Shape');\npn = thisProperty.propertyGroup().propertyGroup().propertyGroup().propertyIndex-1;\npath.points()[pn];; var IPString = path = thisLayer.content(1).content(1)('ADBE Vector Shape');\npn = thisProperty.propertyGroup().propertyIndex-1;\np = path.points()[pn];\npi = path.inTangents()[pn];\np+pi;; var OPString = path = thisLayer.content(1).content(1)('ADBE Vector Shape');\npn = thisProperty.propertyGroup().propertyIndex-1;\np = path.points()[pn];\npo = path.outTangents()[pn];\np+po;; var HLString = path = thisLayer.content(1).content(1)('ADBE Vector Shape');\npn = thisProperty.propertyGroup().propertyIndex-1;\np = path.points()[pn];\npi = path.inTangents()[pn]+p;\npo = path.outTangents()[pn]+p;\ncreatePath(points = [pi,p,po], inTangents = [], outTangents = [], isClosed = false); var HLSString = effect(\Stroke\)(1)*0.5;; app.beginUndoGroup(Path-Path); var…- 0
- 0
- 381