如何从 Maya Python 脚本获取点的 XYZ 坐标?

问题描述 投票:0回答:1

如何从 Python 脚本获取 Maya 中顶点的数字 xyz 分量?

python api maya
1个回答
0
投票

非常难找,但你必须在

maya.cmds.xform
查询模式下使用
q
命令

Maya 仅通过字符串来识别其中的对象。因此,您必须使用向 Maya 询问您正在查询的形状对象的顶点的字符串。如果你有一个名为

pCube1
的立方体,它就是
pCube1.vtx[*]

# Get the raw numeric xyz values of pCube1
xyzs = cmds.xform( 'pCube1.vtx[*]', q=True, translation=True, worldSpace=True)

print( str(len( xyzs )) + ' component entries' )
for i in range( 0, len(xyzs), 3 ):
  x = xyzs[ i + 0 ]
  y = xyzs[ i + 1 ]
  z = xyzs[ i + 2 ]
  print( 'x = ' + str( x ) + ', y = ' + str(y) + ', z = ' + str(z) )
© www.soinside.com 2019 - 2024. All rights reserved.