-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbatch_detect_sk.py
More file actions
63 lines (50 loc) · 1.6 KB
/
batch_detect_sk.py
File metadata and controls
63 lines (50 loc) · 1.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
"""Detect shape keys from an existing .blend file and list them.
Usage:
blender <blend_file> --background --python batch_detect_sk.py
"""
import bpy
import sys
print("=== Shape Key Detection ===")
print(f"File: {bpy.data.filepath}")
# Find armature
armature = None
for obj in bpy.context.view_layer.objects:
if obj.type == 'ARMATURE':
armature = obj
break
if not armature:
print("ERROR: No armature found")
sys.exit(1)
print(f"Armature: {armature.name}")
# Check if ValveBiped converted
has_pelvis = "ValveBiped.Bip01_Pelvis" in armature.data.bones
print(f"ValveBiped converted: {has_pelvis}")
# Find mesh
mesh_obj = None
for obj in bpy.context.view_layer.objects:
try:
if obj.type == 'MESH' and obj.parent == armature:
mesh_obj = obj
break
except ReferenceError:
continue
if not mesh_obj:
print("ERROR: No mesh found")
sys.exit(1)
print(f"Mesh: {mesh_obj.name}")
if not mesh_obj.data.shape_keys:
print("No shape keys found")
sys.exit(0)
print(f"\n--- Shape Keys ({len(mesh_obj.data.shape_keys.key_blocks) - 1} total, excluding Basis) ---")
for i, kb in enumerate(mesh_obj.data.shape_keys.key_blocks):
if kb.name == "Basis":
continue
# Check if any vertex is different from Basis
basis = mesh_obj.data.shape_keys.key_blocks[0]
max_delta = 0
for vi in range(min(len(kb.data), len(basis.data))):
delta = (kb.data[vi].co - basis.data[vi].co).length
if delta > max_delta:
max_delta = delta
print(f" [{i}] {kb.name} (max_delta={max_delta:.4f})")
print("\n=== DONE ===")