5180 posts
  • Elite Author: Sold more than $75,000 on Envato Market
  • Has sold $125,000+ on Envato Market
  • Helps us moderate the forums
  • Provided great contribution to our forums
+12 more
felt_tips Moderator says

i use the felt expression for the mask path:

t = effect(“Time”)(“Slider”).value; thisComp.layer(“Black Solid 1”).mask(“Mask 1”).maskPath.valueAtTime(t);

how i can animated a text number with the mask, example:

in the slider control i put 35 then a number is animated with the mask, is this possible?

can i use the number effect? or what?

Thanks

I don’t quite understand what you want to do…. have an animated number controlled by a slider, then mask that layer?

For the animated number, use a Text Layer. On its Source Text property:

tNum = thisComp.layer("Controller").effect("Number")("Slider").value;
tNum.toString();

Then you’d put the mask effect on a solid layer, put the solid layer above the text layer on the timeline and set the text layer’s track matte to “Alpha”. Bingo! Masked number.

387 posts
  • Has sold $40,000+ on Envato Market
  • Made it to the Authors' Hall of Fame
  • Joined an Envato Football competition
  • Has collected 50+ items on Envato Market
+3 more
motionvids says

So here we are again with some expression problems. I have this pre-comp which contains a solid, which contains multiple masks. Looks something like this: “Main Comp > Pre-comp > Solid Layer > Mask” And within my projects it is named as follows: “Main Comp > Circle Placeholder 1 > Mask Layer > Circle”

All I want to do is to turn on|off masks from a Checkbox Controller which is applied to the pre-comp.

I first got the mask to turn on and off by applying this expression on the ‘Mask Opacity’ of the mask itself and having the Checkbox Controller set on a different Null within the same pre-comp:

check =thisComp.layer("Null 1").effect("Checkbox Control")("Checkbox")
if(check==1){100} else {0}

So now I had exactly what I wanted but only downside was that I had to get inside the pre-comp to get to the Checkbox Control and be able to switch my masks on and off.

So I decided to put the Checkbox Controller on the pre-comp itself so I would no longer have to get in to the pre-comp to turn the masks on and off. And this is where all went wrong. I came up with this but it doesn’t do a thing:

check = thisLayer.effect("Checkbox Control")("Checkbox")
if(check==1)

{
comp("Circle Placeholder 1").layer("Mask Layer").mask("Circle").maskOpacity = 100
} 
else  (check==0)
{
comp("Circle Placeholder 1").layer("Mask Layer").mask("Circle").maskOpacity = 0
}

The expression gives no errors but it is simply not working. I figured that an expression can only change the value of the property that it is applied to, so I need to figure out another way to do this. However, I feel like my brain has just exploded, so I’m in need of your help!

387 posts
  • Has sold $40,000+ on Envato Market
  • Made it to the Authors' Hall of Fame
  • Joined an Envato Football competition
  • Has collected 50+ items on Envato Market
+3 more
motionvids says

I found a temporarily solution by applying the expression below on a Null Object(named “Shapes”) that is in the Main Comp together with all the pre-comps.

check = comp("Main Comp").layer("Shapes").effect("Checkbox Control")("Checkbox")
if(check==1){100} else {0}

But that would require me to make a Null Object for each different pre-comp.. which is not ideal!

5180 posts
  • Elite Author: Sold more than $75,000 on Envato Market
  • Has sold $125,000+ on Envato Market
  • Helps us moderate the forums
  • Provided great contribution to our forums
+12 more
felt_tips Moderator says

But that would require me to make a Null Object for each different pre-comp..

No it wouldn’t.

Your null object is your master controller layer, and you simply link the expression on each mask opacity to this same layer’s Checkbox effect.

By the way, you’re better off writing your expression like this… if you want to know why, read back through this thread…

check = comp("Main Comp").layer("Shapes").effect("Checkbox Control")("Checkbox").value;
if(check==1) 100; else 0; //you don't need the curly braces if the if and the else are a single line

That last line could also be written if(check) 100; else 0; or check?100:0; or check*100. If you use your previous version without the .value, that’s not possible.

387 posts
  • Has sold $40,000+ on Envato Market
  • Made it to the Authors' Hall of Fame
  • Joined an Envato Football competition
  • Has collected 50+ items on Envato Market
+3 more
motionvids says

No it wouldn’t.

Your null object is your master controller layer, and you simply link the expression on each mask opacity to this same layer’s Checkbox effect.

But that is the problem, I don’t need a master controller layer for all of my pre-comps, I want exactly the opposite. Each pre-comp contains a solid layer with 6 masks drawn on top of it. I want to be able to switch on|off a different mask for each of these pre-comps seperately by using Checkbox Controllers.

In example: For one pre-comp I need a circular shaped mask, for the other pre-comp I need a square shaped mask and for the third pre-comp I need a star shaped mask and so on.. Therefore I need each pre-comp to have its own Checkbox Controllers to match different shapes, so that I can turn on|off shape masks independently from each other.

These Checkbox Controllers(which are linked to the 6 mask shapes) are currently located on a Null Object outside of the pre-comp because I can’t get the Checkbox Controllers to work when they are on a pre-comp itself. This is because I think you can’t parent a layer to the pre-composition it is currently in, at least this was something I couldn’t get to work properly(if this is possible I would like to know).

Anyway I got it working with the Null Objects now, but it seems like an unnecessary extra step to me.

5180 posts
  • Elite Author: Sold more than $75,000 on Envato Market
  • Has sold $125,000+ on Envato Market
  • Helps us moderate the forums
  • Provided great contribution to our forums
+12 more
felt_tips Moderator says


No it wouldn’t.

Your null object is your master controller layer, and you simply link the expression on each mask opacity to this same layer’s Checkbox effect.

But that is the problem, I don’t need a master controller layer for all of my pre-comps, I want exactly the opposite. Each pre-comp contains a solid layer with 6 masks drawn on top of it. I want to be able to switch on|off a different mask for each of these pre-comps seperately by using Checkbox Controllers.

In example: For one pre-comp I need a circular shaped mask, for the other pre-comp I need a square shaped mask and for the third pre-comp I need a star shaped mask and so on.. Therefore I need each pre-comp to have its own Checkbox Controllers to match different shapes, so that I can turn on|off shape masks independently from each other.

These Checkbox Controllers(which are linked to the 6 mask shapes) are currently located on a Null Object outside of the pre-comp because I can’t get the Checkbox Controllers to work when they are on a pre-comp itself. This is because I think you can’t parent a layer to the pre-composition it is currently in, at least this was something I couldn’t get to work properly(if this is possible I would like to know).

Anyway I got it working with the Null Objects now, but it seems like an unnecessary extra step to me.

I have no idea what you’re talking about. Expressions are a very specific thing, so you have to be absolutely specific about what you are asking. You’ve got to remember, I’m not sitting in front of your project and I’m not telepathic.

Where do you want your controlling Expression Checkbox? You say you want it on a precomp. Expression Checkbox, Slider effects etc. are properties that exist under the Effect Property Group of a Layer Object and only a Layer Object.

You seem to be confused about Layers and Comps. You can’t parent a Layer to a Comp, you can only parent it to another Layer within the same Comp.

That means that you want your controlling Expression Properties either on a Layer Object whose source is the precomp in question, or you want your Expression Properties on a Null Layer Object inside the precomp in question. Either is possible.

I guess you want the controller on the Layer Object whose Layer Source is the pre-comp. If that Layer’s in comp “MAIN” and is called “A” and the effect is a Slider effect called “B”, then put the following onto the Mask Opacity of each mask…It’s actually irrelevant if the pre-comp is the source of Layer “A” or not… it’ll work either way.

//Get the Slider val. Make sure it's an integer
tSliderNum = parseInt(comp("MAIN").layer("A").effect("B")(1).value);
//Clamp it between 1 and the number of masks on this layer
tSliderNum = clamp(tSliderNum, 1, thisProperty.propertyGroup(2).numProperties);
//Get the Mask index of this Mask
myMaskIndex = thisProperty.propertyGroup(1).propertyIndex;
//If the Slider val is the same as the Mask index, show it, otherwise hide it
if(tSliderNum==myMaskIndex) 100; else 0;

When the Slider is 1, the first Mask will show, when the Slider is 2, the second etc. Is that what you’re on about?

If you change this line tSliderNum = clamp(tSliderNum, 1, thisProperty.propertyGroup(2).numProperties); to have 0 as its second argument instead of 1, then setting the Slider val to 0 or below will turn all Masks off.

5180 posts
  • Elite Author: Sold more than $75,000 on Envato Market
  • Has sold $125,000+ on Envato Market
  • Helps us moderate the forums
  • Provided great contribution to our forums
+12 more
felt_tips Moderator says

dbl post.

387 posts
  • Has sold $40,000+ on Envato Market
  • Made it to the Authors' Hall of Fame
  • Joined an Envato Football competition
  • Has collected 50+ items on Envato Market
+3 more
motionvids says

You seem to be confused about Layers and Comps. You can’t parent a Layer to a Comp, you can only parent it to another Layer within the same Comp.

That means that you want your controlling Expression Properties either on a Layer Object whose source is the precomp in question, or you want your Expression Properties on a Null Layer Object inside the precomp in question. Either is possible.

I was so confused that I did a terrible job at trying to explain my situation here. Sorry for being vague about this, but I was messing around for 3 hours straight and I got lost in my own world. Anyway this does answer my main question and validates what I was so unsure about.


//Get the Slider val. Make sure it's an integer
tSliderNum = parseInt(comp("MAIN").layer("A").effect("B")(1).value);
//Clamp it between 1 and the number of masks on this layer
tSliderNum = clamp(tSliderNum, 1, thisProperty.propertyGroup(2).numProperties);
//Get the Mask index of this Mask
myMaskIndex = thisProperty.propertyGroup(1).propertyIndex;
//If the Slider val is the same as the Mask index, show it, otherwise hide it
if(tSliderNum==myMaskIndex) 100; else 0;

Is that what you’re on about?

This is most certainly another and more efficient way of achieving the same thing I did with the Checkbox Controllers. I’ve now finally customized it to my requirements and now, as you clearly stated before ;), need only one Null Object for all the pre-comps.

Instead of having 6 Checkbox Controls for every pre-comp, it is now nicely replaced with 1 Slider Control per pre-comp.

And again, all thanks to you felt_tips. :)

147 posts
  • Has been part of the Envato Community for over 4 years
  • Has referred 1+ members
  • Has sold $10,000+ on Envato Market
  • Has collected 10+ items on Envato Market
+1 more
didgi says

Hi,

i’d like to add a Javascript button for ‘Empty Disk Cache’ in ft_Toolbar. Felt,do you know how to access this command via script?

5180 posts
  • Elite Author: Sold more than $75,000 on Envato Market
  • Has sold $125,000+ on Envato Market
  • Helps us moderate the forums
  • Provided great contribution to our forums
+12 more
felt_tips Moderator says

Hi, i’d like to add a Javascript button for ‘Empty Disk Cache’ in ft_Toolbar. Felt,do you know how to access this command via script?

Take your pick… but I’m not sure that any of them actually give you access to the disk cache. These would be more of a scripting way to access the menu items under Edit->Purge… But you never know, give ‘em a try :-)

If they don’t work, then I think there’s no current scripting access to disk cache at the moment. File a feature request!

// Purges all data that After Effects has cached to physical memory. 
target = PurgeTarget.ALL_CACHES; 

// Purges all data saved in the undo cache.
target = PurgeTarget.UNDO_CACHES;

// Purges all data cached as composition/layer snapshots.
target = PurgeTarget.SNAPSHOT_CACHES;

//Purges all saved image data.
target = PurgeTarget.IMAGE_CACHES; 

app.purge(target);

by
by
by
by
by
by