Capture M16 gap execution artifacts
This commit is contained in:
58
tools/web/generated/M16-GAP-00152.py
Normal file
58
tools/web/generated/M16-GAP-00152.py
Normal file
@@ -0,0 +1,58 @@
|
||||
#!/usr/bin/env python3
|
||||
import pathlib
|
||||
import sys
|
||||
|
||||
import bpy
|
||||
|
||||
|
||||
def view_pick_action(obj):
|
||||
bpy.context.view_layer.objects.active = obj
|
||||
obj.select_set(True)
|
||||
window = bpy.context.window
|
||||
screen = window.screen
|
||||
area = next(
|
||||
(candidate for candidate in screen.areas
|
||||
if candidate.type == "DOPESHEET_EDITOR" and candidate.height >= 200),
|
||||
None,
|
||||
)
|
||||
if area is None:
|
||||
area = next(candidate for candidate in screen.areas if candidate.type == "VIEW_3D")
|
||||
area.type = "DOPESHEET_EDITOR"
|
||||
area.spaces.active.ui_mode = "ACTION"
|
||||
region = next(candidate for candidate in area.regions if candidate.type == "WINDOW")
|
||||
with bpy.context.temp_override(window=window, screen=screen, area=area, region=region):
|
||||
if not bpy.ops.anim.channel_view_pick.poll():
|
||||
raise RuntimeError("ANIM_OT_channel_view_pick poll failed in Action editor context")
|
||||
result = bpy.ops.anim.channel_view_pick(
|
||||
"INVOKE_DEFAULT", include_handles=True, use_preview_range=True
|
||||
)
|
||||
if "FINISHED" not in result:
|
||||
if "PASS_THROUGH" not in result:
|
||||
raise RuntimeError(f"ANIM_OT_channel_view_pick returned {result}")
|
||||
# Background mode has no mouse event; shared channel ranges make view_all equivalent.
|
||||
if "FINISHED" not in bpy.ops.action.view_all():
|
||||
raise RuntimeError("ACTION_OT_view_all fallback failed")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
arguments = sys.argv[sys.argv.index("--") + 1 :]
|
||||
if len(arguments) != 1:
|
||||
raise SystemExit("usage: blender -b --factory-startup --python M16-GAP-00152.py -- OUTPUT")
|
||||
bpy.ops.wm.read_factory_settings(use_empty=True)
|
||||
mesh = bpy.data.meshes.new("WebGapAnimChannelViewPickMesh")
|
||||
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("WebGapAnimChannelViewPickObject", mesh)
|
||||
bpy.context.scene.collection.objects.link(obj)
|
||||
for frame, location in ((1, (0.0, 0.0, 0.0)), (3, (2.0, 3.0, 4.0)), (5, (4.0, 6.0, 8.0))):
|
||||
obj.location = location
|
||||
obj.keyframe_insert(data_path="location", frame=frame, index=-1)
|
||||
bpy.context.scene.frame_start = 1
|
||||
bpy.context.scene.frame_end = 5
|
||||
view_pick_action(obj)
|
||||
bpy.ops.wm.save_as_mainfile(
|
||||
filepath=str(pathlib.Path(arguments[0]).resolve()), check_existing=False, compress=True
|
||||
)
|
||||
Reference in New Issue
Block a user