35 lines
1014 B
Python
35 lines
1014 B
Python
#!/usr/bin/env python3
|
|
import pathlib
|
|
import sys
|
|
|
|
import bpy
|
|
|
|
|
|
ACTION_NAME = "WebGapAssignAction"
|
|
OBJECT_NAME = "WebGapAssignActionObject"
|
|
|
|
|
|
def main():
|
|
arguments = sys.argv[sys.argv.index("--") + 1 :]
|
|
if len(arguments) != 1:
|
|
raise SystemExit("usage: blender -b --factory-startup --python M16-GAP-00266.py -- OUTPUT")
|
|
bpy.ops.wm.read_factory_settings(use_empty=True)
|
|
obj = bpy.data.objects.new(OBJECT_NAME, None)
|
|
bpy.context.scene.collection.objects.link(obj)
|
|
for frame, x in ((1, 0.0), (5, 2.0)):
|
|
obj.location.x = x
|
|
obj.keyframe_insert(data_path="location", index=0, frame=frame)
|
|
action = obj.animation_data.action
|
|
action.name = ACTION_NAME
|
|
action.use_fake_user = 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()
|