#!/usr/bin/env python3 import hashlib import json import os import pathlib import sys import tempfile import bpy def report_scene(): scene = bpy.context.scene cube = bpy.data.objects.get("WBV2P2005WorkflowCube") if cube is None or cube.type != "MESH": raise RuntimeError("WORKFLOW_INVALID: workflow fixture cube is missing") return { "sceneId": "scene:" + scene.name, "objectId": "object:" + cube.name, "meshId": "mesh:" + cube.data.name, "location": [round(float(value), 6) for value in cube.location], "vertexCount": len(cube.data.vertices), "faceCount": len(cube.data.polygons), } def main(): arguments = sys.argv[sys.argv.index("--") + 1 :] if len(arguments) != 2: raise SystemExit("usage: blender -b --python check-wbv2-p2-005-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 = report_scene() descriptor, temporary = tempfile.mkstemp(prefix="wbv2-p2-005-reopen-", suffix=".blend", dir=fixture.parent) 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 = report_scene() finally: pathlib.Path(temporary).unlink(missing_ok=True) if before != after: raise RuntimeError(f"WORKFLOW_INVALID: desktop save/reopen drift: {before} != {after}") value = { "schemaVersion": 1, "task": "WBV2-P2-005", "operation": "WORKFLOW_P0_USER_LOOP_DESKTOP", "fixtureSha256": hashlib.sha256(fixture.read_bytes()).hexdigest(), "scene": after, "saveReopen": "EXACT", "blenderVersion": bpy.app.version_string, } output.parent.mkdir(parents=True, exist_ok=True) output.write_text(json.dumps(value, indent=2, sort_keys=True) + "\n", encoding="utf-8") print("wbv2-p2-005-desktop-ok object=%s topology=cube saveReopen=exact" % after["objectId"]) if __name__ == "__main__": main()