Sorry, been away from internet connection for a few days. Looks like dirty-stick is working away on this…
Anyhow, for what it’s worth, here’s what I came up with:
import bpy
bl_info = {
"name": "Change Shape Key Driver Targets",
"author": "dirty-stick, revolt_randy",
"version": (0, 0, 1),
"blender": (2, 6, 9),
"location": "3D View -> Tool Shelf",
"description": "",
"warning": "",
"wiki_url": "",
"tracker_url": "",
"category": "Rigging"}
class DriverTargetsPanel(bpy.types.Panel):
bl_idname = "OBJECT_PT_Driver_Targets"
bl_label = "Change Shape Key Driver Targets"
bl_space_type = "VIEW_3D"
bl_region_type = "TOOLS"
@classmethod
def poll(self, context):
# check for mesh selected
return (bpy.context.active_object.type == "MESH")
def draw(self, context):
wm = bpy.context.window_manager
layout = self.layout
row = layout.row()
row.prop(wm, "armature_old")
row = layout.row()
row.prop(wm, "armature_new")
row = layout.row()
row.operator("changetargets.op")
class ChangeTargetsOperator(bpy.types.Operator):
bl_idname = "changetargets.op"
bl_label = "Change Driver Targets"
bl_description ="Change the armature that is used as targets for shape key drivers"
bl_options = {'REGISTER', 'UNDO'}
def execute(self, context):
if bpy.context.window_manager['armature_new'] not in bpy.data.armatures:
self.report({"ERROR"}, "New Armature Invalid")
return {"FINISHED"}
for d in bpy.context.active_object.data.shape_keys.animation_data.drivers:
for dv in d.driver.variables:
for t in dv.targets:
if t.id.name == bpy.context.window_manager['armature_old']:
t.id = bpy.data.objects[bpy.context.window_manager['armature_new']]
else:
self.report({"ERROR"}, "Previous Armature Invalid")
return {"FINISHED"}
bpy.types.WindowManager.armature_old = bpy.props.StringProperty(
name='Previous Armature',
description='Name of previous Armature used for shape key drivers',
default = "")
bpy.types.WindowManager.armature_new = bpy.props.StringProperty(
name='New Armature',
description='Name of current Armature used for shape key drivers',
default = "")
def register():
bpy.utils.register_class(DriverTargetsPanel)
bpy.utils.register_class(ChangeTargetsOperator)
def unregister():
bpy.utils.unregister_class(DriverTargetsPanel)
bpy.utils.unregister_class(ChangeTargetsOperator)
if __name__ == "__main__":
register()
Basic error checking to make sure the previous armature name and new armature name are valid, nothing more. Nothing more is needed as a simple tool to just update the name of the armature in all shape key drivers on a mesh. It’s in the tool shelf area in the UI, only active when a mesh is selected. Oh, and I tested it with 2.70, not tested with any newer version than that.
Thought about this tool quite a bit, and basically anything in blender can be driven, so a tool to re-target drivers for everything would be quite a major undertaking, I think. Not something I would want to take on just because I’m a nice guy.
Anyway, anyone is free to use that code without any credit given. I’m done with this project, I’ve better blender projects to play with…
Randy