Activity › Forums › Adobe After Effects Expressions › How to target a property on an effect
-
How to target a property on an effect
Posted by Romain Cousin on October 22, 2016 at 10:54 amHi,
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.frRomain Cousin replied 9 years, 6 months ago 2 Members · 6 Replies -
6 Replies
-
Dan Ebberts
October 22, 2016 at 7:48 pmGenerally 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
-
Romain Cousin
October 22, 2016 at 8:29 pmThanks 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 -
Dan Ebberts
October 22, 2016 at 9:11 pmWhen 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
-
Romain Cousin
October 22, 2016 at 9:59 pmThanks 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 -
Dan Ebberts
October 22, 2016 at 10:09 pmMy 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
-
Romain Cousin
October 22, 2016 at 10:25 pmOk!
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
Reply to this Discussion! Login or Sign Up