FORUMS: list search recent posts

AE Script: How do you retrieve a new value for a script?

COW Forums : Adobe After Effects

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Mark Michel
AE Script: How do you retrieve a new value for a script?
on Jun 19, 2018 at 7:10:40 pm

I'm new to After Effects scripting and am about 80% done my first script. I'm trying to retrieve a new value the user sets for the 2nd part of the script to work properly.

Part one is establishing the script UI.
By default, in the script I set x position to be 10. When the script UI is launched, x = 10 and 10 is editable. Let's say the user now enters 250 instead of 10, so now it's x = 250. Now the user clicks "GO".

Part two is creating a new control layer.
After "GO" is clicked, a new solid/"controller" layer is created with the Controller effect set in place. I'm using Pseudo Effect Maker to help establish this Controller effect. Within the Controller effect I have an x position. Currently, x shows up as 10. What bit of code do I have to do to set it to be 250?

Currently I have:
var controllerLayer = app.project.activeItem;
var effect = controllerLayer.layer(selectedLayer[0].name+" Controller").property("ADBE Effect Parade").property("Pseudo/PSE Effect Name");
alert(effect.property("Pseudo/PSE Effect Name-0014").value);


The alert displays "10". Is there a method to retrieve the new value the user entered so the alert can say "250"?

Thanks for the help!


Return to posts index

Walter Soyka
Re: AE Script: How do you retrieve a new value for a script?
on Jun 20, 2018 at 3:48:07 pm

[Mark Michel] "By default, in the script I set x position to be 10. When the script UI is launched, x = 10 and 10 is editable. Let's say the user now enters 250 instead of 10, so now it's x = 250. Now the user clicks "GO"."

It sounds like you need to read the value of the edittext box in the UI. You can either pass the UI panel/palette object or pass the value of the edittext box to your button's onClick handler function, so it can set the property value accordingly.

What's your UI code look like?

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

Mark Michel
Re: AE Script: How do you retrieve a new value for a script?
on Jun 20, 2018 at 6:45:47 pm

Thanks for the help Walter,

I'm not going to paste all of the code, but the code I think it relevant to this situation. If I'm missing anything I'll recheck my code again to include it in here. In getting the correct number, I suppose I'd prefer to pass the value of the edittext box while going through the onClick function, but I don't know how. Any help you give is much appreciated.

(function(thisObj) {

var PosX = PosXx = null;

scriptBuildUI(thisObj);

function scriptBuildUI(thisObj) {

var myX = 10.00;
PosX.add("statictext", undefined,"X");
PosXx = PosX.add("edittext", undefined, myX);
var mySection = win.add("group", undefined, "GroupOne");
var goSet = mySection.add("button", undefined, "Go");
goSet.onClick = setController;

win.onResizing = win.onResize = function() {
this.layout.resize();
};

win instanceof Window
? (win.center(), win.show()) : (win.layout.layout(true), win.layout.resize());
}
function setController(){

var activeItem = app.project.activeItem;
selectedLayer = activeItem.selectedLayers;
var solidName = selectedLayer[0].name + " Controller";
var solidW = activeItem.width;
var solidH = activeItem.height;
var solidPixelAspectRatio = activeItem.pixelAspect;
var solidDuration = activeItem.duration;
var adjLayer = activeItem.layers.addSolid([1, 1, 1], solidName, solidW, solidH, solidPixelAspectRatio, solidDuration);

adjLayer.moveBefore(selectedLayer[0]);
adjLayer.adjustmentLayer = true;

var presetPath = ("C:/Users/MARK/Documents/Pseudo Effect Maker/Controller.ffx");
var myPreset = File(presetPath);
adjLayer.applyPreset(myPreset);

setExpression(thisObj);

}

function setExpression(thisObj){
var controllerLayer = app.project.activeItem;
var controlThis = controllerLayer.layer(selectedLayer[0].name+" Controller").property("ADBE Transform Group").property("ADBE Anchor Point");
var selectedThis = controllerLayer.layer(selectedLayer[0].name).property("ADBE Transform Group").property("ADBE Anchor Point");
var effect = controllerLayer.layer(selectedLayer[0].name+" Controller").property("ADBE Effect Parade").property("Pseudo/PSE Effect Name");
alert(effect.property("Pseudo/PSE Effect Name-0014").value); // the alert states "10"
}
}
})(this);



Return to posts index


Walter Soyka
Re: AE Script: How do you retrieve a new value for a script?
on Jun 22, 2018 at 4:38:01 pm

Here's a quick sample:

function myScript(thisObj) {
// function to build the UI
function myScript_buildUI(thisObj) {
var myPanel = (thisObj instanceof Panel) ? thisObj : new Window("palette", "UI Test", [0, 0, 300, 300]);
var res =
"group { \
orientation:'column', alignment:['left', 'top'], alignChildren:['left', 'top'] \
userValue: EditText {text:'10'} \
doItButton: Button{text: 'Go'} \
}";

//Add resource string to panel
myPanel.grp = myPanel.add(res);

//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();}

// UI handlers here
myPanel.grp.doItButton.onClick = function() { doItFunction(myPanel.grp.userValue.text) };

return myPanel;
}

// invoke the UI here
var myScriptPal = myScript_buildUI(thisObj);
if ((myScriptPal != null) && (myScriptPal instanceof Window)) {
myScriptPal.center();
myScriptPal.show();
}

// what shall we actually do when the user presses the Go button?
function doItFunction(x) {
alert(x);
}

}

myScript(this);


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

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