我想知道为什么这会在str上出错?我试图缩小问题所在的范围,并且它与变量ShapeNode有关?我不知道为什么会这样。我希望有人可以帮助阐明这一点。
谢谢。
import maya.cmds as cmds
cmds.file(new=True, f=True)
nodes = []
# create a line of nodes
for i in range(0,6):
# create node then move it
node = cmds.spaceLocator()
cmds.xform(node, ws=True, t=(4*i,0, 0) )
nodes.append(node)
# collect positions
pts = []
for n in nodes:
p = cmds.xform(n, query=True, translation=True, worldSpace=True )
pts.append(p)
# create curve and rename
line = cmds.curve(d=1, p=pts )
newPath = cmds.rename( line, 'Pathway_00' )
# create connections between objects and curve
count = len(pts)
for i in range(0,count):
node = nodes[i]
shapeNode = cmds.listRelatives(node, fullPath=True, shapes=True)
shapeTransform = cmds.ls(newPath)[0]
shapePath = cmds.listRelatives(shapeTransform, fullPath=False, shapes=True)
ctrl = (shapePath[0] + '.controlPoints[' + str(i) + ']')
cmds.connectAttr( (shapeNode + '.worldPosition[0]'), ctrl , f=True )
答案 0 :(得分:1)
shapeNode是一个列表。通过以下方式更改您的最后一行:
cmds.connectAttr( shapeNode[0] + '.worldPosition[0]' , ctrl , f=True )
或shapeNode变量由:
设置shapeNode = cmds.listRelatives(node, fullPath=True, shapes=True)[0]
希望它有所帮助。
欢呼声。