hi, I made a prototype addon.
Probably some bugs with it, I think some some error checks for the active object should be added.
It should add panel to 3D view > object mode > properties, addon category Rigging.
Feel free to update it.
DT.py
# ##### BEGIN GPL LICENSE BLOCK #####
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# ##### END GPL LICENSE BLOCK #####
# DT.py @ http://blenderartists.org: 2014
# Code by dirty-stick @ http://blenderartists.org: 2014
# Todo: Add error checks for active object.
# ----------------------------------------------------------------
# Header
bl_info = {
"name": "Driver Tools",
"author": "dirty-stick",
"version": (1, 0),
"blender": (2, 70, 0),
"location": "3D View > Object Mode > Properties > Driver Tools",
"description": "...",
"warning": "",
"wiki_url": "",
"category": "Rigging"}
import bpy
# Driver Tools PropertyGroup
class DT_props(bpy.types.PropertyGroup):
ob1 = bpy.props.StringProperty(name="Object One", description="Object One", default='')
ob2 = bpy.props.StringProperty(name="Object Two", description="Object Two", default='')
# ----------------------------------------------------------------
# ----------------------------------------------------------------
# Replace Driver Targets
def op_rdt(self, context):
'''
AD_dir
Drivers are stored in AnimData pointers.
This is a list of AnimData directories.
For now, compile based on active object.
'''
AD_dir = []
AD_dir.append(bpy.context.active_object.data.shape_keys.animation_data) # rel shape key value
# error check
OK = True
# ob1: check if Object
if context.scene.DT.ob1 == '':
self.report({"ERROR"},"Object One: Select an Object.")
OK = False
# ob2: check if Object
if context.scene.DT.ob2 == '':
self.report({"ERROR"},"Object Two: Select an Object.")
OK = False
# replace driver targets
if OK:
ob1 = bpy.data.objects[context.scene.DT.ob1]
ob2 = bpy.data.objects[context.scene.DT.ob2]
for ad in AD_dir:
for d in ad.drivers:
for dv in d.driver.variables:
for t in dv.targets:
if t.id == ob1:
t.id = ob2
class OT_RDT(bpy.types.Operator):
"""Replace Driver Targets that use Object One with Object Two"""
bl_idname = "scene.replace_driver_targets"
bl_label = "Replace Driver Targets"
@classmethod
def poll(cls, context):
return context.active_object is not None
def execute(self, context):
op_rdt(self, context)
return {'FINISHED'}
# ----------------------------------------------------------------
# ----------------------------------------------------------------
# Panel
class PT_DRIVER_TOOLS(bpy.types.Panel):
bl_label = "Driver Tools"
bl_idname = "VIEW3D_PT_driver_tools"
bl_space_type = 'VIEW_3D'
bl_region_type = 'UI'
bl_context = "object"
@classmethod
def poll(cls, context):
return (context.active_object and (context.mode == 'OBJECT'))
def draw(self, context):
layout = self.layout
row = layout.row()
col = row.column(align=True)
col.prop_search(context.scene.DT, "ob1", bpy.context.scene, "objects", text="")
col.prop_search(context.scene.DT, "ob2", bpy.context.scene, "objects", text="")
col.operator("scene.replace_driver_targets")
# ----------------------------------------------------------------
# ----------------------------------------------------------------
# Regiter
def register():
bpy.utils.register_class(DT_props)
bpy.types.Scene.DT = bpy.props.PointerProperty(type=DT_props)
bpy.utils.register_class(OT_RDT)
bpy.utils.register_class(PT_DRIVER_TOOLS)
def unregister():
bpy.utils.unregister_class(PT_DRIVER_TOOLS)
bpy.utils.unregister_class(OT_RDT)
del bpy.types.Scene.DT
bpy.utils.unregister_class(DT_props)
if __name__ == "__main__":
register()
# ----------------------------------------------------------------