Page 1 of 1

setting a property to an expression from within script

Posted: September 5th, 2008, 12:36 pm
by peteoconnell
Hi I am making a script that makes an adjustment layer with a levels effect on it and I would like the the rgb gamma property to be an expression deriving its value from the input white property. Although I can get the expression to work as a simple number eg:

Code: Select all

myComp = app.project.activeItem;
mySolid = myComp.layers.addSolid([0,0,0], "colorCorrect", myComp.width, myComp.height,1);
mySolid.startTime = 0
mySolid.adjustmentLayer = true;
myEffect = mySolid.property("Effects").addProperty("Levels (Individual Controls)");
myEffectProperty = myEffect.property("Gamma");
var myEffectPropertyExpression = "5" 
myEffectProperty.expression = myEffectPropertyExpression;
I can't seem to get it to work as a string expression pointing to another property (in this example I get an error):

Code: Select all

myComp = app.project.activeItem;
mySolid = myComp.layers.addSolid([0,0,0], "colorCorrect", myComp.width, myComp.height,1);
mySolid.startTime = 0
mySolid.adjustmentLayer = true;
myEffect = mySolid.property("Effects").addProperty("Levels (Individual Controls)");
myEffectProperty = myEffect.property("Gamma");
var myEffectPropertyExpression = "effect("Levels (Individual Controls)")("Input White")"
myEffectProperty.expression = myEffectPropertyExpression;

Anyone know what's up with that?
Pete O'Connell

Re: setting a property to an expression from within script

Posted: September 5th, 2008, 8:04 pm
by Dan Ebberts
You probably just need to change the outer quotes to single quotes so they don't confilict with the quotes in the expression itself:

var myEffectPropertyExpression = 'effect("Levels (Individual Controls)")("Input White")';

Dan

Re: setting a property to an expression from within script

Posted: September 7th, 2008, 8:56 am
by peteoconnell
Thanks Dan that did the trick.
Pete