42 lines
1.6 KiB
Python
42 lines
1.6 KiB
Python
#!/usr/bin/env python3
|
|
import pathlib
|
|
import sys
|
|
|
|
import bpy
|
|
|
|
|
|
OBJECT_NAME = "WebGapAnimKeyingSetPathRemoveObject"
|
|
ACTION_NAME = "WebGapAnimKeyingSetPathRemoveAction"
|
|
KEYING_SET_NAME = "WebGapAnimKeyingSetPathRemoveSet"
|
|
DATA_PATH = '["path_remove_target"]'
|
|
|
|
|
|
def main():
|
|
arguments = sys.argv[sys.argv.index("--") + 1 :]
|
|
if len(arguments) != 1:
|
|
raise SystemExit("usage: blender -b --factory-startup --python M16-GAP-00194.py -- OUTPUT")
|
|
bpy.ops.wm.read_factory_settings(use_empty=True)
|
|
mesh = bpy.data.meshes.new("WebGapAnimKeyingSetPathRemoveMesh")
|
|
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(OBJECT_NAME, mesh)
|
|
bpy.context.scene.collection.objects.link(obj)
|
|
obj["path_remove_target"] = 3.0
|
|
for frame, value in ((1, 1.0), (3, 3.0), (5, 5.0)):
|
|
bpy.context.scene.frame_set(frame)
|
|
obj["path_remove_target"] = value
|
|
obj.keyframe_insert(data_path=DATA_PATH, frame=frame)
|
|
obj.animation_data.action.name = ACTION_NAME
|
|
keying_set = bpy.context.scene.keying_sets.new(idname=KEYING_SET_NAME, name=KEYING_SET_NAME)
|
|
keying_set.paths.add(obj, DATA_PATH, index=0)
|
|
bpy.context.scene.keying_sets.active_index = 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(3)
|
|
bpy.ops.wm.save_as_mainfile(filepath=str(pathlib.Path(arguments[0]).resolve()), check_existing=False, compress=True)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|