Govern task context and advance execution pointer
This commit is contained in:
27
tools/web/check-armature-desktop.py
Normal file
27
tools/web/check-armature-desktop.py
Normal file
@@ -0,0 +1,27 @@
|
||||
#!/usr/bin/env python3
|
||||
import hashlib
|
||||
import json
|
||||
import pathlib
|
||||
import sys
|
||||
import tempfile
|
||||
import os
|
||||
import bpy
|
||||
|
||||
def report():
|
||||
armature = next((value for value in bpy.data.armatures if value.name == "RiggedArmature"), None)
|
||||
if armature is None: raise RuntimeError("RiggedArmature is missing")
|
||||
return {"name": armature.name, "bones": [{"name": bone.name, "parent": bone.parent.name if bone.parent else None, "head": [round(float(v), 6) for v in bone.head_local], "tail": [round(float(v), 6) for v in bone.tail_local]} for bone in armature.bones]}
|
||||
|
||||
def main():
|
||||
args = sys.argv[sys.argv.index("--") + 1:]
|
||||
if len(args) != 2: raise SystemExit("usage: blender -b --python check-armature-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-armature-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"armature save/reopen drift: {before} != {after}")
|
||||
value = {"schemaVersion": 1, "task": "M16-GAP-00002", "operation": "ARMATURE_DATABLOCK_DESKTOP", "fixture": str(fixture), "fixtureSha256": hashlib.sha256(fixture.read_bytes()).hexdigest(), "armature": 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-desktop-ok bones={len(after['bones'])} saveReopen=exact")
|
||||
if __name__ == "__main__": main()
|
||||
Reference in New Issue
Block a user