# Vtk transform matrix as python list/tuple array

**URL:** https://discourse.slicer.org/t/vtk-transform-matrix-as-python-list-tuple-array/11797
**Category:** Development
**Tags:** vtk, transforms
**Created:** [May 30, 2020, 10:59pm UTC](https://discourse.slicer.org/t/vtk-transform-matrix-as-python-list-tuple-array/11797 "2020-05-30T22:59:22Z")
**Posts on this page:** 1
**Showing post:** 2

<div class="post-metadata">

### Author: ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)
#### Post date: [May 30, 2020, 11:54pm UTC](https://discourse.slicer.org/t/vtk-transform-matrix-as-python-list-tuple-array/11797/2 "2020-05-30T23:54:23Z")

</div>

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

> [@Centering on a segment from a script](https://discourse.slicer.org/t/centering-on-a-segment-from-a-script/6209/9):
>
> Using a custom extension is certainly a solution, but in the long term I would recommend developers to use Slicer core functions if available. Slicer-4.10 returning a swig pointer (such as \_000001bfd4897340\_p\_void) is a minor inconvenience. You can still access the values using the helper function below (in the nightly version the VTK hint is there so the position is directly returned as a Python tuple). def getListFromPointer(bufferPtr, scalarType=vtk.VTK\_DOUBLE, numberOfElements=3): """Con…

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

> <https://github.com/Slicer/Slicer/blob/e53e8af9c4a0b60adee28b5eca5fc1b5ff2da9ea/Base/Python/slicer/util.py#L1114-L1151>

---

_[View the full topic](https://discourse.slicer.org/t/vtk-transform-matrix-as-python-list-tuple-array/11797)._
