82 lines
2.9 KiB
Python
82 lines
2.9 KiB
Python
#!/usr/bin/env python3
|
|
import hashlib
|
|
import json
|
|
import os
|
|
import pathlib
|
|
import sys
|
|
import tempfile
|
|
|
|
import bpy
|
|
|
|
|
|
def action_view_report():
|
|
screen = next((candidate for candidate in bpy.data.screens if candidate.name == "Animation"), bpy.context.screen)
|
|
area = next((candidate for candidate in screen.areas if candidate.type == "DOPESHEET_EDITOR"), None)
|
|
if area is None:
|
|
raise RuntimeError("Action Editor area is missing")
|
|
if area.spaces.active.ui_mode != "ACTION":
|
|
raise RuntimeError(f"unexpected Dopesheet mode: {area.spaces.active.ui_mode}")
|
|
region = next((candidate for candidate in area.regions if candidate.type == "WINDOW"), None)
|
|
if region is None:
|
|
raise RuntimeError("Action Editor window region is missing")
|
|
view = region.view2d
|
|
xmin, ymin = view.region_to_view(0, 0)
|
|
xmax, ymax = view.region_to_view(region.width - 1, region.height - 1)
|
|
return {
|
|
"areaType": area.type,
|
|
"uiMode": area.spaces.active.ui_mode,
|
|
"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 main():
|
|
arguments = sys.argv[sys.argv.index("--") + 1 :]
|
|
if len(arguments) != 2:
|
|
raise SystemExit("usage: blender -b --python check-action-view-all-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 = action_view_report()
|
|
descriptor, temporary = tempfile.mkstemp(prefix="m16-action-view-all-reopen-", suffix=".blend")
|
|
os.close(descriptor)
|
|
try:
|
|
bpy.ops.wm.save_as_mainfile(filepath=temporary, check_existing=False, compress=True)
|
|
bpy.ops.wm.open_mainfile(filepath=temporary, load_ui=True)
|
|
after = action_view_report()
|
|
finally:
|
|
pathlib.Path(temporary).unlink(missing_ok=True)
|
|
if before != after:
|
|
raise RuntimeError(f"action.view_all save/reopen drift: {before} != {after}")
|
|
report = {
|
|
"schemaVersion": 1,
|
|
"task": "M16-GAP-00147",
|
|
"operation": "ACTION_VIEW_ALL_DESKTOP",
|
|
"fixture": str(fixture),
|
|
"fixtureSha256": hashlib.sha256(fixture.read_bytes()).hexdigest(),
|
|
"action": after,
|
|
"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(
|
|
"action-view-all-desktop-ok area=DOPESHEET_EDITOR mode=ACTION "
|
|
"saveReopen=exact"
|
|
)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|