选择路径,使用本脚本,可以连接到新的路径。

选项:路径拐点尺寸、手柄尺寸、手柄描边、填充、描边

// 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 shapeLayer = thisComp.layers.addShape();
shapeLayer.name = props[0].name + " - Path";

var PointSize = shapeLayer.effect.addProperty('ADBE Slider Control');
PointSize.name = "Point Size";
PointSize.property(1).setValue(26);
var HandleSize = shapeLayer.effect.addProperty('ADBE Slider Control');
HandleSize.name = "Handle Size";
HandleSize.property(1).setValue(22);
var Stroke = shapeLayer.effect.addProperty('ADBE Slider Control');
Stroke.name = "Stroke";
Stroke.property(1).setValue(6);
var StrokeColor = shapeLayer.effect.addProperty('ADBE Color Control');
StrokeColor.name = "Stroke - Color";
StrokeColor.property(1).setValue([255,255,255]);
var FillColor = shapeLayer.effect.addProperty('ADBE Color Control');
FillColor.name = "Fill - Color";
FillColor.property(1).setValue([255,0,0]);



//************************************************add path********************************************************
var shapeGroup = shapeLayer('ADBE Root Vectors Group').addProperty('ADBE Vector Group');
shapeGroup.name = "Path";

var vertices = [[0,0]];
var inTangents = [];
var outTangents = [];

var pathShape = new Shape();
pathShape.vertices = vertices;
pathShape.inTangents = inTangents;
pathShape.outTangents = outTangents;

var pathGroup = shapeGroup.property('Contents').addProperty('ADBE Vector Shape - Group');
var pathStroke = shapeGroup.property('Contents').addProperty('ADBE Vector Graphic - Stroke');
pathStroke('ADBE Vector Stroke Color').expression = SCString;
pathStroke('ADBE Vector Stroke Width').expression = SWString;

function getPropPath(currentProp,pathHierarchy){
    var pathPath = "";
        while (currentProp.parentProperty !== null){

            if ((currentProp.parentProperty.propertyType === PropertyType.INDEXED_GROUP)) {
                pathHierarchy.unshift(currentProp.propertyIndex);
                pathPath = "(" + currentProp.propertyIndex + ")" + pathPath;
            } else {
                pathPath = "(\'" + currentProp.matchName.toString() + "\')" + pathPath;
            }

            // Traverse up the property tree
            currentProp = currentProp.parentProperty;
        }
    return pathPath
}

var pathHierarchy = [];
var pathPath = getPropPath(props[0], pathHierarchy);


shapeLayer.property('Contents').property("Path").content(1)('ADBE Vector Shape').expression ="thisComp.layer(\'" + userLayers[0].name + "\')" + pathPath + ".path;";


//************************************************add points********************************************************
var pointsGroup = shapeLayer('ADBE Root Vectors Group').addProperty('ADBE Vector Group');
pointsGroup.name = "Points";
var pointsGroup1 = pointsGroup.property('Contents').addProperty('ADBE Vector Group');
pointsGroup1.name = "P1";
var pathpoints = pointsGroup1.property('Contents').addProperty('ADBE Vector Shape - Rect');
pathpoints('ADBE Vector Rect Size').expression = PSString;
pathpoints('ADBE Vector Rect Position').expression = PPString;
pointsGroup1('ADBE Vector Transform Group')(1).expression = AnPosString;
pointsGroup1('ADBE Vector Transform Group')(2).expression = AnPosString;
pointsGroup1('ADBE Vector Transform Group')(6).expression = RotString;

for(var i = 0; i < pointNum-1; i++)
{
    aa = shapeLayer('ADBE Root Vectors Group').property("Points").content('ADBE Vector Group');
    var bb = aa.duplicate();
    bb.name = pointNum-1-i;
}
    shapeLayer('ADBE Root Vectors Group').property("Points").content('P1').name = pointNum;

var pointsfill = pointsGroup.property('Contents').addProperty('ADBE Vector Graphic - Fill');
pointsfill('ADBE Vector Fill Color').expression = SCString;


//************************************************add handle********************************************************

var handleGroup = shapeLayer('ADBE Root Vectors Group').addProperty('ADBE Vector Group');
handleGroup.name = "Handle";

//************************************************add inTangents******************************************
var TangentsGroup = handleGroup.property('Contents').addProperty('ADBE Vector Group');
TangentsGroup.name = "Tangents Points";
var inTGroup = TangentsGroup.property('Contents').addProperty('ADBE Vector Group');
inTGroup.name = "inTangents";
var inpoints = inTGroup.property('Contents').addProperty('ADBE Vector Shape - Ellipse');
inpoints.name = "in1";
inpoints('ADBE Vector Ellipse Size').expression = HSString;
inpoints('ADBE Vector Ellipse Position').expression = IPString;


for(var i = 0; i < pointNum-1; i++)
{
    aai = shapeLayer.content("Handle").content("Tangents Points").content("inTangents").content(1);
    var bbi = aai.duplicate();
    bbi.name = pointNum-i;
}
    shapeLayer.content("Handle").content("Tangents Points").content("inTangents").content(1).name = "1";


//************************************************add inTangents******************************************
var outTGroup = TangentsGroup.property('Contents').addProperty('ADBE Vector Group');
outTGroup.name = "outTangents";
var outpoints = outTGroup.property('Contents').addProperty('ADBE Vector Shape - Ellipse');
outpoints.name = "in1";
outpoints('ADBE Vector Ellipse Size').expression = HSString;
outpoints('ADBE Vector Ellipse Position').expression = OPString;


for(var i = 0; i < pointNum-1; i++)
{
    aai = shapeLayer.content("Handle").content("Tangents Points").content("outTangents").content(1);
    var bbi = aai.duplicate();
    bbi.name = pointNum-i;
}
    shapeLayer.content("Handle").content("Tangents Points").content("outTangents").content(1).name = "1";


//************************************************add TangentsFill******************************************
var intfill = TangentsGroup.property('Contents').addProperty('ADBE Vector Graphic - Fill');
intfill('ADBE Vector Fill Color').expression = SCString;


//************************************************add handle line*******************************************
var lineGroup = handleGroup.property('Contents').addProperty('ADBE Vector Group');
lineGroup.name = "line";
var handleline = lineGroup.property('Contents').addProperty('ADBE Vector Shape - Group');
handleline.name = "line1"
handleline('ADBE Vector Shape').expression = HLString;
var hlStroke = lineGroup.property('Contents').addProperty('ADBE Vector Graphic - Stroke');
hlStroke('ADBE Vector Stroke Color').expression = SCString;
hlStroke('ADBE Vector Stroke Width').expression = HLSString;

for(var i = 0; i < pointNum-1; i++)
{
    aai = shapeLayer.content("Handle").content("line").content(1);
    var bbi = aai.duplicate();
    bbi.name = pointNum-i;
}
    shapeLayer.content("Handle").content("line").content(1).name = "1";



//************************************************add path fill********************************************************
var fillGroup = shapeLayer('ADBE Root Vectors Group').addProperty('ADBE Vector Group');
fillGroup.name = "Fill";
var fillpath = fillGroup.property('Contents').addProperty('ADBE Vector Shape - Group');
var fillfill = fillGroup.property('Contents').addProperty('ADBE Vector Graphic - Fill');
fillfill('ADBE Vector Fill Color').expression = FCString;
shapeLayer.property('Contents').property("Fill").content(1)('ADBE Vector Shape').expression ="thisLayer.content(1).content(1)('ADBE Vector Shape');";


shapeLayer.property('Contents')(1).enabled = false;
shapeLayer.property('Contents')(1).enabled = true;

app.endUndoGroup();

您的电子邮箱地址不会被公开。 必填项已用*标注

请下载到本地观看!因为pdf是用的阿里云盘预览,可能部分字体加载不了。

请安装油猴脚本,并下载月离的万事屋脚本。详情请查看菜单 导航 - 用户指引

请在右上角三个点 - 下载管理 - 找到刚才的文件,选择允许下载。 或者换个浏览器