Vtk transform matrix as python list/tuple array

Hey,
I have a model object i am exporting to PLY then trying to obtain its transform node as python list/tuple
I am doing this in my script

my_matrix = transform.GetMatrixTransformFromParent()
matrix_Array = my_matrix.GetData()

where matrix_Array should look like [[row1,…],[row2,…],[…]]

or so i thought that GetData would provide me with per
https://vtk.org/doc/nightly/html/classvtkMatrix4x4.html#a46a8fab5dec2c21f6379beb89730bd74
The document says it returns a raw double array, im not sure what “raw” would entail, I was hoping for it to be a native python array object but when I try to print the object it gives me a mem pointer / instance address… i’m a little confused what to do with it at this point.

I know I can try to iterate through the matrix, and I know it’s fixed 4x4, and manually create the array by pulling data via GetElement but is there a more elegant way of doing this that has already been implemented?

thanks!

You can use this function to convert a raw pointer to a Python list:

A bit more elegant, but probably not much faster or simpler method is to use DeepCopy method:

worked well, thanks.

Note that in Slicer’s Python environment you can simply use slicer.util.arrayFromTransformMatrix to get a numpy array from a transform node (and there are similar convenience functions for getting/settings various other node contents as numpy array).