def get_selected_channels(full=True, long=True, *args):
"""
for ONE object selected, return all selected channels from channel box
:param full: (boolean) return the full name of the object.attr?, if false then returns only the attr names
":param long: (boolean) whether we should get the long name of the attr. False will give us "short" names
:return: list of full obj.channel names selected, or (if not "full") just the channnel names
"""
cBox = mel.eval('$temp=$gChannelBoxName')
sel = cmds.ls(sl=True, l=True)
if len(sel) != 1:
cmds.warning("You have to select ONE node!")
return(None)
obj = sel[0]
channelsRaw = cmds.channelBox(cBox, q=True, selectedMainAttributes=True, selectedShapeAttributes=True,
selectedHistoryAttributes=True,
selectedOutputAttributes=True)
channels = []
if channelsRaw:
if long:
for ch in channelsRaw:
newC = cmds.attributeQuery(ch, node=obj, longName=True)
channels.append(newC)
else:
for ch in channelsRaw:
newC = cmds.attributeQuery(ch, node=obj, shortName=True)
channels.append(newC)
else: return(None)
returnList = []
if channels:
if full:
for c in channels:
full = "{0}.{1}".format(obj, c)
returnList.append(full)
else:
returnList = channels
return(returnList)
else:
cmds.warning("zbw_rig.get_selected_channels: I didn't detect any channels selected!")
return(None)
评论列表
文章目录