Hi, how can I get object's actual rotation after freeze?
For instance :
# create a cube
CudeTransformNode = cmds.polyCube()[ 0 ]
# rotate X 20 degree.
cmds.setAttr( f"{CudeTransformNode}.rotateX" , 20 )
# * now its like
# - freezed rotation X : 0
# - rotation translation X : 20
# - actual rotation X : 20
# freeze translation.
cmds.makeIdentity( CudeTransformNode , a = 1 , r = 1 )
# * then its like
# - freezed rotation X : 20
# - rotation translation X : 0
# - actual rotation X : 20
# for test, rotate X 30 more degree.
cmds.setAttr( f"{CudeTransformNode}.rotateX" , 30 )
# * now its like
# - freezed rotation X : 20
# - rotation translation X : 30
# - actual rotation X : 50
# From here
# how to get actual rotation
Foo() == 50
# or how to get freezed rotation
Boo() == 20
** Above example, my question is how can we get the real rotation??( how to get 50 or 20 )**
Because every method I found is only telling you how to get current rotation( * rotation translation )
For reference :
- https://www.akeric.com/blog/?p=1067
- Getting rotation from matrix, OpenMaya
- Is there a way to calculate 3D rotation on X and Y axis from a 4x4 matrix
All these are telling you to use Matrix to get rotation, but the Matrix returned from native commands are always reflecting the translated values only. Therefore, in above example, the calculated output will always be 30( current rotation ).
For instance :
import maya.api.OpenMaya as om
Matrix = cmds.xform( CudeTransformNode, q = 1 , m = 1 )
_M = om.MMatrix( Matrix )
_TM = om.MTransformationMatrix( _M )
_rotation_radiants = _TM.rotation()
_rotation_radiants[ 0 ] <-- # equals to 30 degree
# But I want to get 20 or 50...
Maybe the question is more correct to say, how to get overall rotation matrix?
Thank you for your advices!!