39 lines
1.2 KiB
Python
39 lines
1.2 KiB
Python
#!/usr/bin/env python3
|
|
import pathlib
|
|
import sys
|
|
|
|
import bpy
|
|
|
|
|
|
def main():
|
|
arguments = sys.argv[sys.argv.index("--") + 1 :]
|
|
if len(arguments) != 1:
|
|
raise SystemExit("usage: blender -b --factory-startup --python M16-GAP-00199.py -- OUTPUT")
|
|
|
|
bpy.ops.wm.read_factory_settings(use_empty=True)
|
|
mesh = bpy.data.meshes.new("WebGapAnimPasteDriverButtonMesh")
|
|
mesh.from_pydata(
|
|
[(-1.0, -1.0, 0.0), (1.0, -1.0, 0.0), (1.0, 1.0, 0.0), (-1.0, 1.0, 0.0)],
|
|
[],
|
|
[(0, 1, 2, 3)],
|
|
)
|
|
obj = bpy.data.objects.new("WebGapAnimPasteDriverButtonObject", mesh)
|
|
bpy.context.scene.collection.objects.link(obj)
|
|
obj["source_target"] = 2.5
|
|
obj["paste_target"] = 7.5
|
|
source_driver = obj.driver_add('["source_target"]')
|
|
source_driver.driver.type = "SCRIPTED"
|
|
source_driver.driver.expression = "frame * 3.0 + 2.0"
|
|
bpy.context.view_layer.objects.active = obj
|
|
obj.select_set(True)
|
|
bpy.context.scene.frame_start = 1
|
|
bpy.context.scene.frame_end = 5
|
|
bpy.context.scene.frame_set(1)
|
|
bpy.ops.wm.save_as_mainfile(
|
|
filepath=str(pathlib.Path(arguments[0]).resolve()), check_existing=False, compress=True
|
|
)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|