简体   繁体   中英

Maya – Aligning the center of one object to the center of another object

I'm an animation student and this is the first time I study programing and Python.

My doubt is the following: I have two objects in a maya file: “pSphere1” and “pCone1”, and I want to place the pSphere1 center at the center of pCone1, (by center I mean pivot; I want both pivots to be aligned). pSphere1 is the one that should move to the position of pCone1. pCone 1 doesn't move.

So, I was wondering if there is a command in Python that can center both object's pivots.

At first select pSphere1 , then pCone1 and apply the following command:

import maya.cmds as mc

mc.align(x='mid', y='mid', z='mid', alignToLead=True)

Flag alignToLead=True produces the desired result.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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