FORUMS: list search recent posts

How to target a property on an effect

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Romain Cousin
How to target a property on an effect
on Oct 22, 2016 at 10:54:07 am
Last Edited By Romain Cousin on Oct 22, 2016 at 2:34:12 pm

Hi,

When I set a variable for targetting a property on a layer I write:

var myProperty = app.project.activeItem.selectedLayers[0].selectedProperties[0];

It works well on classic properties like "position", "rotation", "opacity", etc ...but it doesn't work on the properties of an effect such as Particular, a simple slider, etc...

How can I declare this variable? At the end I want to get the value of any properties.

Thank you!

Freelance motion designer :
http://www.romaincousin.fr


Return to posts index

Dan Ebberts
Re: How to target a property on an effect
on Oct 22, 2016 at 7:48:48 pm

Generally by name:

var myProperty = app.project.activeItem.selectedLayers[0].property("Effects").property("Particular").property("Emitter Type")

or better yet (in case your script might be used in a different language version of AE), by match name:

var myProperty = app.project.activeItem.selectedLayers[0].property("ADBE Effect Parade").property("tc Particular").property("tc Particular-0005")


Dan



Return to posts index

Romain Cousin
Re: How to target a property on an effect
on Oct 22, 2016 at 8:29:30 pm

Thanks Dan, unfortunately I don't know which properties users will select, Particular was just an exemple.

I have to get the length of the values and then apply an expression depending on the length.
The expressions are not the same on 1D, 2D or 3D values...

As I said it works well on "layer properties" but not on "effect properties". Is there a trick to get the value (and the length) of whatever selected properties?

--
Freelance motion designer http://www.romaincousin.fr


Return to posts index


Dan Ebberts
Re: How to target a property on an effect
on Oct 22, 2016 at 9:11:48 pm

When you select a property, upstream properties may also get selected. For example, selecting Emitter Type also selects Particular. So you need to loop through the selected properties and process just the ones that are actual properties. This example should give the name and dimensions of the type property you're looking for:


var myProps = app.project.activeItem.layer(1).selectedProperties;
var myProp;
var n;
for (var i = 0; i < myProps.length; i++){
myProp = myProps[i];
if (myProp.propertyType == PropertyType.PROPERTY){
switch(myProp.propertyValueType){
case PropertyValueType.OneD:
n = 1;
break;
case PropertyValueType.TwoD:
case PropertyValueType.TwoD_SPATIAL :
n = 2;
break;
case PropertyValueType.ThreeD:
case PropertyValueType.ThreeD_SPATIAL:
n = 3;
break;
case PropertyValueType.COLOR:
n = 4;
break;
default:
n = 0; // just in case
break;
}
alert (myProp.name + " " + n);
}
}


Dan



Return to posts index

Romain Cousin
Re: How to target a property on an effect
on Oct 22, 2016 at 9:59:18 pm

Thanks a lot, exactly what i needed!

I had already noticed a bug with my old code and i get the same result with yours, but the layer position property gets 3 dimensions (on a 2D layer)... Do you have an explanation? It's not a big deal but it's weird...

--
Freelance motion designer http://www.romaincousin.fr


Return to posts index

Dan Ebberts
Re: How to target a property on an effect
on Oct 22, 2016 at 10:09:38 pm

My guess is that behind the scenes, they're all 3D layers, with the z component zero'd out and hidden unless the 3D switch is on. You can check the state of the 3D switch with:

yourLayer.threeDLayer

if that helps.

Just curious--give me an example of an expression you're using where you need to know the dimensions of the property.

Dan



Return to posts index


Romain Cousin
Re: How to target a property on an effect
on Oct 22, 2016 at 10:25:48 pm

Ok!

Sorry I do not have the code on this computer, but basically I want to random the selected properties. The expression are linked to a pseudo effect (I created different pseudo effect based on the length of the property) and I do not have the same expression for "numbers" properties and colors for example.
For 3 dimensionnal properties I have 6 sliders :
minX, minY, minZ, maxX, maxY, maxZ
but for one dimensionnal property i only have a "minimum" and a "maximum" sliders.

--
Freelance motion designer http://www.romaincousin.fr


Return to posts index

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