Cycle through expressions to clear warnings/errors

Moderators: Disciple, zlovatt

NEO_AMiGA
Posts: 20
Joined: September 4th, 2008, 5:55 am

Have a little annoyance over here. I have quite a bit of expressions in a comp here. And sometimes an expression does not update when I for instance check a checkbox that "drives" it (could for example be changing the color of a fill or so). Or when I duplicate a layer with expression I sometimes get some error because the layers are linked in the expressions with the help of "index". So they have to be in the correct position. But when the layer is put into position the expression warnings ain't removed.
So to fix both these scenarios I have to go into all expressions and click them, then click in the viewer or so so the expression reloads. Very frustrating when there are so many expressions as I currently have.

So I wonder if there's any global expression-refresh command? So I can easily just cycle through all expressions for a layer or comp to make them valid again...?
Mylenium
Posts: 139
Joined: July 20th, 2005, 12:07 am

NEO_AMiGA wrote:So I wonder if there's any global expression-refresh command? So I can easily just cycle through all expressions for a layer or comp to make them valid again...?
No. There's a reason it behaves this way. And for the other matter: If your code doesn't evaluate, then it is crooked. By all means, AE will always evaluate at any frame and scrubbing the timeline should update. It not being so can only mean that a condition in your expression isn't met.

Mylenium
[Pour Mylène, ange sur terre]
NEO_AMiGA
Posts: 20
Joined: September 4th, 2008, 5:55 am

Mylenium wrote:
NEO_AMiGA wrote:So I wonder if there's any global expression-refresh command? So I can easily just cycle through all expressions for a layer or comp to make them valid again...?
No. There's a reason it behaves this way. And for the other matter: If your code doesn't evaluate, then it is crooked. By all means, AE will always evaluate at any frame and scrubbing the timeline should update. It not being so can only mean that a condition in your expression isn't met.

Mylenium
Hmm... I don't think your really correct here. Because the expression that get's flagged with the triangle does work immediately after I have clicked on the expression row and then once again clicked on the comp. So after I have duplicated my layer I have to to this on 20+ expressions. I guess it has something to do with the duplicate/copy not doing stuffs in the correct order or something. But never the less... Once an expression is flagged with the triangle it is disabled until the user takes action. And this is what I'm trying to automate.
Dan Ebberts
Posts: 320
Joined: June 26th, 2004, 10:01 am
Location: Folsom, CA
Contact:

What does the expression look like?

Dan
NEO_AMiGA
Posts: 20
Joined: September 4th, 2008, 5:55 am

Dan Ebberts wrote:What does the expression look like?

Dan
The setup could look like this:

Layer Index 12: Text layer with 10 masks. Masks are adjusted here
Layer index 13: Shape layer with a rectangle and 10 masks. All masks attributes are with expressions linked to the layer above. Like: thisComp.layer(index-1).mask("Word 01").maskPath

When select those two layers and copy and paste them all those expressions goes haywire. So I have to manually click on the expression row on all expressions and then go back out in the comp. Can do a screencap of it if someone wants to see what I mean.

Oh guys, I have not thanked you for all your help. So I must just say that you guys rock and thanks for all help I have gotten in all my different threads. You're the man Dan!
Dan Ebberts
Posts: 320
Joined: June 26th, 2004, 10:01 am
Location: Folsom, CA
Contact:

I'm not having any luck duplicating that behavior. My test case isn't as complicated as your example, but I don't have any trouble (i.e., the expressions don't break) copying and pasting pairs of layers with expressions linking the paths of the bottom layer to masks of the top layer where the expressions reference the top layer using index-1. Sorry, I'm stumped.

Dan
NEO_AMiGA
Posts: 20
Joined: September 4th, 2008, 5:55 am

Mmmkay... I made a screencap of it:

http://www.irry.com/neo/bilder/temp/3d/ ... broken.zip

It's a 102MB zip that unpacks to an 800MB avi. I have no time now to recompress it. Will provide a smaller QT tmorrow. But maybe it's ok with this one?
Dan Ebberts wrote:I'm not having any luck duplicating that behavior. My test case isn't as complicated as your example, but I don't have any trouble (i.e., the expressions don't break) copying and pasting pairs of layers with expressions linking the paths of the bottom layer to masks of the top layer where the expressions reference the top layer using index-1. Sorry, I'm stumped.

Dan
Dan Ebberts
Posts: 320
Joined: June 26th, 2004, 10:01 am
Location: Folsom, CA
Contact:

There is something strange going on. When you paste, a new Layer 1 (STROKE TEXT ROW 9) shows up (with a little comp layer indicator instead of the shape layer indicator). Whatever's happening, it appears that that layer with the expressions is getting pasted in before the expressions' target layer, which I would expect to break the expressions. It might be a timing thing having to do with how complex your layers are.

Maybe you could try copying and pasting the layer with the masks first, then the layer with the expressions.

Dan
NEO_AMiGA
Posts: 20
Joined: September 4th, 2008, 5:55 am

Mmm... Theres something real odd there. Will look further tomorrow. I did try to select and copy paste them in different order but that didn't help. And I tried to duplicate them. But then they will not be "pasted" after one eachother so then it breaks a bunch of expressions.

But you see where I'm going with my "cycle through a whole comps layers expressions" now? =) Would be really neat if it was possible in some way. Couldn't I make like a script that just cycles through all layers in the comp and looks at all attributes with an expression and just reads in the expression and sets it again? Sounds like a pretty straight forward iteration task? But not sure what I can and can't access with script/expressions in AE. Would had been easier if it was Maya or Nuke (at least for me =)). =/
Dan Ebberts wrote:There is something strange going on. When you paste, a new Layer 1 (STROKE TEXT ROW 9) shows up (with a little comp layer indicator instead of the shape layer indicator). Whatever's happening, it appears that that layer with the expressions is getting pasted in before the expressions' target layer, which I would expect to break the expressions. It might be a timing thing having to do with how complex your layers are.

Maybe you could try copying and pasting the layer with the masks first, then the layer with the expressions.

Dan
Dan Ebberts
Posts: 320
Joined: June 26th, 2004, 10:01 am
Location: Folsom, CA
Contact:

You could do it with a script. The trick would be finding all the properties with expressions. In your case though, since you know where they are, you could set up the code to zero in on them. You should be able to just set the expression text to the existing text. Haven't tried it, but I'd guess that would work.

Dan
NEO_AMiGA
Posts: 20
Joined: September 4th, 2008, 5:55 am

Great news. Managed to find out what was causing this behavior. On that shape layer that behaved odd I had added a fill effect and linked that one to the fill of the layer above (index - 1). When killing that fill effect I could duplicate it. So instead I linked the color fill to the shapes fill, which I of course should have done from the beginning but guess I overlooked that when I was in a hurry.

So for the moment I'm a happy face!

Thanks again for all help!
Dan Ebberts wrote:You could do it with a script. The trick would be finding all the properties with expressions. In your case though, since you know where they are, you could set up the code to zero in on them. You should be able to just set the expression text to the existing text. Haven't tried it, but I'd guess that would work.

Dan
NEO_AMiGA
Posts: 20
Joined: September 4th, 2008, 5:55 am

Bummer! This old "bug" came back and bit me in the ass! Really hard! :? Seems like there's a bug that makes it impossible to paste shape layers with effect that has expressions that refers to something like (index-1). In this case I have a shape layer with a drop shadow. And the layer above is a text layer also with a drop shadow. I drive the opacity of the drop shadow with an expression that links it to the drop shadow on the layer above (index-1). When I paste it it does as described on the earlier screen capture and the expression dies. Then I manually have to click on the expression to reactivate it. Really frustrating. Haven't found any workaround so far. Will try to do it with a solid or something instead.
NEO_AMiGA
Posts: 20
Joined: September 4th, 2008, 5:55 am

So i remade it with a solid instead of a shape layer. Same behavior. :( Going nuts over here. Is there some reason that this expression on a layers drop shadow opacity wouldn't work to copy and paste?

thisComp.layer(index).effect("Drop Shadow")(2).value = thisComp.layer(index-1).effect("Drop Shadow")(2).value;

I'm copying and pasting both the layers... Can't really figure out what's going on and why the layer looks like a comp when I paste it. I guess that it checks up (layer - 1) before both layers are pasted. Instead it should check the expressions the last thing it does.
NEO_AMiGA
Posts: 20
Joined: September 4th, 2008, 5:55 am

Mkay I got a workaround from Mr Princz that worked! It's a simple one! Just put the whole expression inside

if(index > 1){
expression goes here
}

else{
...something else
}

Thanks again man! :D
User avatar
lloydalvarez
Enhancement master
Posts: 460
Joined: June 17th, 2004, 9:27 am
Location: New York City, NY
Contact:

Btw, writing a script that goes through a comp and attempts to re-enable turned off expression is on my to-do list. This is something that has always frustrated me in AE when dealing with lots of layers with expressions..

Stay tuned..

-Lloyd
Post Reply