Change textfield and store joint chain for use in a function


I’m attempting to set up a small IK FK Snap interface in maya with python. I have a non editable text field and a button in a window. I want the text field to change to the name of a joint that I select and store the joint chain so that I can use I certain joints in a function.

also is there a way to only add joints with a certain prefix to the list?
like ones that have either shdlr, elbow, wrist?

how can I go about this?

You’d want to look at cmds.scriptJob it has a selection changed event that you can hook into to update your values as you change selection.

There is several ways to do that, depending on what you’re after, for example:

elbows ='elbow*', type='joint')
Will give you all joints in the scene whose name starts with “elbow”

sel =
joints = cmds.listRelatives(sel, allDescendents=True, type='joint')
elbows = [jnt for jnt in joints if jnt.startswith('elbow')]

Will list all joints below your selection, and then build a list out of the ones that start with “elbow”