41 lines
2.3 KiB
Python
41 lines
2.3 KiB
Python
#!/usr/bin/env python3
|
|
import hashlib
|
|
import json
|
|
import os
|
|
import pathlib
|
|
import sys
|
|
import tempfile
|
|
|
|
import bpy
|
|
|
|
|
|
def nla_report():
|
|
obj = bpy.data.objects.get("WebGapPushDownObject")
|
|
if obj is None or obj.animation_data is None:
|
|
raise RuntimeError("WebGapPushDownObject animation data is missing")
|
|
tracks = []
|
|
for track in obj.animation_data.nla_tracks:
|
|
tracks.append({"name": track.name, "strips": [{"name": strip.name, "action": strip.action.name if strip.action else None, "frameStart": round(float(strip.frame_start), 6), "frameEnd": round(float(strip.frame_end), 6)} for strip in track.strips]})
|
|
return {"activeAction": obj.animation_data.action.name if obj.animation_data.action else None, "tracks": tracks}
|
|
|
|
|
|
def main():
|
|
arguments = sys.argv[sys.argv.index("--") + 1:]
|
|
if len(arguments) != 2:
|
|
raise SystemExit("usage: blender -b --python check-action-push-down-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 = nla_report()
|
|
if before["activeAction"] is not None or len(before["tracks"]) != 1 or len(before["tracks"][0]["strips"]) != 1:
|
|
raise RuntimeError(f"unexpected action.push_down result: {before}")
|
|
descriptor, temporary = tempfile.mkstemp(prefix="m16-action-push-down-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 = nla_report()
|
|
finally: pathlib.Path(temporary).unlink(missing_ok=True)
|
|
if before != after: raise RuntimeError(f"action.push_down save/reopen drift: {before} != {after}")
|
|
report = {"schemaVersion": 1, "task": "M16-GAP-00132", "operation": "ACTION_PUSH_DOWN_DESKTOP", "fixture": str(fixture), "fixtureSha256": hashlib.sha256(fixture.read_bytes()).hexdigest(), "nla": after, "saveReopen": "EXACT", "blenderVersion": bpy.app.version_string}
|
|
output.parent.mkdir(parents=True, exist_ok=True); output.write_text(json.dumps(report, indent=2, sort_keys=True) + "\n", encoding="utf-8"); print("action-push-down-desktop-ok tracks=1 strips=1 activeAction=none saveReopen=exact")
|
|
|
|
|
|
if __name__ == "__main__": main()
|