Continue Blender Web parity task handoff
This commit is contained in:
54
tools/web/generated/M16-GAP-00202.py
Normal file
54
tools/web/generated/M16-GAP-00202.py
Normal file
@@ -0,0 +1,54 @@
|
||||
#!/usr/bin/env python3
|
||||
import pathlib
|
||||
import sys
|
||||
|
||||
import bpy
|
||||
|
||||
|
||||
OLD_ACTION = "WebGapAnimReplaceOldAction"
|
||||
NEW_ACTION = "WebGapAnimReplaceNewAction"
|
||||
|
||||
|
||||
def make_object(name, action, property_name, values):
|
||||
mesh = bpy.data.meshes.new(f"{name}Mesh")
|
||||
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(name, mesh)
|
||||
bpy.context.scene.collection.objects.link(obj)
|
||||
obj.animation_data_create()
|
||||
obj.animation_data.action = action
|
||||
for frame, value in zip((1, 3, 5), values):
|
||||
obj[property_name] = value
|
||||
obj.keyframe_insert(data_path=f'["{property_name}"]', frame=frame)
|
||||
return obj
|
||||
|
||||
|
||||
def main():
|
||||
arguments = sys.argv[sys.argv.index("--") + 1 :]
|
||||
if len(arguments) != 1:
|
||||
raise SystemExit("usage: blender -b --factory-startup --python M16-GAP-00202.py -- OUTPUT")
|
||||
bpy.ops.wm.read_factory_settings(use_empty=True)
|
||||
old_action = bpy.data.actions.new(OLD_ACTION)
|
||||
new_action = bpy.data.actions.new(NEW_ACTION)
|
||||
old_a = make_object("WebGapAnimReplaceOldA", old_action, "replace_target", (1.0, 3.0, 5.0))
|
||||
old_b = make_object("WebGapAnimReplaceOldB", old_action, "replace_target", (2.0, 4.0, 6.0))
|
||||
new_user = make_object("WebGapAnimReplaceNewUser", new_action, "replace_target", (10.0, 30.0, 50.0))
|
||||
old_action.use_fake_user = True
|
||||
new_action.use_fake_user = True
|
||||
bpy.context.view_layer.objects.active = old_a
|
||||
old_a.select_set(True)
|
||||
old_b.select_set(False)
|
||||
new_user.select_set(False)
|
||||
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()
|
||||
Reference in New Issue
Block a user