Selecting joint chain through a control curve


having some trouble selecting my arm Ik joint chain through its wrist control curve. for some reason, I can only get a print of one joint at a time even though I have all parents=True

currently my test code prints just the upper elbow for for me (I have a lower and upper elbow)

why would this be happening? also Is there a better way to go about this?

import maya.cmds as cmds

sel =
list = cmds.listConnections(sel)
list1 =  cmds.listConnections(list[0], type = 'joint')
list2 = list1[0]
list3 = cmds.listRelatives(list2, p=True, pa=True, type = 'joint')
ikjointsel= cmds.listRelatives(list3, p=True, pa=True, type = 'joint')

print ikjointsel

The allParents flag doesn’t do what you think it does.
It returns all the parents of an instanced object, not the parent hierarchy of the object.

Since you wan to make sure you only get the joints, you’ll probably want to recurse up the chain, and check each parent’s type.

There’s a better explanation, and code examples of this here: