Mask Path expression
by Dan Kelly on Aug 9, 2012 at 2:10:16 pm
I need an expression to turn a mask's opacity = 100 if there's a mask path keyframe, else the mask opacity = 0. I have some code background but this is my very first expression, so be gentle.
Can the presence of a keyframe be tested?
Thanks for any and all help!
Dan
Here's the background
I'm doing roto with Mocha AE and bringing in the shape layers via "Paste Mocha Mask". The in and out points of the shape layers get translated into AE masks as continuous mask shape keyframes, starting at the shape in point and ending at the shape outpoint. This means that all the masks are visible and that's not very useful, so my idea is to knock out the opacity to recreate in and out points. If anyone is familiar with this workflow and thinks they have a better solution than writing an expression, I'd be much obliged.
if (mask("Mask 1").maskPath){mask("Mask 1").opacity = 100}else{mask("Mask 1").opacity = 0
}
Re: Mask Path expression by Dan Ebberts on Aug 9, 2012 at 3:14:59 pm
From your screen shot, it looks like there are Mask Path keyframes, so I would expect the expression to return 100%. I notice that there appear to be refresh issues in versions prior to CS6, which means you might have to clear the cache to see a change. It's also possible I misunderstood your request. The expression should give you 100% if the path has any keyframes. Is that what you wanted?
Re: Mask Path expression by Dan Ebberts on Aug 9, 2012 at 3:54:29 pm
I can think of a couple ways to do it. If you really want 100 on any frame where there is a keyframe, on each frame, the expression will have to go through all the keyframes until it finds one that has the same frame number as the current time (= pretty inefficient if you have a lot of keyframes.
The other possibility would be to just check the times of the first and last keyframes, and make the opacity 100 if the current time is between those two times. Will that work?
Re: Mask Path expression by Dan Kelly on Aug 9, 2012 at 4:11:37 pm
[Dan Ebberts] The other possibility would be to just check the times of the first and last keyframes, and make the opacity 100 if the current time is between those two times. Will that work?"
Either one would work. Paste Mocha Mask creates only one contiguous set of keyframes for each mask, so the first and last approach makes sense.