Forums › Adobe After Effects Expressions › Recursive offset PSR via duplicated pseudo effects
Recursive offset PSR via duplicated pseudo effects
Nathan Clark
May 13, 2020 at 1:59 pmHi creative cow, I hope whoever finds this message is faring well in these difficult times. Hoping for a little help as Im a bit out of my depth here.
I have a workflow where I apply a pseduo effect to a layer which provides controls for position / scale / rotation offsets. This is linked up via expressions to add the values from the pseudo effect to the original PSR values. I’m hoping to get something set up where the expression can look for multiple pseudo effects and it will add all of them to the original value.
So effectively I could then duplicate the pseudo effect (which would increment it’s name) and any of the new control values will add on top – and I could do this multiple times, stacking more and more PSR offset pseudo effects, as required.
I suppose what I need is some kind of way of having the expression loop through the effects stack looking for increments of the “PSR Offset *” effects, then adding their values. But I have no idea how to do this kind of thing with expressions, or if it is even possible?
I’ve included some screen shots as an alternative(simpler?) explanation for the goal. Also here’s a stripped down .aep including just a null with the pseudo effect applied to it – dropbox link
If anyone had some brain-space to help with this it would very appreciated ❤
Dan Ebberts
May 13, 2020 at 4:59 pmObviously I haven’t tested this, and I’m not even sure the syntax is exactly right, but it might give you an idea and get you headed in the right direction. This example is for Position:
n = thisLayer("Effects").numProperties;
accum = [0,0];
for (i = 1; i <= n; i++){
if (thisLayer("Effects").property(i).name.indexOf("PSR Offset") > -1){
accum += thisLayer("Effects").property(i).property("Position");
}
}
value + accum
Dan
Nathan Clark
May 14, 2020 at 4:48 amHi Dan, thanks so much for your time.
I spent a bit of time trying to get this up and running but can’t seem to work it out. It’s throwing the error:
TypeError: thisLayer(…).property is not a function
It says the error is at line 1. But I grabbed the line 1 code and used it by itself in another expression to test, and it does not throw an error, leaving me baffled.Here’s a screenshot of the error:
And a screenshot of where that first line is actually working fine in this other expression:
Searching web for the error returns another thread here on Creative Cow where you commented “I think the new JavaScript engine doesn’t like the this keyword.”
but in that thread the “this” was a this.sourceRectAtTime, rather than what we have here: “thisLayer(…)” (and which works anyway).
I would have loved to have worked this out using the pointers you provided, and not bugged you and the forum for more assistance. Sadly I have struck a wall, and I’m not there yet with knowing how to troubleshoot this
Dan Ebberts
May 14, 2020 at 6:53 amTry it this way:
n = thisLayer("Effects").numProperties;
accum = [0,0];
for (i = 1; i <= n; i++){
if (thisLayer("Effects")(i).name.indexOf("PSR Offset") > -1){
accum += thisLayer("Effects")(i)("Position");
}
}
value + accum
Dan
Nathan Clark
May 14, 2020 at 8:18 amThankyou kindly Dan, it works perfectly.
What a handy little tool this is ☺
Really appreciate the knowledge you share.
Log in to reply.