2
$\begingroup$

I am trying to make a simple panel with buttons for snapping bones between IK and FK configurations, and I need to change attributes of bone constraints with python scripting.

I can quite easily change something like the Influence of a constraint this way, however I am a little lost when it comes to executing/applying/pressing the Disable and Keep Transform button through script.

I found the operator: bpy.ops.constraint.disable_keep_transform()
and I know you should be able to use "Context Override" on the operator to feed it the appropriate context
(found here: https://docs.blender.org/api/current/bpy.ops.html#overriding-context)

I have tried to copy "similiar" solutions from other people like in this question:
How do I reset a specific bone's "Stretch To" Rest Length, via code?
but I havn't been able to find much information about how these operators and the "Context Override" works.

I feel like I am close.. but someone who knows how these operators work would be a big help.

So the simple question: What context does the disable_keep_transform() operator need?

$\endgroup$
3
  • 1
    $\begingroup$ related: poll() failed, context incorrect? $\endgroup$
    – brockmann
    Commented Jun 15, 2020 at 11:56
  • $\begingroup$ See first part of this answer which is pretty much disable constraint (set influence to zero) and keep transform. Otherwise imagine that the operator override needs a "constraint" member which is present in PROPERTIES space but not elsewhere. Similarly blender.stackexchange.com/questions/19602/… $\endgroup$
    – batFINGER
    Commented Jun 15, 2020 at 12:26
  • $\begingroup$ So if I change the "area" attribute of the override context to one with a "PROPERTIES" type then it seems to work, however I'm currently just doing a for-loop to find the appropriate area, like this: for area in bpy.context.screen.areas : if area.type == "PROPERTIES" : override["area"] = area .. Is there a better way of getting the correct area type for the override? $\endgroup$
    – CPCN
    Commented Jun 16, 2020 at 15:54

0

You must log in to answer this question.

Browse other questions tagged .