Maya 2018, Python, Move And Rotate Extracted Face
Trying to write part of the python code in Maya to extract the face from object then move it and rotate it. I tried parameters of polyChipOff itself, tried xform and move and rotat
Solution 1:
In your example, the face is rotated not around its previous position but around the object pivot (you can try to move the object pivot before executing your script and see the rotation center changes).
If you want another pivot you'll need to specify it as an argument. I am not sure what center you want to rotate the faces around so I've just specified (2, 2, 0):
from maya import cmds
face1 = 'pCube1.f[1]'
cmds.select(face1)
cmds.polyChipOff(duplicate=True)
cmds.move(2, 2, 0, relative=True, objectSpace=True)
rotation_pivot = [2, 2, 0]
cmds.rotate(0, 0, 10, relative=True, pivot=rotation_pivot)
for i inrange (35):
cmds.polyChipOff(duplicate=True)
cmds.rotate(0, 0, 10, relative=True, pivot=rotation_pivot)
Update: If you need to rotate faces around their own center then it's just componentSpace=True as you've mentioned. So the code looks like this:
from maya import cmds
face1 = 'pCube1.f[1]'
cmds.select(face1)
cmds.polyChipOff(duplicate=True)
cmds.move(2, 2, 0, relative=True, objectSpace=True)
cmds.rotate(0, 0, 10, relative=True, componentSpace=True)
for i inrange (35):
cmds.polyChipOff(duplicate=True)
cmds.rotate(0, 0, 10, relative=True, componentSpace=True)
Post a Comment for "Maya 2018, Python, Move And Rotate Extracted Face"