Ejemplo n.º 1
0
    def OnExportSurface(self, filename, filetype):
        ftype_prefix = {
            const.FILETYPE_STL: '.stl',
            const.FILETYPE_VTP: '.vtp',
            const.FILETYPE_PLY: '.ply',
            const.FILETYPE_STL_ASCII: '.stl',
        }
        if filetype in ftype_prefix:
            temp_file = tempfile.mktemp(suffix=ftype_prefix[filetype])

            if _has_win32api:
                utl.touch(temp_file)
                _temp_file = temp_file
                temp_file = win32api.GetShortPathName(temp_file)
                os.remove(_temp_file)

            temp_file = utl.decode(temp_file, const.FS_ENCODE)
            try:
                self._export_surface(temp_file, filetype)
            except ValueError:
                if wx.GetApp() is None:
                    print(
                        "It was not possible to export the surface because the surface is empty"
                    )
                else:
                    wx.MessageBox(
                        _("It was not possible to export the surface because the surface is empty"
                          ), _("Export surface error"))
                return

            shutil.move(temp_file, filename)
Ejemplo n.º 2
0
 def OnExportPicture(self, pubsub_evt):
     id, filename, filetype = pubsub_evt.data
     if id == const.VOLUME:
         Publisher.sendMessage('Begin busy cursor')
         if _has_win32api:
             utils.touch(filename)
             win_filename = win32api.GetShortPathName(filename)
             self._export_picture(id, win_filename, filetype)
         else:
             self._export_picture(id, filename, filetype)
         Publisher.sendMessage('End busy cursor')
Ejemplo n.º 3
0
def Export(polydata, filename, bin=False):
    writer = vtkXMLPolyDataWriter()
    if _has_win32api:
        touch(filename)
        filename = win32api.GetShortPathName(filename)
    writer.SetFileName(filename.encode(const.FS_ENCODE))
    if bin:
        writer.SetDataModeToBinary()
    else:
        writer.SetDataModeToAscii()
    writer.SetInputData(polydata)
    writer.Write()
Ejemplo n.º 4
0
 def OnExportSurface(self, pubsub_evt):
     filename, filetype = pubsub_evt.data
     if filetype not in (const.FILETYPE_STL, const.FILETYPE_VTP,
                         const.FILETYPE_PLY, const.FILETYPE_STL_ASCII):
         if _has_win32api:
             utils.touch(filename)
             win_filename = win32api.GetShortPathName(filename)
             self._export_surface(win_filename.encode(const.FS_ENCODE),
                                  filetype)
         else:
             self._export_surface(filename.encode(const.FS_ENCODE),
                                  filetype)
Ejemplo n.º 5
0
def Export(polydata, filename, bin=False):
    writer = vtk.vtkXMLPolyDataWriter()
    if _has_win32api:
        touch(filename)
        filename = win32api.GetShortPathName(filename)
    writer.SetFileName(filename.encode(const.FS_ENCODE))
    if bin:
        writer.SetDataModeToBinary()
    else:
        writer.SetDataModeToAscii()
    writer.SetInputData(polydata)
    writer.Write()
Ejemplo n.º 6
0
def Compress(folder, filename, filelist):
    tmpdir, tmpdir_ = os.path.split(folder)
    current_dir = os.path.abspath(".")
    temp_inv3 = tempfile.mktemp()
    if _has_win32api:
        touch(temp_inv3)
        temp_inv3 = win32api.GetShortPathName(temp_inv3)

    temp_inv3 = temp_inv3.decode(const.FS_ENCODE)
    #os.chdir(tmpdir)
    #file_list = glob.glob(os.path.join(tmpdir_,"*"))
    tar = tarfile.open(temp_inv3, "w:gz")
    for name in filelist:
        tar.add(name, arcname=os.path.join(tmpdir_, filelist[name]))
    tar.close()
    shutil.move(temp_inv3, filename)
Ejemplo n.º 7
0
    def OnExportSurface(self, filename, filetype):
        ftype_prefix = {
            const.FILETYPE_STL: '.stl',
            const.FILETYPE_VTP: '.vtp',
            const.FILETYPE_PLY: '.ply',
            const.FILETYPE_STL_ASCII: '.stl',
        }
        if filetype in ftype_prefix:
            temp_file = tempfile.mktemp(suffix=ftype_prefix[filetype])

            if _has_win32api:
                utl.touch(temp_file)
                _temp_file = temp_file
                temp_file = win32api.GetShortPathName(temp_file)
                os.remove(_temp_file)

            temp_file = utl.decode(temp_file, const.FS_ENCODE)
            try:
                self._export_surface(temp_file, filetype)
            except ValueError:
                if wx.GetApp() is None:
                    print(
                        "It was not possible to export the surface because the surface is empty"
                    )
                else:
                    wx.MessageBox(
                        _("It was not possible to export the surface because the surface is empty"
                          ), _("Export surface error"))
                return

            try:
                shutil.move(temp_file, filename)
            except PermissionError as err:
                dirpath = os.path.split(filename)[0]
                if wx.GetApp() is None:
                    print(
                        _("It was not possible to export the surface because you don't have permission to write to {} folder: {}"
                          .format(dirpath, err)))
                else:
                    dlg = dialogs.ErrorMessageBox(
                        None, _("Export surface error"),
                        "It was not possible to export the surface because you don't have permission to write to {}:\n{}"
                        .format(dirpath, err))
                    dlg.ShowModal()
                    dlg.Destroy()
                os.remove(temp_file)
Ejemplo n.º 8
0
def Compress(folder, filename, filelist, compress=False):
    tmpdir, tmpdir_ = os.path.split(folder)
    current_dir = os.path.abspath(".")
    temp_inv3 = tempfile.mktemp()
    if _has_win32api:
        touch(temp_inv3)
        temp_inv3 = win32api.GetShortPathName(temp_inv3)

    temp_inv3 = decode(temp_inv3, const.FS_ENCODE)
    #os.chdir(tmpdir)
    #file_list = glob.glob(os.path.join(tmpdir_,"*"))
    if compress:
        tar = tarfile.open(temp_inv3, "w:gz")
    else:
        tar = tarfile.open(temp_inv3, "w")
    for name in filelist:
        tar.add(name, arcname=os.path.join(tmpdir_, filelist[name]))
    tar.close()
    shutil.move(temp_inv3, filename)
Ejemplo n.º 9
0
    def OnExportSurface(self, filename, filetype):
        ftype_prefix = {
            const.FILETYPE_STL: '.stl',
            const.FILETYPE_VTP: '.vtp',
            const.FILETYPE_PLY: '.ply',
            const.FILETYPE_STL_ASCII: '.stl',
        }
        if filetype in ftype_prefix:
            temp_file = tempfile.mktemp(suffix=ftype_prefix[filetype])

            if _has_win32api:
                utl.touch(temp_file)
                _temp_file = temp_file
                temp_file = win32api.GetShortPathName(temp_file)
                os.remove(_temp_file)

            temp_file = utl.decode(temp_file, const.FS_ENCODE)
            self._export_surface(temp_file, filetype)

            shutil.move(temp_file, filename)
Ejemplo n.º 10
0
    def OnExportSurface(self, filename, filetype):
        ftype_prefix = {
            const.FILETYPE_STL: '.stl',
            const.FILETYPE_VTP: '.vtp',
            const.FILETYPE_PLY: '.ply',
            const.FILETYPE_STL_ASCII: '.stl',
        }
        if filetype in ftype_prefix:
            temp_file = tempfile.mktemp(suffix=ftype_prefix[filetype])

            if _has_win32api:
                utl.touch(temp_file)
                _temp_file = temp_file
                temp_file = win32api.GetShortPathName(temp_file)
                os.remove(_temp_file)

            temp_file = utl.decode(temp_file, const.FS_ENCODE)
            self._export_surface(temp_file, filetype)

            shutil.move(temp_file, filename)