"""Per-take motion: which `AnimationStack` in an FBX actually carries animation. `fbx_takes.py` counts the stacks; this says which of them hold anything. The two disagree on four files in this library, where a C4D export left an empty second stack named `Take 001` beside the real motion — no layers with curves under it, nothing to play. Counting stacks calls those files two-take; following the connections shows they hold one action and one empty shell. Walks `Connections` from each stack down through its layers and curve nodes to the curves themselves, then reports how many of those curves move. """ import struct, sys, zlib, collections SCALAR={"Y":2,"C":1,"I":4,"F":4,"D":8,"L":8}; ELEM={"f":4,"d":8,"l":8,"i":4,"b":1} FMT={"f":"f","d":"d","l":"q","i":"i","b":"b"} def analyse(path): d=open(path,"rb").read(); u64=struct.unpack("=7500; N=25 if u64 else 13 obj={}; conn=[]; curve_vals={} def rp(p,want): t=chr(d[p]); s=p; p+=1 if t in SCALAR: p+=SCALAR[t]; return p,(t,d[s+1:p]) if t in ELEM: n,enc,cl=struct.unpack("=2: uid=struct.unpack("=3: try: conn.append((props[0][1], struct.unpack("1e-6] out.append((name, len(curves), len(moving), max(curves) if curves else 0.0)) return out def takes_with_motion(path): """How many of the file's stacks actually carry a curve.""" return sum(1 for _, ncurves, _, _ in analyse(path) if ncurves) if __name__=="__main__": import os for f in sys.argv[1:]: print(os.path.basename(f)) for name,n,mv,mx in analyse(f): print(" take %-24s curves=%-4d moving=%-4d max_range=%.4f%s" %(name,n,mv,mx," <- empty" if not n else ""))