Hi!
I'm not sure that this will give you the desired outcome, since having both locators and nurbsCurves as controlls is quite messy and you'll probably select some objects in the rig that aren't controls.
Unless there are really strict naming conventions or a tagging system (or all the nurbsCurves and Locators without exception are controls), this isn't really doable...
import maya.cmds as mc
def selectAllControllers():
""" selects all the Nurbscurves and Locators with the same namespace as the current selection if any of the transform attributes are keyable"""
transforms = ['visibility', 'translateX', 'translateY', 'translateZ', 'rotateX', 'rotateY', 'rotateZ', 'scaleX', 'scaleY', 'scaleZ']
selectObjs = []
#get current selection
sel = mc.ls(sl = True, l = True)
for s in sel:
#get prefix
characterName = s.split(":")[0]
#get all objects that contain the prefix
objs = mc.ls("{0}:*".format(characterName), dag = True, lf = True)
for o in objs:
#check if object is either nurbsCurve or locator
if mc.objectType(o) == "nurbsCurve" or mc.objectType(o) == "locator":
#get parent transform and check for keyable transform attributes
par = mc.listRelatives(o, p = True, f = True)[0]
keyables = mc.listAttr(par, k= True)
if any(attr in transforms for attr in keyables):
#if there is a keyable transform attribute, add to the list of objects to be added to selection
selectObjs.append(par)
mc.select(selectObjs, add = True)
selectAllControllers()
Now I also should point out that there is a list of Attributes which are checked for keyability. This list can be changed to include more or less attributes, and if one of the attributes in the list is keyable, the curve will be selected.
I hope it helps!