Search code examples
pythonmayamatrix-inversepymel

Getting the inverse of a matrix with PyMel in Maya 2017


I've been looking around in the PyMel docs but can't I get the inverse of a matrix from pymel.core.datatypes. My code is:

inverseM = orientationM*bindRotationM;
inverseM = inverseM.asMatrixInverse()

I just get the error: Error: line 1: AttributeError: file S:\Maya_2017_DI\build\Release\runTime\Python\Lib\site-packages\maya\OpenMaya.py line 54: asMatrixInverse #


Solution

  • if inverseM is already a pymel matrix, you want inverseM.inverse(). The doc is here. Actually its the same thing for an OpenMaya MMatrix too