Skip to content

Instantly share code, notes, and snippets.

@uyjulian
Created January 4, 2022 21:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save uyjulian/526c8c7326b0bd7031875c5973144000 to your computer and use it in GitHub Desktop.
Save uyjulian/526c8c7326b0bd7031875c5973144000 to your computer and use it in GitHub Desktop.
import bpy
def constraintBoneTargets(armature = 'VisualSceneNode', rig = 'VisualSceneNode.001'):
rigobj = bpy.data.objects[armature]
for ob in bpy.context.scene.objects: ob.select_set(False)
bpy.context.view_layer.objects.active = rigobj
bpy.ops.object.mode_set(mode='POSE')
bpy.ops.pose.select_all(action='SELECT')
for bone in bpy.context.selected_pose_bones:
for c in bone.constraints:
bone.constraints.remove( c )
if bpy.context.scene.objects[rig].data.bones.get(bone.name) is not None:
constraint = bone.constraints.new('COPY_TRANSFORMS')
constraint.target = bpy.context.scene.objects[rig]
constraint.subtarget = bone.name
constraintBoneTargets()
bpy.ops.object.mode_set(mode='OBJECT')
bpy.ops.object.select_pattern(pattern='rig')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment