简体   繁体   English

Maya + Python:将枢轴移到边界框的底部

[英]Maya + Python: Move pivot to bottom of bounding box

How can I move just the pivot of the selected node to the bottom of the bounding box? 如何仅将所选节点的枢轴移动到边界框的底部?

# 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)

bbox is a 6-element list of XYZ min and XYZ max : [xmin, ymin, zmin, xmax, ymax, zmax] . bboxXYZ minXYZ max的6元素列表: [xmin, ymin, zmin, xmax, ymax, zmax] If you want the pivot point to be the bottom center, you'll want the average X, minimum Y, and average Z: 如果希望将枢轴点作为底部中心,则需要平均值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)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM