Maya + Python:将数据移动到边界框的底部

时间:2014-04-15 22:21:21

标签: python maya

如何只将所选节点的轴移动到边界框的底部?

# Move the pivot for each selected not to it's center then bottom

import maya.cmds as cmds

curSel = cmds.ls(long = True, selection = True, type = 'dagNode')

for n in curSel:
    bbox = cmds.exactWorldBoundingBox(n)

    cmds.xform(n, cp=1)

1 个答案:

答案 0 :(得分:3)

bbox XYZ min XYZ max 的6个元素列表:[xmin, ymin, zmin, xmax, ymax, zmax]。如果您希望枢轴点为底部中心,则需要平均X,最小Y和平均Z:

bbox = cmds.exactWorldBoundingBox(n)
bottom = [(bbox[0] + bbox[3])/2, bbox[1], (bbox[2] + bbox[5])/2]
cmds.xform(n, piv=bottom, ws=True)