Commit dfac149772d65f3027b0d3ec70fea5b3bca06348

Authored by Thiago Franco de Moraes
1 parent c83af65f
Exists in master

Verifying if surface has content (vertex and cells) before trying to export to a file

Showing 1 changed file with 11 additions and 1 deletions   Show diff stats
invesalius/data/surface.py
... ... @@ -876,7 +876,14 @@ class SurfaceManager():
876 876 os.remove(_temp_file)
877 877  
878 878 temp_file = utl.decode(temp_file, const.FS_ENCODE)
879   - self._export_surface(temp_file, filetype)
  879 + try:
  880 + self._export_surface(temp_file, filetype)
  881 + except ValueError:
  882 + if wx.GetApp() is None:
  883 + print("It was not possible to export the surface because the surface is empty")
  884 + else:
  885 + wx.MessageBox(_("It was not possible to export the surface because the surface is empty"), _("Export surface error"))
  886 + return
880 887  
881 888 shutil.move(temp_file, filename)
882 889  
... ... @@ -903,6 +910,9 @@ class SurfaceManager():
903 910 else:
904 911 polydata = pu.Merge(polydata_list)
905 912  
  913 + if polydata.GetNumberOfPoints() == 0:
  914 + raise ValueError
  915 +
906 916 # Having a polydata that represents all surfaces
907 917 # selected, we write it, according to filetype
908 918 if filetype == const.FILETYPE_STL:
... ...