get an effect by name
main();
function main() {
app.beginUndoGroup("XXX");
var curComp = app.project.activeItem;
if(!curComp || !(curComp instanceof CompItem)) {
alert("noComp");
return;
}
var layer = curComp.selectedLayers[0];
var name = "locations_radius";
var matchName = "ADBE Slider Control";
var res = getEffect(layer, name, matchName);
res("ADBE Slider Control-0001").setValue(100);
}
// by Kevin Schires
// http://aescripts.com/authors/f-l/kevin-schires/
// edit by fabiantheblind
// http://aescripts.com/authors/f-l/fabiantheblind/
function getEffect(layer, name, matchName) {
var effectGroup = layer("ADBE Effect Parade");
var effect = null;
for(var i = 1; i <= effectGroup.numProperties; i++) {
effect = effectGroup(i);
if(effect.name !== name && effect.matchName !== matchName) {
effect.name += " *";
effect = null;
} else {
break;
}
}
if(!effect && effectGroup.canAddProperty(matchName)) {
effect = effectGroup.addProperty(matchName);
effect.name = name;
}
return effect;
}
main();
function main() {
app.beginUndoGroup("XXX");
var curComp = app.project.activeItem;
if(!curComp || !(curComp instanceof CompItem)) {
alert("noComp");
return;
}
var layer = curComp.selectedLayers[0];
var name = "locations_radius";
var matchName = "ADBE Slider Control";
var res = getEffect(layer, name, matchName);
res("ADBE Slider Control-0001").setValue(Math.random()* 1000);
}
// by Kevin Schires
// edit by fabiantheblind
function getEffect(layer, name, matchName)
{
var start = new Date().getTime();
var effectGroup = layer("ADBE Effect Parade");
var effect = effectGroup(name);
if ( effect && effect.matchName != matchName )
{
effect.name += " *";
effect = null;
}
if ( !effect && effectGroup.canAddProperty(matchName) )
{
effect = effectGroup.addProperty(matchName);
effect.name = name;
}
var end = new Date().getTime();
var time = end - start;
alert('Execution time: ' + time);
return effect;
}