Files
workinf_Blender_Wasm/tools/web/check-action-scene-range-frame-desktop.py
mes123456 9f43244982
Some checks failed
M6 deployable RC / quick (push) Has been cancelled
M6 deployable RC / chromium (push) Has been cancelled
M6 deployable RC / release (push) Has been cancelled
Continue Blender Web parity task handoff
2026-08-23 05:47:21 -04:00

91 lines
3.9 KiB
Python

#!/usr/bin/env python3
import hashlib
import json
import os
import pathlib
import sys
import tempfile
import bpy
def view_report():
area = next((candidate for screen in bpy.data.screens for candidate in screen.areas if candidate.type == "DOPESHEET_EDITOR" and candidate.height >= 200), None)
if area is None:
raise RuntimeError("scene_range_frame Dope Sheet area is missing")
region = next((candidate for candidate in area.regions if candidate.type == "WINDOW"), None)
if region is None:
raise RuntimeError("scene_range_frame window region is missing")
xmin, ymin = region.view2d.region_to_view(0, 0)
xmax, ymax = region.view2d.region_to_view(region.width - 1, region.height - 1)
return {
"areaType": area.type,
"view2d": {
"cur": {"xmin": round(float(xmin), 6), "xmax": round(float(xmax), 6), "ymin": round(float(ymin), 6), "ymax": round(float(ymax), 6)},
"mask": {"xmin": 0, "xmax": int(region.width - 1), "ymin": 0, "ymax": int(region.height - 1)},
},
}
def frame_scene_range():
window = bpy.context.window
screen = window.screen
area = next(candidate for candidate in screen.areas if candidate.type == "DOPESHEET_EDITOR" and candidate.height >= 200)
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):
poll = bool(bpy.ops.anim.scene_range_frame.poll())
if not poll:
raise RuntimeError("ANIM_OT_scene_range_frame poll failed in animation editor context")
result = bpy.ops.anim.scene_range_frame()
if "FINISHED" not in result:
raise RuntimeError(f"ANIM_OT_scene_range_frame returned {result}")
return poll, result
def main():
arguments = sys.argv[sys.argv.index("--") + 1 :]
if len(arguments) != 2:
raise SystemExit("usage: blender -b --factory-startup --python check-action-scene-range-frame-desktop.py -- FIXTURE REPORT")
fixture, output = (pathlib.Path(value).resolve() for value in arguments)
bpy.ops.wm.open_mainfile(filepath=str(fixture), load_ui=True)
before = view_report()
poll, result = frame_scene_range()
after = view_report()
if before != after:
raise RuntimeError(f"scene_range_frame view drifted on repeat: {before} != {after}")
descriptor, temporary = tempfile.mkstemp(prefix="m16-anim-scene-range-frame-reopen-", suffix=".blend")
os.close(descriptor)
temporary_path = pathlib.Path(temporary)
try:
bpy.ops.wm.save_as_mainfile(filepath=str(temporary_path), check_existing=False, compress=True)
bpy.ops.wm.open_mainfile(filepath=str(temporary_path), load_ui=True)
reopened = view_report()
if reopened != after:
raise RuntimeError(f"anim.scene_range_frame save/reopen drift: {after} != {reopened}")
report = {
"schemaVersion": 1,
"task": "M16-GAP-00204",
"operation": "ANIM_SCENE_RANGE_FRAME_DESKTOP",
"fixture": str(fixture),
"fixtureSha256": hashlib.sha256(fixture.read_bytes()).hexdigest(),
"view": reopened,
"poll": poll,
"operatorStatus": "FINISHED" if "FINISHED" in result else sorted(result)[0],
"mainMutation": "VIEW_FRAMED_TO_SCENE_RANGE",
"saveReopen": "EXACT",
"blenderVersion": bpy.app.version_string,
}
output.parent.mkdir(parents=True, exist_ok=True)
output.write_text(json.dumps(report, indent=2, sort_keys=True) + "\n", encoding="utf-8")
print("anim-scene-range-frame-desktop-ok poll=true status=FINISHED mainMutation=view_framed saveReopen=exact")
finally:
temporary_path.unlink(missing_ok=True)
if __name__ == "__main__":
try:
main()
except Exception as error:
print(f"anim-scene-range-frame-desktop-failed: {error}")
raise SystemExit(1)