#!/usr/bin/env python3 import hashlib import json import os import pathlib import sys import tempfile import bpy def report(): mesh_object = bpy.data.objects.get("WebGapArmatureMeshObject") armature_object = bpy.data.objects.get("WebGapArmatureObject") if mesh_object is None or mesh_object.type != "MESH": raise RuntimeError("WebGapArmatureMeshObject is missing") if armature_object is None or armature_object.type != "ARMATURE": raise RuntimeError("WebGapArmatureObject is missing") modifiers = [modifier for modifier in mesh_object.modifiers if modifier.type == "ARMATURE"] if len(modifiers) != 1: raise RuntimeError(f"expected exactly one ARMATURE modifier, found {len(modifiers)}") modifier = modifiers[0] type_code = bpy.types.Modifier.bl_rna.properties["type"].enum_items[modifier.type].value return { "meshId": "mesh:" + mesh_object.data.name, "meshName": mesh_object.data.name, "armatureObjectId": "object:" + armature_object.name, "armatureDataId": "armature:" + armature_object.data.name, "modifier": { "name": modifier.name, "type": modifier.type, "typeCode": type_code, "enabled": bool(modifier.show_viewport), "showViewport": bool(modifier.show_viewport), "showRender": bool(modifier.show_render), "showEditMode": bool(modifier.show_in_editmode), "showOnCage": bool(modifier.show_on_cage), "vertexGroup": modifier.vertex_group, "targetObjectId": "object:" + modifier.object.name if modifier.object else None, }, } def main(): arguments = sys.argv[sys.argv.index("--") + 1 :] if len(arguments) != 2: raise SystemExit("usage: blender -b --python check-armature-modifier-desktop.py -- FIXTURE REPORT") fixture, output = (pathlib.Path(value).resolve() for value in arguments) bpy.ops.wm.open_mainfile(filepath=str(fixture), load_ui=False) before = report() descriptor, temporary = tempfile.mkstemp(prefix="m16-armature-modifier-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=False) after = report() finally: pathlib.Path(temporary).unlink(missing_ok=True) if before != after: raise RuntimeError(f"armature modifier save/reopen drift: {before} != {after}") value = { "schemaVersion": 1, "task": "M16-GAP-00030", "operation": "ARMATURE_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"armature-modifier-desktop-ok mesh={after['meshId']} modifier={after['modifier']['name']} saveReopen=exact") if __name__ == "__main__": main()