-
Script UI Not Detecting Variable
Hello everyone, I am having a problem of detecting a variable in a text box. So basically what I want to do is to apply a pre-defined preset to whatever I typed into the text box. Now when I click the button, it creates an empty layer with the preset because apparently, it can’t detect the variable I give it.
Here is the code, it may look like what a noob would have done because I am completely new to coding. More resources will be provided below…(function(thisObj){
scriptBuildUI(thisObj)function scriptBuildUI(thisObj) {
var win = (thisObj instanceof Panel) ? thisObj : new Window("palette", "ScriptUI Template", undefined);
win.spacing = 5;var groupOne = win.add("group", undefined, "GroupOne");
groupOne.orientation = "column";var myText = groupOne.add ("edittext", undefined, "");
myText.characters = 30;
// myText.active = true; // <--- This line I copied from the Internet, don't know what excatly it does
myText.helpTip = "Please edit your text here"
var myEditText = myText.text;var Button = groupOne.add("button", undefined, "Button");
Button.onClick = function(){
main('Bouncing_texts.ffx', myEditText); // FINAL FUNCTION!!!
};win.onResizing = win.onResize = function() {
this.layout.resize();
};win instanceof Window
? (win.center(), win.show()) : (win.layout.layout(true), win.layout.resize());
}// Add functions below this line
// Applying Presets //
var main = function(myFX, myEditText) {var proj = app.project;
var folder = new Folder('C:/Program Files/Adobe/Adobe After Effects CC 2019/Support Files/Presets/User Presets/' + myFX);
if (folder.exists !== true) {
alert('Preset file does not exist');
return;
}app.beginUndoGroup('apply preset');
var Composition = proj.activeItem;
var myTextLayer = Composition.layers.addText(myEditText);
var myTextSource = myTextLayer.sourceText;
var myTextDocument = myTextSource.value;// var item = proj.activeItem;
myTextLayer.applyPreset(folder);
myTextSource.setValue(myTextDocument);app.endUndoGroup();
// return 0;
};
// Function "Apply presets" Ends //})(this);
Some more details here: https://imgur.com/0BGfNIy
https://imgur.com/1soiSP4Any help is greatly appreciated!!
John