FORUMS: list search recent posts

write a script to run another script

COW Forums : Adobe After Effects

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Amanda Russell
write a script to run another script
on Jun 19, 2018 at 12:44:56 am

Looking forward to ideas...

I'm trying to build a UI Script Panel I can send to our third party designers so they can quickly convert and animate some files for us. I have the panel built, but the tools we use internally are mostly presets and a few scripts.



I figured out how to apply a preset to the selected layer from the preset .ffx file (panel 3/button 1 for Fly In/Out), but I'm not sure how to make the buttons run a script in the same way (by referencing a specific .jsx file). So currently, panel 1/button1 for Fade In works, but I'd like it to use the script file instead so if I need to make changes internally, I don't have to also edit the panel for our external designers - just send everyone the same updated fadeIn.jsx to replace.

Code below:

{
function myScript(thisObj) {
function myScript_buildUI(thisObj) {
var myPanel = (thisObj instanceof Panel) ? thisObj : new Window("palette", "PPT Toolbar", undefined, {resizeable:true});
res="group{orientation:'row', alignment:['fill', 'fill'], alignChildren:['fill', 'fill'],\
myPanelOne: Panel{text:'Entrance Effects', orientation:'column', alignChildren:['fill', 'top'],\
myPanelOneButton1: Button{text:'Fade In'},\
myPanelOneButton2: Button{text:'Zoom In 0-100'},\
myPanelOneButton3: Button{text:'Zoom In 1000-100'},\
myPanelOneButton4: Button{text:'Grow & Spin In'},\
myPanelOneButton5: Button{text:'Swivel In'},\
myPanelOneButton6: Button{text:'Wheel In'},\
myPanelOneButton7: Button{text:'Stretch'},\
myPanelOneButton8: Button{text:'Expand'},\
myPanelOneButton9: Button{text:'Spiral'},\
},\
myPanelTwo: Panel{text:'Exit Effects', orientation:'column', alignChildren:['fill', 'top'],\
myPanelTwoButton1: Button{text:'Fade Out'},\
myPanelTwoButton2: Button{text:'Zoom Out 100-0'},\
myPanelTwoButton3: Button{text:'Zoom Out 100-1000'},\
myPanelTwoButton4: Button{text:'Grow & Spin Out'},\
myPanelTwoButton5: Button{text:'Swivel Out'},\
myPanelTwoButton6: Button{text:'Wheel Out'},\
myPanelTwoButton7: Button{text:'Collapse'},\
myPanelTwoButton8: Button{text:'Contract'},\
},\
myPanelThree: Panel{text:'Dual Effects', orientation:'column', alignChildren:['fill', 'top'],\
myPanelThreeButton1: Button{text:'Fly In/Out'},\
myPanelThreeButton2: Button{text:'Rise/Sink'},\
myPanelThreeButton3: Button{text:'Float In/Out'},\
myPanelThreeButton4: Button{text:'Peek In/Out'},\
myPanelThreeButton5: Button{text:'Wipe In/Out'},\
myPanelThreeButton6: Button{text:'Split Wipe In/Out'},\
},\
myPanelFour: Panel{text:'Additional Effects', orientation:'column', alignChildren:['fill', 'top'],\
myPanelFourButton1: Button{text:'Blink'},\
myPanelFourButton2: Button{text:'Teeter'},\
myPanelFourButton3: Button{text:'Pulse'},\
myPanelFourButton4: Button{text:'Bounce'},\
myPanelFourButton5: Button{text:'Typewriter Text'},\
myPanelFourButton6: Button{text:'Wave Text'},\
myPanelFourButton7: Button{text:'Drop Shdw Far'},\
myPanelFourButton8: Button{text:'Drop Shdw Near'},\
myPanelFourButton9: Button{text:'Gradient BG'},\
},\
myPanelFive: Panel{text:'Other', orientation:'column', alignChildren:['fill', 'top'],\
myPanelFiveButton1: Button{text:'Time Remap'},\
myPanelFiveButton2: Button{text:'Chapter Marker'},\
myPanelFiveButton3: Button{text:'styleGuide Fill'},\
},\
}"
//Add resource string to panel
myPanel.grp = myPanel.add(res);

//Defaults
//panel 1 button 1
myPanel.grp.myPanelOne.myPanelOneButton1.onClick = function setOpacityKeyframes() {
var selectedLayers = app.project.activeItem.selectedLayers;

if (selectedLayers.length == 0) {
throw new Error('Please select at least 1 layer.');
}

for (var i = 0; i < selectedLayers.length; i++) {
var fadeTime = 0.50
var layer = selectedLayers[i];

if (layer.property("Transform").property("Opacity").numKeys.length >= 1) {
throw new Error('Layer "' + layer.name + '" has existing opacity keyframes. Disable opacity stopwatch and retry.');
}

//layer.timeRemapEnabled = true;

var keyframes = layer.property("Transform").property("Opacity");

keyframes.setValueAtTime(layer.inPoint, 0);
keyframes.setValueAtTime(layer.inPoint + fadeTime, 100);

//keyframes.setInterpolationTypeAtKey(1, KeyframeInterpolationType.LINEAR, KeyframeInterpolationType.LINEAR);
}

//panel 3 button 1
myPanel.grp.myPanelThree.myPanelThreeButton1.onClick = function applyPreset(preset) {
var preset = File ('/Applications/Adobe After Effects CC 2017/Presets/pptPresets2018/superFly.ffx');
app.project.activeItem.layer(1).applyPreset(preset);
}

}

//Setup panel sizing and make panel resizable
myPanel.layout.layout(true);
myPanel.grp.minimumSize = myPanel.grp.size;
myPanel.layout.resize();
myPanel.onResizing = myPanel.onResize = function () {this.layout.resize();}

return myPanel;
}
var myScriptPal = myScript_buildUI(thisObj);
if ((myScriptPal != null) && (myScriptPal instanceof Window)) {
myScriptPal.center();
myScriptPal.show();
}
}
myScript(this);
}


Return to posts index

Walter Soyka
Re: write a script to run another script
on Jun 19, 2018 at 10:29:49 am

Two methods I can think of right away.

1) If the script is installed in one of Ae's default application or user script folders, it will appear as a menu item. That means you can call it as such:

app.executeCommand(app.findMenuCommandId("myGreatScript.jsx"));


2) If you know where the file sits on disk, you can call tell Ae's scripting engine to evaluate it:

$.evalFile("C:/path/to/myGreatScript.jsx");

Walter Soyka
Designer & Mad Scientist at Keen Live [link]
Motion Graphics, Widescreen Events, Presentation Design, and Consulting
@keenlive [twitter]   |   RenderBreak [blog]   |   Profile [LinkedIn]


Return to posts index

Amanda Russell
Re: write a script to run another script
on Jun 19, 2018 at 6:26:29 pm

Thank you! I have some customer work to get through, but I'm excited to try this out!


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2018 CreativeCOW.net All Rights Reserved
[TOP]