Quantcast
Channel: Adobe Community : Discussion List - After Effects Scripting
Viewing all articles
Browse latest Browse all 2143

autoFixExpressions

$
0
0

I'm experiencing issues with app.project.autoFixExpressions() (which is a utility function that attempts to fix expressions that a script may have broken, to be used like this: app.project.autoFixExpressions(oldString, newString) - see guide).

It works most of the time, but not always.

Here is a situation where it does not:

 

// create a new comp, a solid with a slider control, then duplicate the solid to get 5 solids.
var n, N=5;
var name;
var comp = app.project.items.addComp("test", 1280, 720, 1.0, 5.0, 25.0);
with(comp.layers.addSolid([1,1,0.5], comp.width, comp.height, comp.pixelAspect, comp.duration)){    name = "solid";    effect.addProperty("ADBE Slider Control").name = "My Slider";    effect(1)(1).expression = "thisComp.layer(\"solid\").effect(\"My Slider\")(1).value";    };
for (n=1; n<N; n++) comp.layer(1).duplicate();
// at this stage, layer(1).name is "solid 5", ... , layer(5).name is "solid".
// all expressions refer to the slider of the last layer.

// rename all solids and try autofix expressions
for (n=1; n<=N; n++){    name = comp.layer(n).name;    app.project.autoFixExpressions(name, comp.layer(n).name = name.replace("solid", "gaz"));    };
// ===> the expression in the last layer is not fixed...

 

If one replaces the line for (n=1; n<N; n++) comp.layer(1).duplicate(); by

 

for (n=1; n<N; n++) comp.layer(1).duplicate().effect(1)(1).expression = "thisComp.layer(\"solid " + (++n) +"\").effect(\"My Slider\")(1).value";

 

(so that now each expression refers to its own layer (same as thisLayer.effect(\"My Slider\")(1).value";), then all expressions are fixed correctly.

 

Should this be considered as a bug or am i doing something wrong ? I'm lost.


Viewing all articles
Browse latest Browse all 2143

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>