0
$\begingroup$

I have got a beautiful bone constraint:

enter image description here

I would like to be able to enable and disable this constraint without the bone reverting to the original position.

By default, the bone appears to return to it's original starting position when influence is set to 0 or visibility is set to off.

So, for example:

  • Constraint is "on" or "enabled" - bone follows Hand.L as expected
  • Constraint is "off" - bone stays where it is at this exact moment and does not move.

I would like to be able to 'apply' the constraint without actually deleting the constraint, as I am intending to turn it on and off frequently during animation.

$\endgroup$
  • 1
    $\begingroup$ Hit the X to the right of influence slider. It "applies" the constraint and sets influence to 0 $\endgroup$ – batFINGER Mar 25 at 10:59
  • $\begingroup$ @batFINGER I can't believe I didn't see that. Seems to work! $\endgroup$ – Joehot200 Mar 25 at 11:02
  • 1
    $\begingroup$ Note it may change behaviour when setting influence back to 1 since there is a new location / rotation etc depending on constraint. $\endgroup$ – batFINGER Mar 25 at 11:03
  • $\begingroup$ @batFINGER It might be a little off-topic now, but I'm also trying to do this with a script. If I set the influence directly, Blender will show me the code in the bottom left of the 'scripting' tab to type to change it, however when I hit the X button nothing shows up at all. $\endgroup$ – Joehot200 Mar 25 at 11:07
1
$\begingroup$

Disable and Keep Transform

Hit the X to the right of influence slider. It "applies" the constraint and sets influence to 0

Script Equivalent, copy the transform, ie the world matrix, set the constraint influence to zero (disable) and reset the matrix world.

import bpy

ob = bpy.context.object
constraint = ob.constraints.get("Copy Location")
if constraint:
    mw = ob.matrix_world.copy()
    constraint.influence = 0
    ob.matrix_world = mw
| improve this answer | |
$\endgroup$
  • $\begingroup$ Cheers for the answer, it's a great help. One last question - since I have to do this for bones, how do I set the matrix_world? bone.matrix_world = mw seems to with objects, but not with bones. $\endgroup$ – Joehot200 Mar 25 at 19:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.