[Maya] Getting the matrix

I’ve run into a wall and was hoping to get some help. I am trying to access the xform matrix of a node sitting in space. As I understand it, the transform matrix has 16 indices in it. I want to be able to access only items [8] [9] and [10], so that I can plug them into multiply/divide nodes. For the life of me, I can’t find a way to extract those items.

Has anyone else had this problem? Were you able to find a solution? Thanks for any help that you can offer!

You can use the decomposeMatrix node for this. Just make sure it’s loaded as a plug-in in maya (matrixnodes.mll). Just input the world matrix into the node and you can retrieve individual indices.

Hope this is the solution you’re looking for. :slight_smile:

in python you can get the matrix as a flat list using


cmds.xform(YourObjectHere, q=True, m=True)

items 8,9,10 will be the local z vector of the matrix in most cases. For the world matrix use


cmds.xform(YourObjectHere, q=True, m=True, ws=True)

BTW this will always return in centimeters no matter what you unit settings are, since matrix values are always cm

Hehe, yeah. If you’re using code to retrieve the values then the solutions above are awesome too. :slight_smile: I think you meant to specify the “ws=True” flag in your code though for the 2nd solution, right Theodox?

fixed :0

[QUOTE=Theodox;22716]fixed :0[/QUOTE]

I coulda sneaked a fix in there but I felt that would be an abuse of my power. >:D

Thanks everyone! All of these different approaches have helped out a lot.