2

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?

CPCN
  • 21
  • 2
  • 1
  • 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 https://blender.stackexchange.com/questions/19602/child-of-constraint-set-inverse-with-python – batFINGER Jun 15 '20 at 12:26
  • 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? – CPCN Jun 16 '20 at 15:54

0 Answers0