Skip to main content
Participant
August 2, 2020
Answered

How to add mask by plugin?

  • August 2, 2020
  • 1 reply
  • 502 views

Hello, I am a newer to AE. I have some problem with plugin development.

I want to add masks by plugin. Just like Brush Tool, it has a independent  timeline and can be adjusted in every frame.  How to implement it by cpp code?

This topic has been closed for replies.
Correct answer nadav_rock

not sure what you want to do but if it helps this is a function to create a mask

 

 

 

 

 

// a= project item, b= layer
// c, vertice 1, x d= vertice 1 y= vertice 2 x, f= vertice 2 y g= vetrice 3 x, h= vertice 3 y, i = veirtice 4 x , j = vertice 4y
// h= feather

function mask_2(a346,b346,c346,d346,e346,f346,g346,h346,i346,j346){


var x346 = app.project.item(a346).layer(b346);
newMask346 = x346.Masks.addProperty("Mask");
myMaskShape346 = newMask346.property("maskShape");
myShape346 = myMaskShape346.value;
myShape346.vertices = [[c346,d346],[e346,f346],[g346,h346],[i346,j346]];
myShape346.closed = true;
myMaskShape346.setValue(myShape346);
app.project.item(a346).layer(b346).property("Masks").property(1).property("Mask Feather").setValueAtTime([0], [h346/10,h346/10]);


}


mask_2(2,2,100,100,200,100,200,200,100,200,20)

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

1 reply

nadav_rock
nadav_rockCorrect answer
Inspiring
August 3, 2020

not sure what you want to do but if it helps this is a function to create a mask

 

 

 

 

 

// a= project item, b= layer
// c, vertice 1, x d= vertice 1 y= vertice 2 x, f= vertice 2 y g= vetrice 3 x, h= vertice 3 y, i = veirtice 4 x , j = vertice 4y
// h= feather

function mask_2(a346,b346,c346,d346,e346,f346,g346,h346,i346,j346){


var x346 = app.project.item(a346).layer(b346);
newMask346 = x346.Masks.addProperty("Mask");
myMaskShape346 = newMask346.property("maskShape");
myShape346 = myMaskShape346.value;
myShape346.vertices = [[c346,d346],[e346,f346],[g346,h346],[i346,j346]];
myShape346.closed = true;
myMaskShape346.setValue(myShape346);
app.project.item(a346).layer(b346).property("Masks").property(1).property("Mask Feather").setValueAtTime([0], [h346/10,h346/10]);


}


mask_2(2,2,100,100,200,100,200,200,100,200,20)

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Participant
August 4, 2020

Thank you for answer. I have found the solution.