#!/usr/bin/env python3 import hashlib import json import pathlib import sys import tempfile import os import bpy def report(): style = bpy.data.linestyles.get("WebGapLineStyle") if style is None: raise RuntimeError("WebGapLineStyle is missing") return {"name": style.name, "color": [round(float(v), 6) for v in style.color], "alpha": round(float(style.alpha), 6), "thickness": round(float(style.thickness), 6), "chaining": style.use_chaining, "dashed": style.use_dashed_line, "modifierCounts": {"color": len(style.color_modifiers), "alpha": len(style.alpha_modifiers), "thickness": len(style.thickness_modifiers), "geometry": len(style.geometry_modifiers)}} def main(): args = sys.argv[sys.argv.index("--") + 1:] if len(args) != 2: raise SystemExit("usage: blender -b --python check-freestyle-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-freestyle-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"Freestyle save/reopen drift: {before} != {after}") value = {"schemaVersion": 1, "task": "M16-GAP-00008", "operation": "FREESTYLE_LINE_STYLE_DESKTOP", "fixture": str(fixture), "fixtureSha256": hashlib.sha256(fixture.read_bytes()).hexdigest(), "lineStyle": 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"freestyle-desktop-ok name={after['name']} thickness={after['thickness']} saveReopen=exact") if __name__ == "__main__": main()