On maya python api 2.0 I am trying to rotate a node from a custom pivot.
This is how it looks like inside Maya
And this is my code:
import maya.OpenMaya as om
import maya.cmds as cmds
object_position = om.MVector(0.0, 1.0, 0.0)
pivot_pos = om.MVector(0.0, 0.0, 0.0)
twist_axis = om.MVector(0.0, 0.0, 1.0)
twist_value = 1
transform = om.MTransformationMatrix()
transform.setTranslation(object_position, om.MSpace.kWorld)
transform.setRotatePivot(
om.MPoint(pivot_pos),
om.MSpace.kWorld,
True)
rotation_quat = om.MQuaternion(twist_value, twist_axis)
transform.rotateBy(rotation_quat, om.MSpace.kTransform)
final_pos = transform.translation(om.MSpace.kTransform)
cmds.spaceLocator(p=(final_pos.x, final_pos.y, final_pos.z))
Doesn’t seem to rotate from the provided pivot,
What am I missing?
Thank you for your help!