Hello, I’m trying to replicate the IK2FK snap option found in the n-panel of rigify. I’m using a pose picker and it’s more convenient having some of these rigify n-panel options in the separate pose picker window.
This is the code for IK2FK snap of the left hand for this particular character.
bpy.ops.pose.rigify_limb_ik2fk_m5zoa5ys2eee44e5(prop_bone=“upper_arm_parent.R”, fk_bones="[“upper_arm_fk.R”, “forearm_fk.R”, “hand_fk.R”]", ik_bones="[“upper_arm_ik.R”, “MCH-forearm_ik.R”, “MCH-upper_arm_ik_target.R”]", ctrl_bones="[“upper_arm_ik.R”, “hand_ik.R”, “upper_arm_ik_target.R”]", extra_ctrls="[]")
The rig_id is m5zoa5ys2eee44e5
I’m trying to pass this exact same argument but make the rig_id dynamic. This code gives me the rig_id of the active rig.
rigID = bpy.context.object.data.values()[1]
I want to pass rigID into the IK2FK argument.
bpy.ops.pose.rigify_limb_ik2fk_rigID(prop_bone=“upper_arm_parent.R”, fk_bones="[“upper_arm_fk.R”, “forearm_fk.R”, “hand_fk.R”]", ik_bones="[“upper_arm_ik.R”, “MCH-forearm_ik.R”, “MCH-upper_arm_ik_target.R”]", ctrl_bones="[“upper_arm_ik.R”, “hand_ik.R”, “upper_arm_ik_target.R”]", extra_ctrls="[]")
This is where I’ve hit a deadend. I’ve tried various ways of executing this code.
import bpy
rigID = bpy.context.object.data.values()[1]
string = “bpy.ops.pose.rigify_limb_ik2fk_” + rigID + ‘(prop_bone=“upper_arm_parent.R”, fk_bones="[“upper_arm_fk.R”, “forearm_fk.R”, “hand_fk.R”]", ik_bones="[“upper_arm_ik.R”, “MCH-forearm_ik.R”, “MCH-upper_arm_ik_target.R”]", ctrl_bones="[“upper_arm_ik.R”, “hand_ik.R”, “upper_arm_ik_target.R”]", extra_ctrls="[]")’
def IK2FKSnap(arg):
test = arg
return test
IK2FKSnap(string)
I’ve tried using print functions and “{}”.format(rigID) and am running out of ideas. The end result is always me simply passing the entire command as a string rather than having it executed.
It’s reading it in as a string. If I copy/paste the output from the info window after actually clicking the IK2FK snap from the n-panel, it would successfully pass like this.
How can I pass this argument and execute it? Thank you!