Activity › Forums › Adobe After Effects › ExtendScript Toolkit – After Effects
-
ExtendScript Toolkit – After Effects
Posted by Krishna Moorthy on November 3, 2016 at 5:22 pmNewbie seeking for help!!!
Am developing a script for my own usage in which I have to enable track matte for a layer through ExtendScript. I had searched the after effects scripting guide and I couldn’t find how to enable track matte for a layer. The options in the guide are trackMatteType, isTrackMatte, hasTrackMatte. These attributes can change the tack matte type, check whether track matte is on or not, did the layer has track matte or not respectively. Kindly, help me how can I enable track matte of a layer via extendscript.
Thanks in advance!
Walter Soykareplied 2 weeks, 1 day ago 3 Members · 7 Replies -
7 Replies
-
Walter Soyka
November 3, 2016 at 11:04 pmUse trackMatteType like this to set layer 2 in the active comp to use layer 1 as a luma track matte:
app.project.activeItem.layers[2].trackMatteType = TrackMatteType.LUMA;
These are the possible track matte types:
TrackMatteType.ALPHA
TrackMatteType.ALPHA_INVERTED
TrackMatteType.LUMA
TrackMatteType.LUMA_INVERTED
TrackMatteType.NO_TRACK_MATTEWalter Soyka
Designer & Mad Scientist at Keen Live [link]
Motion Graphics, Widescreen Events, Presentation Design, and Consulting
@keenlive | RenderBreak [blog] | Profile [LinkedIn] -
Krishna Moorthy
November 4, 2016 at 5:19 amThank you for your quick response Walter.
That’s what I am looking for.
Found that you are replying in most of the posts here. Great work! keep it up!!
Once again, Thank you! -
Krishna Moorthy
November 4, 2016 at 12:03 pmHaving a another doubt in the same project that I am working on!
Now, its for a shape layer which will be the track matte for the layer below it.
I have created a shape layer and added a rectangle using the code below.
var shapeLayer = pipComp.layers.addShape();
var contents = shapeLayer.property("ADBE Root Vectors Group");
shapeRect = contents.addProperty("ADBE Vector Shape - Rect");Now, to make this as a track matte for the layer below it, the shape layer should have a fill property. So, when I added a Fill property to the shape layer by using this
shapeFill = contents.addProperty("ADBE Vector Graphic - Fill");
line of code below the above lines of code, the ESTK throws an error at this particular line stating, “Object is invalid”.But if I place the shapeFill line above the shapeRect line, it works fine as it creates a shape layer with Fill and Rectangle property one after another. But we need the Rectangle property in the top so that the Fill property will be visible.
I hope I explained my situation clearly. kindly, help me to crack this out.
Thanks in advance.
-
Walter Soyka
November 4, 2016 at 12:59 pmYour code:
var shapeLayer = pipComp.layers.addShape();
var contents = shapeLayer.property("ADBE Root Vectors Group");
shapeRect = contents.addProperty("ADBE Vector Shape - Rect");
shapeFill = contents.addProperty("ADBE Vector Graphic - Fill");Works fine here.
Walter Soyka
Designer & Mad Scientist at Keen Live [link]
Motion Graphics, Widescreen Events, Presentation Design, and Consulting
@keenlive | RenderBreak [blog] | Profile [LinkedIn] -
Krishna Moorthy
November 4, 2016 at 1:55 pmOops! Sorry for the inconvenience, I think, I had addressed the problem wrongly. Here is actual problem (really).
1 var shapeLayer = pipComp.layers.addShape();
2 var contents = shapeLayer.property("ADBE Root Vectors Group");
3 var shapeRect = contents.addProperty("ADBE Vector Shape - Rect");
4 var shapeFill = contents.addProperty("ADBE Vector Graphic - Fill");
5 var rectSize = shapeRect.property("ADBE Vector Rect Size");
6 var rectPosition = shapeRect.property("ADBE Vector Rect Position");
7 var rectRoundness = shapeRect.property("ADBE Vector Rect Roundness");
8 rectSize.setValue ([600, 400]);
9 rectPosition.setValue([0.0, -90]);
10 rectRoundness.setValue(10);
11 pipComp.layers[2].trackMatteType = TrackMatteType.ALPHAESTK throws error at the 5th line of above code snippet. And the error is “Objects is invalid”.
The purpose of line 5 to 10 is to change the values of the shape layer.Thanks in advance!
-
James Smith
May 19, 2023 at 10:42 amHi Walter, this is an old post but just wondered if you knew whether it’s possible to set the layer for the trackMatte in the latest version of after effects. Previous versions always used the layer above, but you can now choose. Appreciate your advice, thanks in advance! 😃
-
Walter Soyka
May 23, 2023 at 10:15 pmYes, you use the new method .setTrackMatte(). It accepts two parameters: the layer to use as the track matte, and the track matte type. Here’s a very rough example:
app.project.activeItem.layer(2).setTrackMatte(app.project.activeItem.layer(3), TrackMatteType.ALPHA);
The track matte types are TrackMatteType.ALPHA, TrackMatteType.ALPHA_INVERTED, TrackMatteType.LUMA, TrackMatteType.LUMA_INVERTED, and TrackMatteType.NO_TRACK_MATTE.
You can remove a track matte from a layer with the .removeTrackMatte() method.
Reply to this Discussion! Login or Sign Up