# vtkSTLWriter unknown error

**URL:** https://discourse.vtk.org/t/vtkstlwriter-unknown-error/2334
**Category:** Support
**Created:** [December 25, 2019, 12:06pm UTC](https://discourse.vtk.org/t/vtkstlwriter-unknown-error/2334 "2019-12-25T12:06:51Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Inna\_Daymand](https://discourse.vtk.org/user_avatar/discourse.vtk.org/inna_daymand/32/1172_2.png) [@Inna\_Daymand](https://discourse.vtk.org/u/Inna_Daymand)
#### Post date: [December 25, 2019, 12:06pm UTC](https://discourse.vtk.org/t/vtkstlwriter-unknown-error/2334/1 "2019-12-25T12:06:51Z")

</div>

this is file name

c:\Users\Admin\workspace\TA\_PlacerOptimizer\General\_folder\Patient\_21007large\_TALPS\_2\_0\_InitNormAngles\_90\_90\_90\_  
90\EF14\_Patient\_21007\_Fully\_segmented.stl

this is my code in python

self.output\_data.stlWriter.SetFileName(output\_filename)  
self.output\_data.stlWriter.SetInputConnection(polydata\_transform\_filter.GetOutputPort())  
self.output\_data.stlWriter.Write()

after doing last command I am getting

stlWriter.ErrorCode=UnknownError

What it may be?

====================================================  
Answer

attempt to write an empty file

===============================  
Proposal

to do information in error code/message about this case

---

<div class="post-metadata">

### Author: ![Paulo\_Carvalho](https://discourse.vtk.org/user_avatar/discourse.vtk.org/paulo_carvalho/32/370_2.png) [@Paulo\_Carvalho](https://discourse.vtk.org/u/Paulo_Carvalho)
#### Post date: [December 26, 2019, 11:42am UTC](https://discourse.vtk.org/t/vtkstlwriter-unknown-error/2334/2 "2019-12-26T11:42:59Z")

</div>

Hello, Inna. I suggest you to double the backslashes in your path string: `c:\\Users\\Admin\\workspace\\TA_PlacerOptimizer\\General_folder\\Patient_21007large_TALPS_2_0_InitNormAngles_90_90_90_ 90\\EF14_Patient_21007_Fully_segmented.stl` The backslash is a metacharacter in C-like languages like Python. The double backslash will ensure an `\` in the output.

If that doesn’t work, If you ARE the Admin user, then try writing to a shorter path. Then I suggest eliminating file system-related issues like disk full, insufficient privileges, etc.

---

<div class="post-metadata">

### Author: ![Inna\_Daymand](https://discourse.vtk.org/user_avatar/discourse.vtk.org/inna_daymand/32/1172_2.png) [@Inna\_Daymand](https://discourse.vtk.org/u/Inna_Daymand)
#### Post date: [December 26, 2019, 1:21pm UTC](https://discourse.vtk.org/t/vtkstlwriter-unknown-error/2334/3 "2019-12-26T13:21:52Z")

</div>

Hi, Paulo,

thank you for answer. I wrote in my topic below, that I found in what my problem. My problem was in attempt to write empty file. If input data for vtkStlWriter is not empty, I haven’t problem.

I suggested also to developers to describe this situation in error code. Since I had got Unknown Error as error code for this case.

If I had have an error like “attempt to write empty file”, I wouldn’t spent a time to research of problem with “unknown error”.

It is all.  
Thank you.  
Inna

---

<div class="post-metadata">

### Author: ![Paulo\_Carvalho](https://discourse.vtk.org/user_avatar/discourse.vtk.org/paulo_carvalho/32/370_2.png) [@Paulo\_Carvalho](https://discourse.vtk.org/u/Paulo_Carvalho)
#### Post date: [December 26, 2019, 6:23pm UTC](https://discourse.vtk.org/t/vtkstlwriter-unknown-error/2334/4 "2019-12-26T18:23:45Z")

</div>

In this case you should report a bug here: [https://gitlab.kitware.com/groups/vtk/-/issues](https://gitlab.kitware.com/groups/vtk/-/issues) as writing an empty file is not supposed to trigger an error. Having a zero-byte file is odd, but it is not an error.

All the best,

Paulo

---

<div class="post-metadata">

### Author: ![lassoan](https://discourse.vtk.org/user_avatar/discourse.vtk.org/lassoan/32/50_2.png) [@lassoan](https://discourse.vtk.org/u/lassoan)
#### Post date: [December 26, 2019, 11:48pm UTC](https://discourse.vtk.org/t/vtkstlwriter-unknown-error/2334/5 "2019-12-26T23:48:02Z")

</div>

I agree that it would be sometimes useful to create empty “placeholder” files, but most mesh and image file formats do not allow such empty files. This is not a limitation of VTK.

[VTK should log an error message “No data to write!”](https://gitlab.kitware.com/vtk/vtk/blob/master/IO/Geometry/vtkSTLWriter.cxx#L77), but maybe the mechanism is not robust enough (if GetPoints returns non-nullptr but there are 0 points then maybe it does not log the message). It would be great if you could submit a merge request with a proposed fix.
