Create a new track matte
  • Hi all.
    I'v got this great little script that creates a trimmed solid above the selected layer.
    I do however want to set this new solid as a track mate for the layer underneath.
    anyone interested in taking this one step forward and creating a script that will do all that in one click?

    here is the script that do the create new trimmed solid:

    var proj = app.project;
    var undoStr = "Create Trimmed Solid";

    if (proj){
    var myComp = app.project.activeItem;
    if (myComp != null && (myComp instanceof CompItem)){
    app.beginUndoGroup(undoStr);
    var myLayers = myComp.selectedLayers;
    if (myLayers.length != 0) {
    var saveIn = myComp.duration;
    var saveOut = 0;
    var saveIndex = myComp.numLayers;
    var newInpoint=myComp.duration, newOutpoint=0, myIndex=myComp.numLayers;
    for (i=0; i <= myLayers.length-1; i++){
    currentLayer = myLayers[i];
    saveIn = (currentLayer.stretch < 0) ? currentLayer.outPoint : currentLayer.inPoint;
    saveOut = (currentLayer.stretch < 0) ? currentLayer.inPoint : currentLayer.outPoint;
    saveIndex = currentLayer.index;
    if (saveIn < newInpoint) {newInpoint = saveIn}
    if (saveOut > newOutpoint) {newOutpoint = saveOut}
    if (saveIndex < myIndex) {myIndex = saveIndex}
    }
    var solid = myComp.layers.addSolid([0,0,0],"Solid", myComp.width, myComp.height, myComp.pixelAspect, myComp.duration);
    solid.solid  = true; 
    solid.moveBefore(myComp.layer(myIndex+1));
    solid.inPoint = newInpoint;
    solid.outPoint = newOutpoint;
    app.endUndoGroup();
    } else {
    alert("Please select at least one layer");
    }
    } else {
    alert("Please select an active comp to use this script");
    }
    }
    else
    {
    alert("Please open a project first to use this script.");
    }