43 lines
1.3 KiB
Python
43 lines
1.3 KiB
Python
import pathlib
|
|
import sys
|
|
|
|
import bpy
|
|
|
|
|
|
def main(output_path):
|
|
bpy.ops.wm.read_factory_settings(use_empty=True)
|
|
mask = bpy.data.masks.new("WebMask")
|
|
layer = mask.layers.new(name="WebMaskLayer")
|
|
layer.alpha = 0.625
|
|
layer.hide_select = True
|
|
spline = layer.splines.new()
|
|
spline.use_cyclic = True
|
|
spline.use_fill = False
|
|
spline.points.add(2)
|
|
|
|
values = [
|
|
((0.1, 0.2), (0.0, 0.2), (0.2, 0.2), "ALIGNED", 0.25, True),
|
|
((0.5, 0.7), (0.4, 0.7), (0.6, 0.7), "VECTOR", 0.5, False),
|
|
((0.8, 0.3), (0.7, 0.3), (0.9, 0.3), "FREE", 0.75, True),
|
|
]
|
|
for point, value in zip(spline.points, values):
|
|
co, left, right, handle_type, weight, selected = value
|
|
point.co = co
|
|
point.handle_left = left
|
|
point.handle_right = right
|
|
point.handle_type = handle_type
|
|
point.weight = weight
|
|
point.select = selected
|
|
|
|
path = pathlib.Path(output_path).resolve()
|
|
path.parent.mkdir(parents=True, exist_ok=True)
|
|
bpy.ops.wm.save_as_mainfile(filepath=str(path), compress=False)
|
|
print(f"mask-fixture-generated path={path} points={len(spline.points)}")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
arguments = sys.argv[sys.argv.index("--") + 1:]
|
|
if len(arguments) != 1:
|
|
raise SystemExit("usage: blender -b --python generate-mask-fixture.py -- output.blend")
|
|
main(arguments[0])
|