# Extract 3D Coordinates from VTK Output File

**URL:** <https://discourse.slicer.org/t/extract-3d-coordinates-from-vtk-output-file/15391>\
**Category:** Support\
**Created:** [January 7, 2021, 2:27pm UTC](https://discourse.slicer.org/t/extract-3d-coordinates-from-vtk-output-file/15391 "2021-01-07T14:27:04Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Judith](https://avatars.discourse-cdn.com/v4/letter/j/d9b06d/32.png) [@Judith](https://discourse.slicer.org/u/Judith)\
**Post date:** [January 7, 2021, 2:27pm UTC](https://discourse.slicer.org/t/extract-3d-coordinates-from-vtk-output-file/15391/1 "2021-01-07T14:27:04Z")

</div>

Hello everybody,

How do you extract de 3D coordinates from a VTK output file? This VTK output file is created using the Model-to-Model Distance module. It does not matter if the coordinates are in the LPS or RAS system, as I need to compare different coordinates. I need to export these coordinates to Excel.

Any suggestions would be really helpful, thankyou in advance.

Kind regards,  
Judith

---

<div class="post-metadata">

**Author:** ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)\
**Post date:** [January 7, 2021, 5:11pm UTC](https://discourse.slicer.org/t/extract-3d-coordinates-from-vtk-output-file/15391/2 "2021-01-07T17:11:02Z")

</div>

You can use [`arrayFromModelPoints`](https://slicer.readthedocs.io/en/v4.11/developer_guide/slicer.html#slicer.util.arrayFromModelPoints)

---

<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:** [January 7, 2021, 5:19pm UTC](https://discourse.slicer.org/t/extract-3d-coordinates-from-vtk-output-file/15391/3 "2021-01-07T17:19:34Z")

</div>

@pieper thanks for providing the link. I’m wondering if we should always use latest tag ([https://slicer.readthedocs.io/en/](https://slicer.readthedocs.io/en/) **latest** …) instead of a specific version ([https://slicer.readthedocs.io/en/](https://slicer.readthedocs.io/en/) **v4.11** ) in forum posts, because these posts may be read in several months or even years later and by that time specific tags may be outdated. We could also add a “stable” tag to readthedocs.

---

<div class="post-metadata">

**Author:** ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)\
**Post date:** [January 7, 2021, 5:52pm UTC](https://discourse.slicer.org/t/extract-3d-coordinates-from-vtk-output-file/15391/4 "2021-01-07T17:52:14Z")

</div>

> [@lassoan](#):
>
> I’m wondering if we should always use latest tag

Yes, that’s always a tradeoff. There’s a risk that things will get reformatted and we end up with a dead link. On the wiki we would have a header that was added to pages when new versions were created; can we easily do the same on readthedocs?

There’s a similar tradeoff with github links to line numbers in branches which can get out of date compared to a link to the commit+line number.

---

<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:** [January 7, 2021, 6:34pm UTC](https://discourse.slicer.org/t/extract-3d-coordinates-from-vtk-output-file/15391/5 "2021-01-07T18:34:35Z")

</div>

There is no automatic redirect. Maybe after structure of documentation is stabilized we can establish a policy of never deleting documentation page but add links to pages where content is moved to.

---

<div class="post-metadata">

**Author:** ![jsalas424](https://avatars.discourse-cdn.com/v4/letter/j/a87d85/32.png) [@jsalas424](https://discourse.slicer.org/u/jsalas424)\
**Post date:** [July 24, 2022, 10:03pm UTC](https://discourse.slicer.org/t/extract-3d-coordinates-from-vtk-output-file/15391/6 "2022-07-24T22:03:01Z")

</div>

Hi Pieper,

I too need to extract the x,y,z coordinates from a VTK file that I imported to Slicer. I was hoping you could be a little more explicit about how to use arrayFromModelPoints? I have imported the VTK and can see the mesh in the viewer, now what? Sorry if this is a trivial question, I’m relatively new to Slicer.

Here’s what I’m looking at:

 ![Screen Shot 2022-07-24 at 6.05.39 PM](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/6/c/6c3447fbab194d026be780653ed342615c141aba.jpeg)

If you can see at the bottom, I attempted to run ‘slicer.util.arrayFromModelPoints(mesh)’ since my “Node” is named mesh as far as I can tell. Dead end and I got the error “NameError: name ‘mesh’ is not defined”

---

<div class="post-metadata">

**Author:** ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)\
**Post date:** [July 24, 2022, 10:32pm UTC](https://discourse.slicer.org/t/extract-3d-coordinates-from-vtk-output-file/15391/7 "2022-07-24T22:32:45Z")

</div>

You need to use something like:

```auto
meshModelNode = slicer.util.getNode("mesh")
points = slicer.util. arrayFromModelPoints(meshModelNode)

```

(you can leave out `slicer.util` when typing at the console).

To get used to slicer python programming you can have a look at [the FAQ](https://slicer.readthedocs.io/en/latest/developer_guide/python_faq.html) and some of [the tutorials](https://www.slicer.org/wiki/Documentation/4.10/Training#Tutorials_for_software_developers).
