[READ-ONLY] Mirror of https://github.com/probablykasper/2dcam. After Effects 2d camera
after-effects camera extendscript script
0

Configure Feed

Select the types of activity you want to include in your feed.

Insertion of shape layer works

Kasper (Mar 8, 2020, 1:41 AM +0100) 2bfc5dc8 c17262e3

+98
+98
cambox.jsx
··· 1 + var myPanel = (this instanceof Panel) ? this : new Window("palette", "Cambox", undefined, { resizeable: true }); 2 + 3 + res = "group{orientation:'row',\ 4 + groupTwo: Panel{orientation:'row',\ 5 + deleteCompButton: Button{text:'+'},\ 6 + deleteText: StaticText{text:'Add Cambox'},\ 7 + },\ 8 + }"; 9 + 10 + myPanel.grp = myPanel.add(res); 11 + 12 + // Defaults 13 + myPanel.grp.groupTwo.deleteCompButton.size = [25, 25]; 14 + 15 + // Add Cambox 16 + myPanel.grp.groupTwo.deleteCompButton.onClick = function () { 17 + if (app.project.activeItem == undefined || app.project.activeItem == null) { 18 + alert("Please select a comp to delete"); 19 + return false; 20 + } else { 21 + // delete comp 22 + currentComp = app.project.activeItem; 23 + 24 + // ask for name, width, height then apply preset. 25 + var camWidth = 1920; 26 + var camHeight = 1080; 27 + var strokeWidth = 20; // 50 * width or height, whichever is lowest 28 + 29 + // app.project.activeItem.remove(); 30 + var shapeLayer = app.project.activeItem.layers.addShape(); 31 + shapeLayer.name = 'Cambox'; 32 + shapeLayer.guideLayer = true; 33 + 34 + var contents = shapeLayer.property('ADBE Root Vectors Group'); 35 + 36 + // rectangle 37 + var rectangle = contents.addProperty("ADBE Vector Shape - Rect"); 38 + rectangle.name = 'Rectangle'; 39 + rectangle.property('ADBE Vector Rect Size').setValue([camWidth, camHeight]); 40 + rectangle.property('ADBE Vector Rect Size'); 41 + 42 + // stroke 43 + var stroke = contents.addProperty('ADBE Vector Graphic - Stroke'); 44 + stroke.name = 'Stroke'; 45 + stroke.property('ADBE Vector Stroke Width').setValue(strokeWidth); 46 + 47 + // offset stroke 48 + var offsetPaths = contents.addProperty('ADBE Vector Filter - Offset'); 49 + offsetPaths.name = 'Offset Paths'; 50 + offsetPaths.property('ADBE Vector Offset Amount').expression = '-content("Stroke").strokeWidth/2'; 51 + 52 + // invert effect 53 + var effects = shapeLayer.property('ADBE Effect Parade'); 54 + effects.addProperty('ADBE Invert'); 55 + 56 + // set to adjustment layer, for invert effect 57 + shapeLayer.adjustmentLayer = true; 58 + } 59 + } 60 + 61 + myPanel.layout.layout(true); 62 + 63 + if (myPanel != null && myPanel instanceof Window) { 64 + myPanel.center(); 65 + myPanel.show(); 66 + } 67 + 68 + // log all match names of selected layer (for example "ADBE Vector Stroke Width"): 69 + 70 + // (function () { // wrap entire script in an anonymous function to create a private scope within AE's global namespace 71 + // main(); 72 + // function dumpPropTree(rootObj, nestingLevel) { 73 + // var countProps = rootObj.numProperties; 74 + // for (var propIndex = 1; propIndex <= countProps; propIndex++) { 75 + // var prop = rootObj.property(propIndex); 76 + // $.writeln(Array(nestingLevel * 4).join(" ") + "[" + nestingLevel + "-" + propIndex + "] " + "matchName: \"" + prop.matchName + "\", name: \"" + prop.name + "\""); 77 + // if (prop.numProperties > 0) 78 + // dumpPropTree(prop, nestingLevel + 1); 79 + // } 80 + // } 81 + // function main() { 82 + // var activeComp = app.project.activeItem; 83 + // if (activeComp == null) { 84 + // alert("Error: No active composition"); 85 + // return; 86 + // } 87 + // var countSelectedLayers = activeComp.selectedLayers.length; 88 + // if (countSelectedLayers == 0) { 89 + // alert("Error: No selected layer(s)"); 90 + // return; 91 + // } 92 + // for (selectedLayerIndex = 0; selectedLayerIndex < countSelectedLayers; selectedLayerIndex++) { 93 + // var layer = activeComp.selectedLayers[selectedLayerIndex]; 94 + // $.writeln("***************** [ Layer: \"" + layer.name + "\" ] *****************"); 95 + // dumpPropTree(layer, 0); 96 + // } 97 + // } 98 + // })(); // end of anonymous function that encapsulates entire script