In Softimage, I use a lot the Match transforms' commands to match an object's position, orientation or scale to another. Although we don't have those in Maya, we can get around with snaps and some scripts appended to your shelf!
An easy way to do this in Mel is to use the delete command:
- Match position:
delete `pointConstraint`;
- Match orientation:
delete `orientConstraint`;
- Match All:
delete `parentConstraint`;
Another way is to match each attribute from source to target.
eg: Matching position in Python
import maya.cmds as c
sel = c.ls(sl=True)
ob = c.getAttr(sel[0] + ".t")[0]
c.setAttr(sel[1] + ".t",ob[0],ob[1],ob[2])
Another thing in Softimage that is widely used is Neutral Pose. It is always important to keep controllers zeroed. In Maya we can do this by grouping (Ctrl+G) or parenting to another object and match its transforms!
eg:
import maya.cmds as cmds
# Select group and then select child object
s = cmds.ls(selection=True)
# Get and Set objects' translation
v = cmds.getAttr(s[1] + ".translateX")
cmds.setAttr(str(s[0]) + ".translateX",v)
v = cmds.getAttr(s[1] + ".translateY")
cmds.setAttr(str(s[0]) + ".translateY",v)
v = cmds.getAttr(s[1] + ".translateZ")
cmds.setAttr(str(s[0]) + ".translateZ",v)
# Get and Set objects' rotation
v = cmds.getAttr(s[1] + ".rotateX")
cmds.setAttr(str(s[0]) + ".rotateX",v)
v = cmds.getAttr(s[1] + ".rotateY")
cmds.setAttr(str(s[0]) + ".rotateY",v)
v = cmds.getAttr(s[1] + ".rotateZ")
cmds.setAttr(str(s[0]) + ".rotateZ",v)
# Set child object's transforms
v = 0
cmds.setAttr(str(s[1]) + ".translateX",v)
cmds.setAttr(str(s[1]) + ".translateY",v)
cmds.setAttr(str(s[1]) + ".translateZ",v)
cmds.setAttr(str(s[1]) + ".rotateX",v)
cmds.setAttr(str(s[1]) + ".rotateY",v)
cmds.setAttr(str(s[1]) + ".rotateZ",v)
No comments:
Post a Comment