Creative COW SIGN IN :: SPONSORS :: ADVERTISING :: ABOUT US :: CONTACT US
Creative COW's LinkedIn GroupCreative COW's Facebook PageCreative COW on TwitterCreative COW's Google+ PageCreative COW on YouTube
ADOBE AFTER EFFECTS:HomeForumBasicsExpressionsTutorialsPodcastsAE TechniquesCreative Cloud DebateFAQ

Mask Path expression

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Share on Facebook
Dan KellyMask Path expression
by 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
}



Return to posts index
Reply   Like  

Dan EbbertsRe: Mask Path expression
by on Aug 9, 2012 at 2:17:19 pm

This should work:

if (thisProperty.propertyGroup(1).maskPath.numKeys > 0) 100 else 0


Dan



Return to posts index
Reply   Like  

Dan KellyRe: Mask Path expression
by on Aug 9, 2012 at 2:54:33 pm

Thanks Dan,

Started my quest on your site, small world! I pasted into the Mask Opacity expression but no go. Mask opacity stays at 100. Am I missing something?



Return to posts index
Reply   Like  


Dan EbbertsRe: Mask Path expression
by 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?

Dan



Return to posts index
Reply   Like  

Dan KellyRe: Mask Path expression
by on Aug 9, 2012 at 3:23:35 pm

[Dan Ebberts] "The expression should give you 100% if the path has any keyframes. Is that what you wanted?"


opacity = 100 when there is a mask path keyframe and 0 when there is not, for every frame.

CS6 has issues with paste mocha mask which is why I'm working in CS 5.5 for now. I'll try in 6.0...


Return to posts index
Reply   Like  

Dan EbbertsRe: Mask Path expression
by on Aug 9, 2012 at 3:34:26 pm

> for every frame.

Do you mean that you only want the opacity to be 100% at frames that have corresponding keyframes on the path?

Dan



Return to posts index
Reply   Like  


Dan KellyRe: Mask Path expression
by on Aug 9, 2012 at 3:48:51 pm

Yes! and 0 when there are no keyframes on the path.

The functionality I need is to have the absence/presence/absence of Mask Path keyframes flip opacity of the mask from 0 to 100 to 0.


Return to posts index
Reply   Like  

Dan EbbertsRe: Mask Path expression
by 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?

Dan



Return to posts index
Reply   Like  

Dan KellyRe: Mask Path expression
by 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.


Return to posts index
Reply   Like  


Dan EbbertsRe: Mask Path expression
by on Aug 9, 2012 at 4:17:42 pm

Try this:


p = thisProperty.propertyGroup(1).maskPath;
if (p.numKeys > 0){
t1 = p.key(1).time;
t2 = p.key(p.numKeys).time;
if (time >= t1 && time <= t2) 100 else 0
}else
0



Dan



Return to posts index
Reply   Like  

Dan KellyRe: Mask Path expression
by on Aug 9, 2012 at 4:30:08 pm

Works like a charm Dan. If you had any sticky karma, it's just went up in smoke.

I'm gonna look this expression over and maybe ask some questions about how it works later today.

Big thanks!

Dan Kelly


Return to posts index
Reply   Like  

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
Share on Facebook


FORUMSTUTORIALSFEATURESVIDEOSPODCASTSEVENTSSERVICESNEWSLETTERNEWSBLOGS

Creative COW LinkedIn Group Creative COW Facebook Page Creative COW on Twitter
© 2013 CreativeCOW.net All rights are reserved. - Privacy Policy

[Top]