Files
workinf_Blender_Wasm/web/tests/fixtures/action-main-snapshots.py
mes123456 f3e21c6b98
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
chore: checkpoint web Blender migration source, tools and docs
Accumulated uncommitted work: GHOST Web backend, WebGL/GPU web layer,
web workflow engine and protocol, tooling, docs and task records.
Large generated evidence, user-testing archives, build snapshots and
imported test assets remain untracked.

Co-Authored-By: Claude Code <noreply@anthropic.com>
2026-11-10 11:18:01 +08:00

33 lines
1.9 KiB
Python

"""Read Action, keyframe and timeline-marker state from native saved Main files."""
import json
from pathlib import Path
import sys
import bpy
def curves_of(action):
curves = {}
try:
for curve in action.fcurves:
curves[(curve.data_path, curve.array_index)] = curve
except (AttributeError, RuntimeError):
pass
for layer in action.layers:
for strip in layer.strips:
for bag in getattr(strip, "channelbags", ()):
for curve in bag.fcurves:
curves[(curve.data_path, curve.array_index)] = curve
return [curves[key] for key in sorted(curves)]
directory = Path(sys.argv[sys.argv.index("--") + 1])
snapshots = {}
for file in sorted(directory.glob("*.blend")):
bpy.ops.wm.open_mainfile(filepath=str(file), load_ui=False)
actions = [{"name": action.name, "curves": [{"path": curve.data_path, "index": curve.array_index, "keys": [{"co": list(point.co), "left": list(point.handle_left), "right": list(point.handle_right), "leftType": point.handle_left_type, "rightType": point.handle_right_type, "interpolation": point.interpolation} for point in curve.keyframe_points]} for curve in curves_of(action)]} for action in sorted(bpy.data.actions, key=lambda item: item.name)]
objects = [{"name": obj.name, "action": obj.animation_data.action.name if obj.animation_data and obj.animation_data.action else None} for obj in sorted(bpy.data.objects, key=lambda item: item.name)]
scenes = [{"name": scene.name, "frame": scene.frame_current, "markers": [{"name": marker.name, "frame": marker.frame} for marker in sorted(scene.timeline_markers, key=lambda item: (item.frame, item.name))]} for scene in sorted(bpy.data.scenes, key=lambda item: item.name)]
snapshots[file.stem] = {"actions": actions, "objects": objects, "scenes": scenes}
(directory / "native-action-snapshots.json").write_text(json.dumps(snapshots, sort_keys=True, separators=(",", ":")), encoding="utf-8")