Activity › Forums › Adobe After Effects Expressions › How to check by name if a slider exist on a layer ?
-
How to check by name if a slider exist on a layer ?
Posted by Tal Arbiv on December 25, 2016 at 10:18 pmI know how to check for layer by name but property?
and also, how can i check the number of dimensions on an effect property?Thanks
if (myComp.layer("Layer Name").Effect("ADBE Slider Control").property("Slider") == null){
var exists =false;
}else{
var exists =true;
}Tal Arbiv replied 9 years, 8 months ago 2 Members · 8 Replies -
8 Replies
-
Dan Ebberts
December 26, 2016 at 7:49 amExpression or script? Something like this should work for an expression:
try{
thisComp.layer("Layer Name").effect("Slider Control")("Slider");
exists = true;
}catch(err){
exists = false;
}
It would be similar for a script.
Dan
-
Tal Arbiv
December 26, 2016 at 6:41 pmThank you so much Dan!
yes its scripting…
The second question i had was how can i tell how many dimensions a property has ?
i’m applying an expression to layers and i want the expression to change according to the dimensions…lets take wiggle for example
if there is a better way to do this please share…Thanks a lot again!
var expression1 = "wiggle (10,10)";
var expression2 = "w=wiggle (10,10);[w[0],w[0]]";
var expression3 = "w=wiggle (10,10);[w[0],w[0],w[0]]";for (i=0; i <= sellayers.length-1; i++){
for (p=0; p < = selprop.length-1; p++){
//missing query
selprop[p].expression = //expressionX;
}
-
Dan Ebberts
December 26, 2016 at 8:15 pmI think I’d do something like this:
var val = myProp.valueAtTime(0,false);
var numDim = val instanceof Array ? val.length : 1;Dan
-
Tal Arbiv
December 27, 2016 at 1:09 ami tried it and it breaks…
something about that valueAtTime method stops the loop that goes through the layers
var myComp = app.project.activeItem;
var sellayers = myComp.selectedLayers;
var selprop = myComp.selectedProperties;for (i=0; i <= sellayers.length-1; i++){
for (p=0; p <= selprop.length-1; p++){
selprop[p].expression =("1"); //WORKS GREAT
alert (selprop[p].valueAtTime(0,false)); // DOSNT WORK breaks the loop after the first layer
}
}
-
Dan Ebberts
December 27, 2016 at 2:11 amYou may have some properties selected that can’t have expressions, so I’d make sure that myProp.canSetExpression is true before doing the other tests.
Dan
-
Tal Arbiv
December 27, 2016 at 11:38 amThis will be great to add thanks.
but the problem wasn’t the expression. putting expressions works great for all layers and all properties, the valueAtTime line doesn’t.
what am i missing? -
Dan Ebberts
December 27, 2016 at 4:59 pmI don’t think you want to loop both selected layers and selected properties. This seems to work for me with everything I could throw at it:
var myComp = app.project.activeItem;
var selprop = myComp.selectedProperties;for (p=0; p <= selprop.length-1; p++){
if (selprop[p].canSetExpression){
selprop[p].expression =("value");
alert (selprop[p].valueAtTime(0,true));
}
}
Dan
-
Tal Arbiv
December 27, 2016 at 11:38 pmwow, i was sure i tried that at the beginning…
maybe i needed some operation to be made at the same time to the layers… anyway, it works now,
really appreciate your help!
Reply to this Discussion! Login or Sign Up