Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for .zip files in drag-and-drop and file menu #658

Open
wants to merge 2 commits into
base: SteamEngine
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions Cura/gui/sceneView.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
import threading
import math
import platform
import zipfile
import tempfile

import OpenGL
OpenGL.ERROR_CHECKING = False
Expand Down Expand Up @@ -171,7 +173,15 @@ def loadFiles(self, filenames):
# pop first entry for processing and append new files at end
while filenames:
filename = filenames.pop(0)
if os.path.isdir(filename):
if filename.endswith('.zip'):
# Unpack zip, load all contained files.
destdir = tempfile.mkdtemp()
with zipfile.ZipFile(filename) as zipper:
zipper.extractall(destdir)
self.loadFiles([destdir])
# TODO: Cleanup (needs to be done safely)
continue
elif os.path.isdir(filename):
# directory: queue all included files and directories
filenames.extend(os.path.join(filename, f) for f in os.listdir(filename))
else:
Expand Down Expand Up @@ -201,7 +211,7 @@ def loadFiles(self, filenames):
def showLoadModel(self, button = 1):
if button == 1:
dlg=wx.FileDialog(self, _("Open 3D model"), os.path.split(profile.getPreference('lastFile'))[0], style=wx.FD_OPEN|wx.FD_FILE_MUST_EXIST|wx.FD_MULTIPLE)
dlg.SetWildcard(meshLoader.loadWildcardFilter() + imageToMesh.wildcardList() + "|GCode file (*.gcode)|*.g;*.gcode;*.G;*.GCODE")
dlg.SetWildcard(meshLoader.loadWildcardFilter() + imageToMesh.wildcardList() + "|GCode file (*.gcode)|*.g;*.gcode;*.G;*.GCODE|Zip file (*.zip)|*.zip")
if dlg.ShowModal() != wx.ID_OK:
dlg.Destroy()
return
Expand Down