Maya Python:在曲线CV上生成簇

Maya Python:在曲线CV上生成簇,python,maya,curves,Python,Maya,Curves,我已经找到了曲线上的所有CV,我想在每个CV上做一个聚类。但我得到了一个错误,这不是非常有用。代码如下: # Find all the CVs on the curve, loop through and create a cluster on each curveCVs = cmds.ls(targetCurve + ".cv[0:]",fl=True) for i, cv in enumerate(curveCVs): print i, cv cmds.cluster(wn=(cv, cv

我已经找到了曲线上的所有CV,我想在每个CV上做一个聚类。但我得到了一个错误,这不是非常有用。代码如下:

# Find all the CVs on the curve, loop through and create a cluster on each
curveCVs = cmds.ls(targetCurve + ".cv[0:]",fl=True)
for i, cv in enumerate(curveCVs):
print i, cv

cmds.cluster(wn=(cv, cv))
错误出现在cmds.cluster中wn标志的参数上

# Error: RuntimeError: file <maya console> line 211: Invalid transforms specified.

还有别的办法吗?

你几乎就要成功了。以下是如何使用
cmds.cluster

import maya.cmds as cmds

targetCurve = 'curve1' # Curve to put clusters on
curveCVs = cmds.ls('{0}.cv[:]'.format(targetCurve), fl = True) # Get all cvs from curve
if curveCVs: # Check if we found any cvs
    for cv in curveCVs:
        print 'Creating {0}'.format(cv)
        cmds.cluster(cv) # Create cluster on a cv
else:
    cmds.warning('Found no cvs!')

啊,最简单的解决办法就是答案——谢谢!
import maya.cmds as cmds

targetCurve = 'curve1' # Curve to put clusters on
curveCVs = cmds.ls('{0}.cv[:]'.format(targetCurve), fl = True) # Get all cvs from curve
if curveCVs: # Check if we found any cvs
    for cv in curveCVs:
        print 'Creating {0}'.format(cv)
        cmds.cluster(cv) # Create cluster on a cv
else:
    cmds.warning('Found no cvs!')