#!/usr/bin/env python3 import hashlib import json import pathlib import sys import tempfile import os import bpy def report(): curve = bpy.data.curves.get("WebGapCurve") if curve is None: raise RuntimeError("WebGapCurve is missing") return {"name": curve.name, "dimensions": curve.dimensions, "resolution": curve.resolution_u, "splines": [{"type": s.type, "count": len(s.bezier_points) if s.type == "BEZIER" else len(s.points), "cyclic": s.use_cyclic_u} for s in curve.splines], "points": [[round(float(v), 6) for v in point.co] for s in curve.splines if s.type == "BEZIER" for point in s.bezier_points]} def main(): args = sys.argv[sys.argv.index("--") + 1:] if len(args) != 2: raise SystemExit("usage: blender -b --python check-curve-desktop.py -- FIXTURE REPORT") fixture, output = (pathlib.Path(value).resolve() for value in args) bpy.ops.wm.open_mainfile(filepath=str(fixture), load_ui=False); before = report(); descriptor, temporary = tempfile.mkstemp(prefix="m16-curve-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=False); after = report() finally: pathlib.Path(temporary).unlink(missing_ok=True) if before != after: raise RuntimeError(f"curve save/reopen drift: {before} != {after}") value = {"schemaVersion": 1, "task": "M16-GAP-00006", "operation": "CURVE_DATABLOCK_DESKTOP", "fixture": str(fixture), "fixtureSha256": hashlib.sha256(fixture.read_bytes()).hexdigest(), "curve": 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(f"curve-desktop-ok splines={len(after['splines'])} points={len(after['points'])} saveReopen=exact") if __name__ == "__main__": main()