Files
workinf_Blender_Wasm/tools/web/check-action-channels-group-desktop.py
mes123456 46c9ebfcb6
Some checks failed
M6 deployable RC / quick (push) Has been cancelled
M6 deployable RC / chromium (push) Has been cancelled
M6 deployable RC / release (push) Has been cancelled
Capture M16 gap execution artifacts
2026-08-21 21:09:40 -04:00

74 lines
3.0 KiB
Python

#!/usr/bin/env python3
import hashlib
import json
import os
import pathlib
import sys
import tempfile
import bpy
def action_report():
obj = bpy.data.objects.get("WebGapAnimChannelsGroupObject")
if obj is None or obj.animation_data is None or obj.animation_data.action is None:
raise RuntimeError("WebGapAnimChannelsGroupObject Action is missing")
action = obj.animation_data.action
groups = []
channels = []
for layer in action.layers:
for strip in layer.strips:
for bag in strip.channelbags:
groups.extend(group.name for group in bag.groups)
for curve in bag.fcurves:
channels.append({
"path": curve.data_path,
"index": curve.array_index,
"frames": [round(float(keyframe.co.x), 6) for keyframe in curve.keyframe_points],
"group": curve.group.name if curve.group else None,
})
channels.sort(key=lambda value: (value["path"], value["index"]))
return {"name": action.name, "groups": sorted(groups), "channels": channels}
def main():
arguments = sys.argv[sys.argv.index("--") + 1 :]
if len(arguments) != 2:
raise SystemExit("usage: blender -b --python check-action-channels-group-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 = action_report()
expected = [1.0, 3.0, 5.0]
if before["name"] != "WebGapAnimChannelsGroupObjectAction" or before["groups"] != ["WebGapTransforms"]:
raise RuntimeError(f"unexpected anim.channels_group groups: {before}")
if len(before["channels"]) != 3 or any(channel["frames"] != expected or channel["group"] != "WebGapTransforms" for channel in before["channels"]):
raise RuntimeError(f"unexpected anim.channels_group channels: {before}")
descriptor, temporary = tempfile.mkstemp(prefix="m16-anim-channels-group-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 = action_report()
finally:
pathlib.Path(temporary).unlink(missing_ok=True)
if before != after:
raise RuntimeError("anim.channels_group save/reopen drift")
report = {
"schemaVersion": 1,
"task": "M16-GAP-00161",
"operation": "ANIM_CHANNELS_GROUP_DESKTOP",
"fixture": str(fixture),
"fixtureSha256": hashlib.sha256(fixture.read_bytes()).hexdigest(),
"groups": 1,
"action": 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("anim-channels-group-desktop-ok group=WebGapTransforms channels=3 saveReopen=exact")
if __name__ == "__main__":
main()