我在一条曲线上找到了所有的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))
错误是在cmd .cluster中的own标志的参数上。
# Error: RuntimeError: file <maya console> line 211: Invalid transforms specified.
文档说参数应该是字符串。例如:wn=("thing1", "thing2")
但即使我尝试手动输入CV字符串,它也不起作用。
cmds.cluster(wn=("targetPath.cv[14]", "targetPath.cv[14]"))
有其他方法可以采取吗?
你差点就成功了。以下是如何使用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!')