ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

How to check by name if a slider exist on a layer ?

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Tal Arbiv
How to check by name if a slider exist on a layer ?
on Dec 25, 2016 at 10:18:17 pm
Last Edited By Tal Arbiv on Dec 25, 2016 at 10:35:33 pm

I 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;
}


Return to posts index

Dan Ebberts
Re: How to check by name if a slider exist on a layer ?
on Dec 26, 2016 at 7:49:15 am

Expression 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



Return to posts index

Tal Arbiv
Re: How to check by name if a slider exist on a layer ?
on Dec 26, 2016 at 6:41:02 pm

Thank 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 &lt;= sellayers.length-1; i++){
for (p=0; p &lt; = selprop.length-1; p++){
//missing query
selprop[p].expression = //expressionX;
}


Return to posts index


Dan Ebberts
Re: How to check by name if a slider exist on a layer ?
on Dec 26, 2016 at 8:15:58 pm

I think I'd do something like this:

var val = myProp.valueAtTime(0,false);
var numDim = val instanceof Array ? val.length : 1;


Dan



Return to posts index

Tal Arbiv
Re: How to check by name if a slider exist on a layer ?
on Dec 27, 2016 at 1:09:54 am

i 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 &lt;= sellayers.length-1; i++){
for (p=0; p &lt;= 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
}
}


Return to posts index

Dan Ebberts
Re: How to check by name if a slider exist on a layer ?
on Dec 27, 2016 at 2:11:04 am

You 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



Return to posts index


Tal Arbiv
Re: How to check by name if a slider exist on a layer ?
on Dec 27, 2016 at 11:38:43 am

This 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?


Return to posts index

Dan Ebberts
Re: How to check by name if a slider exist on a layer ?
on Dec 27, 2016 at 4:59:24 pm

I 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



Return to posts index

Tal Arbiv
Re: How to check by name if a slider exist on a layer ?
on Dec 27, 2016 at 11:38:37 pm

wow, 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!


Return to posts index

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