Created
December 13, 2019 08:32
-
-
Save Airyzz/4f0f160d7e69127bcba774eeecae635c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import bpy | |
def ApplyArmatures(): | |
for ob in bpy.context.selected_objects: | |
bpy.context.view_layer.objects.active = ob | |
for mod in [m for m in ob.modifiers if m.type == 'ARMATURE']: | |
bpy.ops.object.modifier_apply( modifier = mod.name ) | |
#First select armature with animation, second select armature to copy to | |
def AddConstraints(): | |
if bpy.context.selected_objects[0].type == 'ARMATURE' and bpy.context.selected_objects[1].type == 'ARMATURE' : | |
if bpy.context.selected_objects[0] == bpy.context.active_object: | |
ob = bpy.context.selected_objects[1] | |
target = bpy.context.selected_objects[0] | |
else: | |
ob = bpy.context.selected_objects[0] | |
target = bpy.context.selected_objects[1] | |
for bone in ob.pose.bones: | |
try: | |
targetBone = target.pose.bones[bone.name] | |
crc = targetBone.constraints.new('COPY_ROTATION') | |
crc.target = ob | |
crc.subtarget = bone.name | |
crc.target_space = 'LOCAL' | |
crc.owner_space = 'LOCAL' | |
except: | |
print('bone not found') | |
else: | |
print('Incorrect Selection') | |
def ClearConstraints(): | |
for ob in bpy.context.selected_objects: | |
for bone in ob.pose.bones: | |
for constraint in bone.constraints: | |
bone.constraints.remove(constraint) | |
AddConstraints() | |
#ClearConstraints() | |
#print(bpy.context.selected_objects) | |
#print(bpy.context.active_object) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment