#!/usr/bin/env python3 import hashlib, json, os, pathlib, sys, tempfile import bpy def report(): obj = bpy.data.objects.get("WebGapClothObject") if obj is None: raise RuntimeError("WebGapClothObject is missing") modifiers = [m for m in obj.modifiers if m.type == "CLOTH"] if len(modifiers) != 1: raise RuntimeError(f"expected one CLOTH modifier, found {len(modifiers)}") m = modifiers[0] return {"meshId": "mesh:" + obj.data.name, "modifier": {"name": m.name, "type": m.type, "typeCode": bpy.types.Modifier.bl_rna.properties["type"].enum_items[m.type].value, "showViewport": bool(m.show_viewport), "showRender": bool(m.show_render), "showEditMode": bool(m.show_in_editmode), "showOnCage": bool(m.show_on_cage)}} def main(): args = sys.argv[sys.argv.index("--") + 1:] if len(args) != 2: raise SystemExit("usage: blender -b --python check-cloth-modifier-desktop.py -- FIXTURE REPORT") fixture, output = (pathlib.Path(v).resolve() for v in args) bpy.ops.wm.open_mainfile(filepath=str(fixture), load_ui=False); before = report() fd, temporary = tempfile.mkstemp(prefix="m16-cloth-modifier-reopen-", suffix=".blend", dir=fixture.parent); os.close(fd) 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"cloth modifier save/reopen drift: {before} != {after}") value = {"schemaVersion": 1, "task": "M16-GAP-00036", "operation": "CLOTH_MODIFIER_DESKTOP", "fixture": str(fixture), "fixtureSha256": hashlib.sha256(fixture.read_bytes()).hexdigest(), "modifier": 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"cloth-modifier-desktop-ok mesh={after['meshId']} saveReopen=exact") if __name__ == "__main__": main()