1
$\begingroup$

I'd like to run some rigify operators. As you might know, the operators are "unique" for each armature because of their rig_id. If I have the rig_id = "i8fj1rbnfbd76bf5" then it takes the following syntax to call the operators:

bpy.ops.pose.rigify_limb_ik2fk_i8fj1rbnfbd76bf5(prop_bone='thigh_parent.L',
                                                  pole_prop="pole_vector", 
                                                  fk_bones='["thigh_fk.L", "shin_fk.L", "foot_fk.L", "toe.L"]',
                                                  ik_bones='["thigh_ik.L", "MCH-shin_ik.L", "MCH-thigh_ik_target.L"]', 
                                                  ctrl_bones='["thigh_ik.L", "foot_ik.L", "thigh_ik_target.L"]', 
                                                  extra_ctrls='["foot_heel_ik.L", "foot_spin_ik.L"]')

bpy.ops.pose.rigify_limb_ik2fk_i8fj1rbnfbd76bf5(prop_bone='upper_arm_parent.L',
                                                  pole_prop="pole_vector", 
                                                  fk_bones='["upper_arm_fk.L", "forearm_fk.L", "hand_fk.L"]',
                                                  ik_bones='["upper_arm_ik.L", "MCH-forearm_ik.L", "MCH-upper_arm_ik_target.L"]', 
                                                  ctrl_bones= '["upper_arm_ik.L", "hand_ik.L", "upper_arm_ik_target.L"]', 
                                                  extra_ctrls='[]')

I was thinking of concatenating the id with the rest of the syntax and converting that into an operator call that I can execute. Is that possible or what alternatives do I have?

$\endgroup$
1
  • $\begingroup$ Can you explain how you identified the list of arguments needed between the end Brackets ? My rig is different than yours and I'm not sure how to get the list of needed args. Also how did you find out the rigify operators ? $\endgroup$
    – mehdianim
    Dec 23, 2022 at 15:38

1 Answer 1

2
$\begingroup$

I think you can use Python's exec() or eval() to do this, if the operator is already registered

import bpy
rig_id = "i8fj1rbnfbd76bf5"
op = eval("bpy.ops.pose.rigify_limb_ik2fk_" + rig_id)
# or with exec
# exec("op = bpy.ops.pose.rigify_limb_ik2fk_" + rig_id)

# now you can call op
op(prop_bone='upper_arm_parent.L') # and rest of arguments
$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .