Activity › Forums › Adobe After Effects Expressions › BlendingMode global constant error
-
BlendingMode global constant error
Posted by Mark Boszko on December 10, 2013 at 1:23 amIf I put this line:
thisComp.layer(index).blendingMode = BlendingMode.NORMAL;…into any expression, or with any BlendingMode constant, After Effects CC (12.1.0.168) gives me the following error:
After Effects warning: property or method named ‘BlendingMode’ in Class ‘global’ is missing or does not exist. It may have been renamed, moved, deleted, or the name may have been mistyped. A property expression referencing it was disabled.
If I say something like
thisComp.layer(index).blendingMode = 4612;it works fine, so it seems it’s the global constantBlendingMode.NORMALthat’s triggering the error.Any ideas as to what’s going wrong here? I’ve looked in the CS6 scripting manual, and it still lists these constants as valid.
Thanks!
MBMark Boszko replied 12 years, 8 months ago 3 Members · 5 Replies -
5 Replies
-
Dan Ebberts
December 10, 2013 at 1:44 amAs far as I know, expressions don’t have access to the blendingMode attribute, or scripting’s BlendingMode constants. Your expression:
thisComp.layer(index).blendingMode = 4612;
doesn’t actually change the blending mode from say, Add, to Normal, does it?
I think it may just letting you declare a new attribute for the layer named blendingMode but I’d be surprised if you can do anything with it.
Dan
-
Jason Reinhardt
December 10, 2013 at 1:46 amHi Mark! Here’s what I believe your problem is – you’re trying to modify a property that can only be accessed via scripting, not expressions. I assume you’re pasting that code as an expression into a keyframable property like Position, Opacity, etc – an expression can only modify the property it’s attached to. In other words, an expression on the Position property can only modify that layer’s Position.
Some workarounds: write a script to perform the intended behavior, save it to your scripts folder, and run it via the Run Script File menu. Or, you could use the CC Composite or Compound Arithmetic scripts to achieve a similar effect.
EDIT: Looks like Dan got in before me while my post was awaiting moderation 🙂
-
Mark Boszko
December 10, 2013 at 6:33 pmOhhh! I thought those were valid for Expressions as well, but I see now. Thanks to both of you, Dan and Jason, for clearing that up!
I had it as part of a larger expression (listed below), hoping to switch the blending mode when the luminance of a particular sampleImage() dropped below a certain point.
Is there any way to do that as part of an expression, do you think? It doesn’t seem that I can attach an expression to the Blending Mode directly. Can I maybe use an expression to trigger a script to act on the sending layer? (A quick google search doesn’t reveal much in the way of helpful hints on that idea. Are scripts able to run during a render? Perhaps not. Sorry, I haven’t tried to script AE in ages, so I’m a little rusty.)
The only other suggestion I found (other than to purchase BCC Composite) is to have duplicate layers with the two blending modes and switch opacity on those via expressions. Which seems do-able, if a little clumsy. Just thought I’d ask if anyone else had a better idea before I implement that.
Thanks!
MarktargetLayer = thisComp.layer(thisLayer.index+1);
samplePoint = targetLayer.effect("Point Control")("Point");
sampleRadius = [5,5];
barColor = targetLayer.sampleImage(samplePoint, sampleRadius);
barLuminance = rgbToHsl(barColor)[2] * 255;if (barLuminance > 100) {
// Obviously, this doesn't work:
thisComp.layer(index).blendingMode = BlendingMode.NORMAL;
} else {
// This either:
thisComp.layer(index).blendingMode = BlendingMode.DARKEN;
}barColor
-
Jason Reinhardt
December 10, 2013 at 7:03 pmHi Mark! I hadn’t thought of using expressions to toggle the opacity of two layers of different blending modes, I agree that’s a little messy but it does sound like a workable solution.
You might want to play with the Compound Arithmetic effect, it performs some similar math to layer blending modes. If your two layers are the same size, you could put Compound Arithmetic on the bottom layer, set the top layer as your second source for the Compound Arithmetic effect, and then hide the top layer itself. You’re then able to keyframe the Operator property of the Compound Arithmetic effect on the bottom layer, which gives you access to blending mode-style operations like Multiply, Add, Darken, etc.
One thing to consider: the equivalent to the “Darken” blending mode is actually not the “Darken” Operator, it’s the “Minimum” Operator. Also, “Add” behaves differently, but Screen, Multiply, Overlay, etc should all work as intended.
I’m not sure this will work without precomping if you’ve got many layers in a stack you’re trying to affect all at once.
-
Mark Boszko
December 10, 2013 at 7:21 pmThanks! The layers aren’t the same size (the “bar” only covers a small portion of the image below), but that’s definitely an interesting idea to think about. Maybe for v.2 of this project.
Almost makes me wish that After Effects had a way to create an “instance” copy of a layer without the overhead of pre-comping.
Reply to this Discussion! Login or Sign Up