Advertisement
robertvari

Connect Rig To Deform

May 12th, 2022
571
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import bpy
  2.  
  3. def connect_bones(from_armature, to_armature):
  4.     armature_rig = bpy.data.objects[from_armature]
  5.     armature_deform = bpy.data.objects[to_armature]
  6.    
  7.     rig_bones = [i for i in armature_rig.pose.bones]
  8.     for rig_bone in rig_bones:
  9.         deform_bone = armature_deform.pose.bones.get(rig_bone.name.replace("rig", "deform"))
  10.        
  11.         if not deform_bone:
  12.             continue
  13.        
  14.         # remove deform contraints
  15.         for con in deform_bone.constraints:
  16.             deform_bone.constraints.remove(con)
  17.            
  18.         # create constraint
  19.         copy_con = deform_bone.constraints.new('COPY_TRANSFORMS')
  20.         copy_con.target = armature_rig
  21.         copy_con.subtarget = rig_bone.name
  22.         copy_con.target_space = 'POSE'
  23.         copy_con.owner_space = 'POSE'
  24.  
  25. connect_bones('Rabbit_Rig', 'Rabbit_Deform')
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement