sheb

02-05-2008, 10:28 AM

Hello!

Once more I'm trying to use the Maya API via python .. and again I can't get it to work properly. What I want to do is using the api Matrix class to create the inverse of the one I retrieved from the xform command.

#get the inverse matrix using the maya api

def inverseMatrix(m):

newM = []

for i in range(0,4):

newM.append([0,0,0,0])

for y in range(0,4):

newM[i][y]=m[y*4+i]

ma = om.MMatrix(newM).inverse()

for i in range(0,4):

for y in range(0,4):

newM[y*4+i]=ma[i][y]

return newM

I'm converting the matrix from float[16] to float[4][4] but the function seems to want 'float const [4][4]' and I have no idea how to create it. I know there is the MScriptUtility class for making pointers and references but it doesnt seem to help there.

Does anybody know how to do this? I guess I could use some math library for python but I wanted to get more familiar using the API .. :/

Thanks for any hints!

seb

Once more I'm trying to use the Maya API via python .. and again I can't get it to work properly. What I want to do is using the api Matrix class to create the inverse of the one I retrieved from the xform command.

#get the inverse matrix using the maya api

def inverseMatrix(m):

newM = []

for i in range(0,4):

newM.append([0,0,0,0])

for y in range(0,4):

newM[i][y]=m[y*4+i]

ma = om.MMatrix(newM).inverse()

for i in range(0,4):

for y in range(0,4):

newM[y*4+i]=ma[i][y]

return newM

I'm converting the matrix from float[16] to float[4][4] but the function seems to want 'float const [4][4]' and I have no idea how to create it. I know there is the MScriptUtility class for making pointers and references but it doesnt seem to help there.

Does anybody know how to do this? I guess I could use some math library for python but I wanted to get more familiar using the API .. :/

Thanks for any hints!

seb