Maya python将曲线控件连接到定位器

Maya python将曲线控件连接到定位器,python,maya,Python,Maya,我想知道为什么这会在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()

我想知道为什么这会在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 )

shapeNode是一个列表。通过以下方式更改最后一行:

cmds.connectAttr( shapeNode[0] + '.worldPosition[0]' , ctrl , f=True )
或shapeNode变量,通过以下方式设置:

shapeNode = cmds.listRelatives(node, fullPath=True, shapes=True)[0]
希望能有所帮助。
干杯。

什么地方出错了?