# stl file is not saving using SaveData in python.

**URL:** https://discourse.paraview.org/t/stl-file-is-not-saving-using-savedata-in-python/6770
**Category:** ParaView Support
**Tags:** python, vtk
**Created:** [March 23, 2021, 8:06am UTC](https://discourse.paraview.org/t/stl-file-is-not-saving-using-savedata-in-python/6770 "2021-03-23T08:06:00Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![rasunag27](https://discourse.paraview.org/user_avatar/discourse.paraview.org/rasunag27/32/4636_2.png) [@rasunag27](https://discourse.paraview.org/u/rasunag27)
#### Post date: [March 23, 2021, 8:06am UTC](https://discourse.paraview.org/t/stl-file-is-not-saving-using-savedata-in-python/6770/1 "2021-03-23T08:06:00Z")

</div>

Dear All,

I used one stl file to split the stl using Paraview. I traced the method using python trace in paraview.

Now, I used the code in python to run it. It runs perfectly, but it does not save the splitted mesh as needed. The code is used as per the trace obtained from paraview. Below is the snipped of the code where SaveData is used to save the file. How to save stl file?

```
# create a new 'Extract Surface'
extractSurface1 = ExtractSurface(Input=threshold1)

    # save data
    SaveData('surf.stl', proxy=extractSurface1, FileType='Ascii')

```

This is not saving anything. Any leads will be appreciated.

Regards,  
Sunag R A.

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.paraview.org/user_avatar/discourse.paraview.org/mwestphal/32/17_2.png) [@mwestphal](https://discourse.paraview.org/u/mwestphal)
#### Post date: [March 23, 2021, 8:18am UTC](https://discourse.paraview.org/t/stl-file-is-not-saving-using-savedata-in-python/6770/2 "2021-03-23T08:18:45Z")

</div>

This code is saving a surf.stl file in the location ParaView is run from.

---

<div class="post-metadata">

### Author: ![rasunag27](https://discourse.paraview.org/user_avatar/discourse.paraview.org/rasunag27/32/4636_2.png) [@rasunag27](https://discourse.paraview.org/u/rasunag27)
#### Post date: [March 23, 2021, 8:47am UTC](https://discourse.paraview.org/t/stl-file-is-not-saving-using-savedata-in-python/6770/3 "2021-03-23T08:47:30Z")

</div>

This is my question. It is actually not saving anything. I am running the python file from IDE by giving ParaviewBuildPath. Below is the full code along with original stl mesh. Let me know if the file is saved after splitting the stl mesh from original mesh.

Please change the build path accordingly, in case of running.

```
import sys #sys- append path
import numpy as np

ParaViewBuildPath = "/home/ParaView-5.7.0/"
sys.path.append(ParaViewBuildPath + "lib/") 
sys.path.append(ParaViewBuildPath + "lib/python3.7/site-packages")
sys.path.append(ParaViewBuildPath + "lib/python3.7/site-packages/vtkmodules")

from paraview.simple import *   
# find source
mesh176_rightstl = FindSource('mesh176_right.stl')
generateSurfaceNormals1 = GenerateSurfaceNormals(Input=mesh176_rightstl)
# Properties modified on generateSurfaceNormals1
generateSurfaceNormals1.FeatureAngle = 15.0
# create a new 'Connectivity'
connectivity1 = Connectivity(Input=generateSurfaceNormals1)

# create a new 'Threshold'
threshold1 = Threshold(Input=connectivity1)
#threshold1.Scalars = ['POINTS', 'RegionId']

# Properties modified on threshold1
threshold1.ThresholdRange = [10.0, 982.0]

# create a new 'Extract Surface'
extractSurface1 = ExtractSurface(Input=threshold1)

# save data
SaveData('surf176.stl', proxy=extractSurface1, FileType='Ascii')

```

Link for stl file: [mesh](https://drive.google.com/file/d/1WhcohfL7Dcl91eUIePLDn4ZYaTJ4sCE0/view?usp=sharing)

---

<div class="post-metadata">

### Author: ![rasunag27](https://discourse.paraview.org/user_avatar/discourse.paraview.org/rasunag27/32/4636_2.png) [@rasunag27](https://discourse.paraview.org/u/rasunag27)
#### Post date: [March 30, 2021, 5:29am UTC](https://discourse.paraview.org/t/stl-file-is-not-saving-using-savedata-in-python/6770/4 "2021-03-30T05:29:37Z")

</div>

Dear Mathieu Westphal,

Thank you very much for the reply. I worked on printing the mesh.

print(mesh176\_rightstl) shows ‘None’.

I changed the directory, now the error is not there, but still the file is not saving.!! I tried with basic work example as

s = Sphere()  
SaveData( ‘sphere.stl’, proxy = s, FileType=‘Ascii’)

This works and saves the stl file. But not the one I needed.

Mesh link: [Mesh](https://drive.google.com/file/d/1WhcohfL7Dcl91eUIePLDn4ZYaTJ4sCE0/view?usp=sharing)

Regards,  
Sunag R A.

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.paraview.org/user_avatar/discourse.paraview.org/mwestphal/32/17_2.png) [@mwestphal](https://discourse.paraview.org/u/mwestphal)
#### Post date: [March 30, 2021, 7:26am UTC](https://discourse.paraview.org/t/stl-file-is-not-saving-using-savedata-in-python/6770/5 "2021-03-30T07:26:29Z")

</div>

Uncomment this line in your script:

```auto
#threshold1.Scalars = ['POINTS', 'RegionId']

```

---

<div class="post-metadata">

### Author: ![rasunag27](https://discourse.paraview.org/user_avatar/discourse.paraview.org/rasunag27/32/4636_2.png) [@rasunag27](https://discourse.paraview.org/u/rasunag27)
#### Post date: [March 30, 2021, 7:30am UTC](https://discourse.paraview.org/t/stl-file-is-not-saving-using-savedata-in-python/6770/6 "2021-03-30T07:30:18Z")

</div>

Well, I did try that too…!! But, still same issue. I also tried working with Paraview 5.9.0 with python 3.8. Also, same issue. I have addressed the full paraview trace in below link. It has all “display” things. So, removed those and shortened the code which is before post.

Full paraview trace link: [stlsplit\_paraview1.py](https://discourse.paraview.org/uploads/short-url/6RiBwp0RswebKFrbbb8IoLvGjNU.py) (6.3 KB)

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.paraview.org/user_avatar/discourse.paraview.org/mwestphal/32/17_2.png) [@mwestphal](https://discourse.paraview.org/u/mwestphal)
#### Post date: [March 30, 2021, 7:34am UTC](https://discourse.paraview.org/t/stl-file-is-not-saving-using-savedata-in-python/6770/7 "2021-03-30T07:34:33Z")

</div>

The following script works perfectly for me with ParaView 5.9.0

```
from paraview.simple import *   
# find source
mesh176_rightstl = OpenDataFile("/home/glow/tmp/mesh176_right.stl");
#mesh176_rightstl = FindSource('mesh176_right.stl')
generateSurfaceNormals1 = GenerateSurfaceNormals(Input=mesh176_rightstl)
# Properties modified on generateSurfaceNormals1
generateSurfaceNormals1.FeatureAngle = 15.0
# create a new 'Connectivity'
connectivity1 = Connectivity(Input=generateSurfaceNormals1)

# create a new 'Threshold'
threshold1 = Threshold(Input=connectivity1)
threshold1.Scalars = ['POINTS', 'RegionId']

# Properties modified on threshold1
threshold1.ThresholdRange = [10.0, 982.0]

# create a new 'Extract Surface'
extractSurface1 = ExtractSurface(Input=threshold1)

# save data
SaveData('surf176.stl', proxy=extractSurface1, FileType='Ascii')
```

---

<div class="post-metadata">

### Author: ![rasunag27](https://discourse.paraview.org/user_avatar/discourse.paraview.org/rasunag27/32/4636_2.png) [@rasunag27](https://discourse.paraview.org/u/rasunag27)
#### Post date: [March 30, 2021, 7:38am UTC](https://discourse.paraview.org/t/stl-file-is-not-saving-using-savedata-in-python/6770/8 "2021-03-30T07:38:53Z")

</div>

This works perfectly for me too…!! This is awesome…!!

I changed from FindSource to OpenDataFile as you have written.!!

Thank you so much for this…!! Just a line made me go out of line for few days…!! 😃 🤐

Regards,  
Sunag R A.
