# Load vtp files in slicer

**URL:** <https://discourse.slicer.org/t/load-vtp-files-in-slicer/30442>\
**Category:** Support\
**Created:** [July 7, 2023, 4:29am UTC](https://discourse.slicer.org/t/load-vtp-files-in-slicer/30442 "2023-07-07T04:29:17Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kening\_Zhang](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/kening_zhang/32/65641_2.png) [@Kening\_Zhang](https://discourse.slicer.org/u/Kening_Zhang)\
**Post date:** [July 7, 2023, 4:29am UTC](https://discourse.slicer.org/t/load-vtp-files-in-slicer/30442/1 "2023-07-07T04:29:17Z")

</div>

Dear developers,  
I want to load the output vtp files generated back to slicer, the code I write is as following:  
#Load the generated anatomical tracts back into Slicer  
for file\_name in os.listdir(AnatomicalTractsFolder):  
# Check whether the file extension is VTP  
if file\_name.endswith(“.vtp”):  
# Build the full path of the file  
file\_path = os.path.join(AnatomicalTractsFolder, file\_name)  
# load vtp in slicer  
loaded\_model\_node = slicer.util.loadModel(file\_path)  
However, it failed:

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/0/8/0888c77dc581388f098897ef277c8a3ba9483542.png)

Best wishes,  
Joshua

---

<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 7, 2023, 1:48pm UTC](https://discourse.slicer.org/t/load-vtp-files-in-slicer/30442/2 "2023-07-07T13:48:19Z")

</div>

It looks like that vtp file is empty. Probably this is flagged as an error in VTK. You can wrap your `loadModel` call in a try/except that the file didn’t load.

It is likely that older VTK versions silently accepted empty files but the I/O was reworked. I ran into an issue like this when trying lo save empty files:

> **[crash writing vtp with degenerate cells (new in vtk9) (#18059) · Issues · VTK...](https://gitlab.kitware.com/vtk/vtk/-/issues/18059)**
>
> Code that uses vtkXMLPolyDataWriter that previously worked with vtk8 started crashing with vtk9. We created a workaround to that in
