small fixes, also option for fake parent so hierarchy is always from the parent down
This commit is contained in:
		@@ -31,9 +31,9 @@ def compat_str(text):
 | 
			
		||||
    text = text.replace('"', '\\"')
 | 
			
		||||
    return text
 | 
			
		||||
 | 
			
		||||
def graph_armature(obj, path):
 | 
			
		||||
def graph_armature(obj, path, FAKE_PARENT=True):
 | 
			
		||||
    
 | 
			
		||||
    file = open("/tmp/test.dot", "w")
 | 
			
		||||
    file = open(path, "w")
 | 
			
		||||
    fw = file.write
 | 
			
		||||
    fw(header)
 | 
			
		||||
    fw('label = "%s::%s" ;' % (bpy.data.filename.split("/")[-1].split("\\")[-1], obj.name))
 | 
			
		||||
@@ -57,14 +57,26 @@ def graph_armature(obj, path):
 | 
			
		||||
        
 | 
			
		||||
        fw('"%s" [%s];\n' % (bone.name, ','.join(opts)))
 | 
			
		||||
    
 | 
			
		||||
    # Root node.
 | 
			
		||||
    if FAKE_PARENT:
 | 
			
		||||
        fw('"Object::%s" [];\n' % obj.name)
 | 
			
		||||
    
 | 
			
		||||
    for bone in arm.bones:
 | 
			
		||||
        parent = bone.parent
 | 
			
		||||
        if parent:
 | 
			
		||||
            parent_name = parent.name
 | 
			
		||||
            connected = bone.connected
 | 
			
		||||
        elif FAKE_PARENT:
 | 
			
		||||
            parent_name = 'Object::%s' % obj.name
 | 
			
		||||
            connected = False
 | 
			
		||||
        else:
 | 
			
		||||
            continue
 | 
			
		||||
            
 | 
			
		||||
        opts = ["dir=forward", "weight=2", "arrowhead=normal"]
 | 
			
		||||
            if not bone.connected:
 | 
			
		||||
        if not connected:
 | 
			
		||||
            opts.append("style=dotted")
 | 
			
		||||
        
 | 
			
		||||
            fw('"%s" -> "%s" [%s] ;\n' % (bone.name, parent.name, ','.join(opts)))
 | 
			
		||||
        fw('"%s" -> "%s" [%s] ;\n' % (bone.name, parent_name, ','.join(opts)))
 | 
			
		||||
    del bone    
 | 
			
		||||
    
 | 
			
		||||
    # constraints
 | 
			
		||||
@@ -73,7 +85,7 @@ def graph_armature(obj, path):
 | 
			
		||||
            subtarget = constraint.subtarget
 | 
			
		||||
            if subtarget:
 | 
			
		||||
                # TODO, not internal links
 | 
			
		||||
                opts = ['dir=forward', "weight=1", "arrowhead=normal", "arrowtail=none", "constraint=false", 'color="red"'] # , 
 | 
			
		||||
                opts = ['dir=forward', "weight=1", "arrowhead=normal", "arrowtail=none", "constraint=false", 'color="red"']
 | 
			
		||||
                label = "%s\n%s" % (constraint.type, constraint.name)
 | 
			
		||||
                opts.append('label="%s"' % compat_str(label))
 | 
			
		||||
                fw('"%s" -> "%s" [%s] ;\n' % (subtarget, pbone.name, ','.join(opts)))
 | 
			
		||||
@@ -88,6 +100,8 @@ def graph_armature(obj, path):
 | 
			
		||||
        bone_name = rna_path.split("[")[1].split("]")[0]
 | 
			
		||||
        return obj.pose.bones[bone_name[1:-1]]
 | 
			
		||||
    
 | 
			
		||||
    animation_data = obj.animation_data
 | 
			
		||||
    if animation_data:
 | 
			
		||||
        for fcurve_driver in obj.animation_data.drivers:
 | 
			
		||||
            rna_path = fcurve_driver.rna_path
 | 
			
		||||
            pbone = rna_path_as_pbone(rna_path)
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user