model/blend: drivers (object, object data, shape keys: variables, targets, keys, f-curve modifiers) and custom properties (objects, pose bones, bones) as data; f-curve modifiers on raw action curves; limit rotation use_legacy_behavior; 5.0 bone hide driver move for older files

This commit is contained in:
4DBug committed 2026-11-03 00:16:12 -06:00
1 parent b4e1ffebd4
commit a1a3971207
16 files changed
+2056 -605

No files matched your search

+52 -1
View File
@@ -177,6 +177,53 @@ def action_info(act):
return {"frame_range": [r6(act.frame_range[0]), r6(act.frame_range[1])], "curves": curves}
def props_info(owner):
out = {}
for k in owner.keys():
if k == "_RNA_UI":
continue
v = owner[k]
if hasattr(v, "to_dict"):
v = v.to_dict()
elif hasattr(v, "to_list"):
v = v.to_list()
out[k] = v
return out
MOD_KEYS = ("type", "mode", "use_additive", "coefficients", "poly_order", "mute", "influence", "use_influence",
"use_restricted_range", "frame_start", "frame_end", "blend_in", "blend_out")
def driver_info(fc):
d = fc.driver
variables = []
for v in d.variables:
targets = []
for t in v.targets:
targets.append({"id": t.id.name if t.id else "", "id_type": t.id_type, "data_path": t.data_path,
"bone_target": t.bone_target, "transform_type": t.transform_type,
"transform_space": t.transform_space, "rotation_mode": t.rotation_mode,
"context_property": t.context_property})
variables.append({"name": v.name, "type": v.type, "targets": targets})
mods = []
for m in fc.modifiers:
e = {}
for k in MOD_KEYS:
if hasattr(m, k):
e[k] = rna_value(getattr(m, k))
mods.append(e)
return {"data_path": fc.data_path, "array_index": fc.array_index, "extrapolation": fc.extrapolation,
"keys": [{"co": [r6(k.co[0]), r6(k.co[1])], "interpolation": k.interpolation} for k in fc.keyframe_points],
"driver": {"type": d.type, "expression": d.expression, "use_self": d.use_self, "variables": variables},
"modifiers": mods}
def drivers_of(idb):
ad = getattr(idb, "animation_data", None)
return [driver_info(fc) for fc in ad.drivers] if ad else []
def constraint_info(c):
out = {}
if c.type == "ARMATURE":
@@ -223,6 +270,8 @@ def rig_info(ob):
pose[k + a] = rna_value(getattr(pb, k + a))
for k in ("location", "rotation_quaternion", "rotation_euler", "rotation_axis_angle", "scale"):
pose[k] = rna_value(getattr(pb, k))
pose["props"] = props_info(pb)
pose["bone_props"] = props_info(b)
info = {}
for k in BONE_KEYS:
if hasattr(b, k):
@@ -266,7 +315,9 @@ def dump(path):
o = {"name": ob.name, "type": ob.type, "parent": ob.parent.name if ob.parent else "", "parent_type": ob.parent_type,
"parent_bone": ob.parent_bone, "world": [r6(x) for x in mat(ob.matrix_world)],
"collections": [c.name for c in ob.users_collection], "hide_viewport": ob.hide_viewport,
"hide_render": ob.hide_render}
"hide_render": ob.hide_render, "props": props_info(ob), "drivers": drivers_of(ob),
"data_drivers": drivers_of(ob.data) if ob.data is not None and ob.type in ("ARMATURE", "MESH") else [],
"shape_key_drivers": drivers_of(ob.data.shape_keys) if ob.type == "MESH" and ob.data.shape_keys else []}
if ob.type == "MESH":
o["mesh"] = mesh_info(ob)
if ob.animation_data and ob.animation_data.action: