Replace PyConstraints in 2.6x

I still use PyConstraints in 2.49b and havn’t transitioned to 2.6x yet. I think I read on another thread that there was a system to replace PyConstraints in 2.6x, but I couldn’t find it. I think someone said it was a variable system. Is there something to replace PyConstraints in 2.6x?

The reason I need PyConstraints is because I used them to set up an FK/IK switch on an armature. I have it set up so that the IK chain can end at either the hand or the lower arm and the swich affects the elbow control. I only found one tutorial for 2.6x for an IK/FK switch, and it was a 54 minute video tutorial. I was hoping for a tutorial that was not a video.

I found a tutorial on another thread, but it is for creating an FK/IK switch from a custom property. I need a switch made from a bone. I went into the graph editor, selected drivers, and then under drivers I selected “scripted expression”. I need to put a python expression representing the Y coordinate of the location another bone in the pose space. I tried pose.bones[“HandIKSwitch.L”].matrix[“BONESPACE”][3][1] but it said it was an invalid python expression. How can I put the Y coordinate of a bone’s location from the pose space into a scripted expression of a driver?

Never mind, I figured it out. It turns out the correct code was bpy.context.object.pose.bones[“HandIKswitch.L”].location[1].

Actually, it turns out that bpy.context.object.pose.bones[“HandIKswitch.L”].location[1] didn’t work the way I expected. What I have is a driver on the influence value of a bone constraint and I want the driver to be driven by the location of another bone in the same armature. I tried bpy.data.objects[“Person5.0.arm”].pose.bones[“HandIKswitch.L”].location[1]/0.4 where “Person5.0.arm” is the name of the object that the armature is associated with and that seems to have worked. However, when the object is renamed the scripted expression in the driver stays the same. Is there any way I can reference the object that a driver is associated with from within a scripted expression without directly mentioning the name of the object?

You could try working with a variable assigned to active object or selected objects. But I’m new here so take this with a grain of salt.

Using a variable assigned to an object worked. Thanks for the suggestion.