2
$\begingroup$

I'm using Blender 2.78 and playing around with making different video transition effects. I want to automate the dynamics of a mask layer(rectangle as seen below) and it all work fine if I add keyframe>move rectangle>add keyframe however facing a hard time in finding how I could manipulate the position of the rectangle from the scripts. Already tried to work with bpy.ops.transform, bpy.data.masks['Mask bar'].layers.active.select but it seems that none of them has a member or function that gives me access to the position of the rectangle.

Not after something big, just couple of pointers on what object would store the data I'm after. enter image description here

$\endgroup$

1 Answer 1

2
$\begingroup$

I don't think you can get the position of the mask as a whole, but you can access the coordinates of each individual point of the mask.

You can access the mask with:

bpy.data.masks['Mask']

And then the layer within the mask:

bpy.data.masks['Mask'].layers['MaskLayer']

Then you have access to the splines in that layer, which are the curves of the mask. In this case I am accessing the first spline:

bpy.data.masks['Mask'].layers['MaskLayer'].splines[0]

Which then leads you to the spline's points. The points have a vector called co (coordinates) which store the x and y position of that point. By looping over all the points in the mask and altering the co[0](x) or co[1](y) you can move the mask:

mask = bpy.data.masks['Mask'].layers['MaskLayer'].splines[0]
for point in mask.points:
    point.co[0] += 0.1
$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .