MaskShape Keyframes?

@GingerFinger can I ask what exactly do you need to do with the mask?, maybe if I understand I can help you better with this automation,
are you asking if it is possible to run this code (or any extendscript code) directly from ATK? (it is possible)

I can try recreate the mask shape window in scripting if you need it and it is important to you(but it will take some time)
I already recreated the ui (not the functionality)
image

Absolutely, sorry for being vague about it lol.
I do alot of roto work, and for me itā€™s faster to start the mask over again rather than moving the points
so what I do is, I put markers on the timeline where the frames update and I need to mask again
So basically I set a keyframe of the mask on the first marker, then put the same keyframe again before the next marker (could use hold keyframes but whatever), then to make the mask go out of frame, I set the shape to something random like 5000, or i can move the mask out of sight, but i find this faster
image
I marked the keyframes that are out of frame with red so you could better see it

Now you could say set the mask opacity to 0, but i donā€™t want to see the mask shape present all the time, it will be a jumbled mess
So if thereā€™re any alternative to my methods that can be easily automated, do let me know :smiley:

@GingerFinger Thanks for the detailed explanation!
now I can think of a simple solution (as you mentioned in your last post),
it will be simple to solve, because you donā€™t need to shape/change the mask in advanced way like the tool you are using, you just need it out of frame, and that is very simple to do with couple lines of code.

I will create an automation and post the result

just to be sure,
the automation should:

  1. create a keyframe with the current state of the selected mask path at the composition time indicator, and a matching keyframe 1 frame before the next marker.
  2. then create a keyframe 1 frame before the time indicator (the first keyframe from the last step), and move the mask out of frame, and a matching keyframe at the next marker time.

if the automation should work with more than 1 mask at a time please let me know how should it work

Yes so works for all masks in the layer
create one current state keyframe at playhead
then current state keyframe before the next marker
then 1 {out of bound} keyframe at the marker
then go back to the first keyframe, go one frame behind and make another {out of bound} keyframe
Pretty much what you said, yes :smiley:

Hi @GingerFinger ,
i finished the automation,
you need to enable ā€œAllow automation to run external javascript codeā€ (it is a safety major against running random javascript code from unsafe source).

i used your code with some little changes:

var time1 = variables["first_key_time"];
var time2 = variables["marker_time"];
var layer = variables["layer"];
var maskIndex = variables["mask_index"];

var maskPath = layer.Masks.property(maskIndex).property("Mask Path");
var myShape = maskPath.value;
myShape.vertices = [[10000,10000]];
myShape.inTangents = [];
myShape.outTangents = [];
myShape.closed = false;
maskPath.setValueAtTime( time1, myShape);
maskPath.setValueAtTime( time2, myShape);

as you can see, automation toolkit can send native variables values to the javascript code, so they work together hand to hand, it send time1 (first keyframe time), time2 (second keyframe time), layer (the current layer) and layer mask index (so we can know which mask should get the keyframes).
all the rest is your code.

to run this code I created a project variable, then I set which variables I want to send to the javascript code, then i could access them from the code.

2 additional things you might want to change,

  1. I move the time indicator at the end to the next marker (I thought it might be helpful but you can disable it).
  2. the automation work only on the selected masks and not all the mask (i created 2 versions).

selected masks -
set mask key 3.json (53.1 KB)

all masks -
set mask key 3 All.json (48.6 KB)

Hopes this work for you, finally :smiley:
Alon

It works great!
Finally this thing works haha I appreciate it man
Thank you so much! :smiley:

1 Like