Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Mask.maskFeather variable

  • Mask.maskFeather variable

    Posted by Nicolas Elsig on May 10, 2010 at 8:13 am

    Hello,

    is there a way to set the value of the mask feather in the following script … I tried a lot of different ways, but I’m just starting AE scripting and I’m totaly lost.

    Thank you for your help

    function convert3DToMask(){

    var currentComp = app.project.activeItem;
    var selectedLayers = currentComp.selectedLayers;
    var nbSelectedLayers = selectedLayers.length;
    var prefixS = "2Dmask_";
    var suffix = "";

    var newLayer;
    var currentLayer;
    var newName;
    var size = Number(solidSizeFld.text);

    if (app.project.activeItem.selectedLayers.length > 0)
    {

    for (var i = 0; i < nbSelectedLayers; i++)
    {
    currentLayer = selectedLayers[i];
    newName = prefixS + currentLayer.name + suffix;

    newLayer = currentComp.layers.addSolid([0,1.0,0], newName, size, size, 1);
    newLayer.name = newName;
    newMask = newLayer.Masks.addProperty("Mask");
    newMask.inverted = false;
    myMaskShape = newMask.property("maskShape");
    myShape = myMaskShape.value;
    myShape.vertices = [[size*0.25,size*0.25],[size*0.25,size*0.75],[size*0.75,size*0.75],[size*0.75,size*0.25]];
    myShape.closed = true;
    myMaskShape.setValue(myShape);

    expression = "L = thisComp.layer("" + currentLayer.name +"");L.toComp(L.anchorPoint);";
    newLayer.position.expression = expression;
    writeLn(currentLayer.name + " was converted to 2D mask");
    writeLn("with a size of : " + size);
    }
    }
    else
    {
    alert("Select 3d null layers to convert", "Warning", true);
    }
    }

    Nicolas Elsig replied 16 years, 2 months ago 2 Members · 2 Replies
  • 2 Replies
  • Dan Ebberts

    May 10, 2010 at 3:00 pm

    I haven’t tested it, but something like this should work:

    newMask.property(“maskFeather”).setValue([10,10]);

    Dan

  • Nicolas Elsig

    May 10, 2010 at 3:53 pm

    thank you !!! SO MUCH !
    I was trying this way :

    // myMaskFeather = newMask.property(“maskFeather”);
    // myMaskFeather.setValue(15);

    but it was always making errors… so thanks a lot and here’s my script
    (coded with feet… but for a first script I’m happy) It’s a tool to transform 3D locators from maya and syntheyes in my case to a 2D_null, a 2D_solid with a mask or a 2D_patch… the 2D patch is used to replicate and offset a small portion of a footage to erase the tracked markers.. simple but so usefull for the project I’m working on…

    I know there are a lot of improvments to be more powerfull :
    mask size is in percent but if you set under 50% it will invert the mask, as it is based on the vertex position.

    feel free to use it and improve it… (and share your feeedback) I think I will try to go further with my poor scripting skills. I will try to give the user the ability to bake the expression on the created objects position. And a second feature would be to translate it in french 🙂

    the link to download is : https://www.mokastudio.tv/data/moka3dto2d_v3.0.jsx.zip

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy