I have this little script that lets me change the target of the shrinkwrap constraints of bones “Bone” and “Bone.001” of an armature object, (the script and an example file are both attached.) However, I have to change the targets for each bone separately. Is it possible to create a UI panel that allows you to choose a single object (preferably from an enumerated drop-down list like both fields have now) and set it as the target for multiple bones’ constraint, from a single field?
import bpy
class BoneSWTest(bpy.types.Panel):
bl_space_type = "VIEW_3D"
bl_region_type = "UI"
bl_label = "Bone Shrinkwrap Test"
@classmethod
def poll(self, context):
if not context.active_object:
return False
return True
def draw(self, context):
layout = self.layout
row = layout.row()
row.prop(bpy.context.object.pose.bones["Bone"].constraints["Shrinkwrap"], 'target', text='Bone target')
row = layout.row()
row.prop(bpy.context.object.pose.bones["Bone.001"].constraints["Shrinkwrap"], 'target', text='Bone.001 target')
bpy.utils.register_class(BoneSWTest)
Shrinkwrap Controller.blend (516 KB)