bool PyOrientationTo(PyObject *pyval, MT_Matrix3x3 &rot, const char *error_prefix) { int size= PySequence_Size(pyval); if (size == 4) { MT_Quaternion qrot; if (PyQuatTo(pyval, qrot)) { rot.setRotation(qrot); return true; } } else if (size == 3) { /* 3x3 matrix or euler */ MT_Vector3 erot; if (PyVecTo(pyval, erot)) { rot.setEuler(erot); return true; } PyErr_Clear(); if (PyMatTo(pyval, rot)) { return true; } } PyErr_Format(PyExc_TypeError, "%s, could not set the orientation from a 3x3 matrix, quaternion or euler sequence", error_prefix); return false; }