model/blend: action / transform / stretch to / armature / floor / limit distance / track to / locked track constraint fields, copy scale add / uniform; bone inheritance and b-bone fields; stored pose basis; every action raw in meta.blend.actions (first layer / strip / channel bag for layered actions)

This commit is contained in:
4DBug committed 2026-11-02 23:18:18 -06:00
1 parent d1e2e25bdf
commit 56e1449b97
15 files changed
+1683 -560

No files matched your search

+41 -3
View File
@@ -131,7 +131,7 @@ def rna_value(v):
return ""
if isinstance(v, bpy.types.ID):
return v.name
if isinstance(v, bpy.types.PoseBone):
if isinstance(v, (bpy.types.PoseBone, bpy.types.Bone)):
return v.name
if isinstance(v, bool):
return v
@@ -151,8 +151,36 @@ SKIP = {"rna_type", "show_expanded", "active", "is_valid", "is_override_data_edi
"error_rotation", "targets", "space_object", "space_subtarget"}
BONE_KEYS = ("inherit_scale", "use_inherit_rotation", "use_local_location", "use_relative_parent", "bbone_segments",
"bbone_x", "bbone_z", "bbone_easein", "bbone_easeout", "bbone_rollin", "bbone_rollout", "bbone_curveinx",
"bbone_curveinz", "bbone_curveoutx", "bbone_curveoutz", "bbone_scalein", "bbone_scaleout",
"bbone_handle_type_start", "bbone_handle_type_end", "bbone_custom_handle_start", "bbone_custom_handle_end",
"use_endroll_as_inroll", "bbone_mapping_mode")
def action_fcurves(act):
if V >= (4, 4) and hasattr(act, "layers") and len(act.layers) > 0:
for strip in act.layers[0].strips:
for bag in strip.channelbags:
return list(bag.fcurves)
return []
return list(act.fcurves)
def action_info(act):
curves = []
for fc in action_fcurves(act):
keys = [{"co": [r6(k.co[0]), r6(k.co[1])], "interpolation": k.interpolation, "easing": k.easing,
"handle_left": [r6(k.handle_left[0]), r6(k.handle_left[1])],
"handle_right": [r6(k.handle_right[0]), r6(k.handle_right[1])]} for k in fc.keyframe_points]
curves.append({"data_path": fc.data_path, "array_index": fc.array_index, "extrapolation": fc.extrapolation, "keys": keys})
return {"frame_range": [r6(act.frame_range[0]), r6(act.frame_range[1])], "curves": curves}
def constraint_info(c):
out = {}
if c.type == "ARMATURE":
out["targets"] = [{"target": t.target.name if t.target else "", "subtarget": t.subtarget, "weight": r6(t.weight)} for t in c.targets]
for prop in c.bl_rna.properties:
k = prop.identifier
if k in SKIP or prop.type == "COLLECTION":
@@ -193,7 +221,13 @@ def rig_info(ob):
for a in "xyz":
for k in ("lock_ik_", "use_ik_limit_", "ik_min_", "ik_max_", "ik_stiffness_"):
pose[k + a] = rna_value(getattr(pb, k + a))
bones.append({"name": b.name, "head_local": [r6(x) for x in b.head_local], "tail_local": [r6(x) for x in b.tail_local],
for k in ("location", "rotation_quaternion", "rotation_euler", "rotation_axis_angle", "scale"):
pose[k] = rna_value(getattr(pb, k))
info = {}
for k in BONE_KEYS:
if hasattr(b, k):
info[k] = rna_value(getattr(b, k))
bones.append({"name": b.name, "head_local": [r6(x) for x in b.head_local], "tail_local": [r6(x) for x in b.tail_local], "bone": info,
"roll": r6(roll), "deform": b.use_deform, "use_connect": b.use_connect, "show_wire": b.show_wire,
"collections": [c.name for c in b.collections], "color": color_info(b.color), "pose": pose})
cols = [{"name": c.name, "visible": c.is_visible, "parent": c.parent.name if c.parent else ""} for c in arm.collections_all]
@@ -226,7 +260,8 @@ def dump(path):
ref = {"version": list(bpy.data.version), "fps": sc.render.fps / sc.render.fps_base, "frameStart": sc.frame_start,
"frameCurrent": sc.frame_current, "resolution": [sc.render.resolution_x, sc.render.resolution_y],
"objects": [], "materials": [], "images": [], "cameras": {}, "lights": {}, "armatures": {}, "actions": {},
"rigs": {}, "themeBoneColors": theme_colors()}
"rigs": {}, "themeBoneColors": theme_colors(),
"allActions": {a.name: action_info(a) for a in bpy.data.actions}}
for ob in obs:
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)],
@@ -272,6 +307,9 @@ def dump(path):
for pb in ob.pose.bones:
for c in pb.constraints:
c.mute = True
sc.frame_set(sc.frame_current)
ref["posedBones"] = {ob.name + "/" + pb.name: [r6(x) for x in mat(ob.matrix_world @ pb.matrix)]
for ob in obs if ob.type == "ARMATURE" for pb in ob.pose.bones}
poses = []
if ref["actions"]:
for f in FRAMES: