PYTHON Bone Constraints and Driver ???

[SUP]Hei Guys,

i have a short question. I have the following code and want to add a driver to the rest lenght of the stretch to constraint(Bone Constraint).
But everytime the console says that the Property Path is invalid. What am i doing wrong ?
armature = Name of my armature
str(GrpName)+"_bone" = Name of the armatures bone

 BaseLenghtDrv =[armature].pose.bones[str(GrpName)+"_bone"].driver_add('pose.bones["'+str(GrpName)+'_bone"].constraints["Stretch To"].rest_length').driver

PS: The Code before the driver_add parentheses is definately correct i tested it with the rotation quaternion of the bone and it worked but not the bone constraint.


You are doubling up the pose bone path when you add the driver in your code. The resultant path would be something akin to


My suggestion would be to add the rest_length driver to the constraint

pb =[armature].pose.bones[str(GrpName)+"_bone"]
fcurve = pb.constraints['Stretch To'].driver_add('rest_length')
driver = fcurve.driver