获取转换节点字符串和列表?玛雅 Python

getting transform node string & list? Maya Python

我附加了一个列表,结果是这样的:

[[u'polyToCurve1', u'polyEdgeToCurve1'], [u'polyToCurve2', u'polyEdgeToCurve2'],....etc

我需要它 select 所有 'polyToCurve#' 变换节点的列表,仅此而已,但我不确定如何到达那里...这很新,所以这可能是一个简单的答案,但 IDK...

selection = cmds.ls(selection=True, flatten = 1)
curveList = []

for i in selection:
    cmds.select(i, r=True)
    curveList.append(cmds.polyToCurve(form= 0, degree= 3))
    print curveList

我只需要一个简单的 polyToCurve# 列表,然后我可以再次使用 cmds.select

最简单的方法是使用列表理解:

curveList = [curve for (curve, edgeCurve) in curveList]

此处的中间部分将双元素列表拆分为两个变量,然后第一部分选择这些元素中的第一个。列表理解作为一个整体使一个列表只包含那些。

selection = cmds.ls(selection=True, flatten = 1)
curveList = []

for i in selection:
    cmds.select(i, r=True)
    curveList.append(cmds.polyToCurve(form= 0, degree= 3)[0])
    print curveList

你只需要select函数输出列表的第一个索引