29 lines
981 B
Python
29 lines
981 B
Python
import sys
|
|
|
|
import bpy
|
|
|
|
|
|
def main(output_path: str) -> None:
|
|
bpy.ops.wm.read_factory_settings(use_empty=True)
|
|
mesh = bpy.data.meshes.new("AnimationMesh")
|
|
mesh.from_pydata([(-1.0, -1.0, 0.0), (1.0, -1.0, 0.0), (0.0, 1.0, 0.0)], [], [(0, 1, 2)])
|
|
obj = bpy.data.objects.new("AnimatedObject", mesh)
|
|
bpy.context.collection.objects.link(obj)
|
|
|
|
obj.location = (0.0, 0.0, 0.0)
|
|
obj.keyframe_insert(data_path="location", frame=1, index=-1)
|
|
obj.location = (2.0, 3.0, 4.0)
|
|
obj.keyframe_insert(data_path="location", frame=10, index=-1)
|
|
|
|
scene = bpy.context.scene
|
|
scene.frame_start = 1
|
|
scene.frame_end = 10
|
|
scene.frame_set(1)
|
|
bpy.ops.wm.save_as_mainfile(filepath=output_path, compress=True)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
if "--" not in sys.argv or len(sys.argv) <= sys.argv.index("--") + 1:
|
|
raise SystemExit("usage: blender -b --python generate-animation-fixture.py -- output.blend")
|
|
main(sys.argv[sys.argv.index("--") + 1])
|