Added copy to SD feature. Fixed #138
parent
7a6b9f367a
commit
22042b9f8b
|
@ -1,7 +1,7 @@
|
|||
from __future__ import absolute_import
|
||||
import __init__
|
||||
|
||||
import wx, os, platform, types
|
||||
import wx, os, platform, types, string
|
||||
import ConfigParser
|
||||
|
||||
from gui import configBase
|
||||
|
@ -52,6 +52,13 @@ class preferencesDialog(configBase.configWindowBase):
|
|||
#c = configBase.SettingRow(right, 'Slicer selection', 'slicer', ['Cura (Skeinforge based)', 'Slic3r'], 'Which slicer to use to slice objects. Usually the Cura engine produces the best results. But Slic3r is developing fast and is faster with slicing.', type = 'preference')
|
||||
c = configBase.SettingRow(right, 'Save profile on slice', 'save_profile', False, 'When slicing save the profile as [stl_file]_profile.ini next to the model.', type = 'preference')
|
||||
|
||||
configBase.TitleRow(right, 'SD Card settings')
|
||||
if len(getDrives()) > 1:
|
||||
c = configBase.SettingRow(right, 'SD card drive', 'sdpath', getDrives(), 'Location of your SD card, when using the copy to SD feature.', type = 'preference')
|
||||
else:
|
||||
c = configBase.SettingRow(right, 'SD card path', 'sdpath', '', 'Location of your SD card, when using the copy to SD feature.', type = 'preference')
|
||||
c = configBase.SettingRow(right, 'Copy to SD with 8.3 names', 'sdshortnames', False, 'Save the gcode files in short filenames, so they are properly shown on the UltiController', type = 'preference')
|
||||
|
||||
self.okButton = wx.Button(left, -1, 'Ok')
|
||||
left.GetSizer().Add(self.okButton, (left.GetSizer().GetRows(), 1))
|
||||
self.okButton.Bind(wx.EVT_BUTTON, self.OnClose)
|
||||
|
@ -65,3 +72,14 @@ class preferencesDialog(configBase.configWindowBase):
|
|||
wx.MessageBox('After changing the amount of extruders you need to restart Cura for full effect.', 'Extruder amount warning.', wx.OK | wx.ICON_INFORMATION)
|
||||
self.MakeModal(False)
|
||||
self.Destroy()
|
||||
|
||||
def getDrives():
|
||||
drives = ['']
|
||||
if platform.system() == "Windows":
|
||||
from ctypes import windll
|
||||
bitmask = windll.kernel32.GetLogicalDrives()
|
||||
for letter in string.uppercase:
|
||||
if bitmask & 1:
|
||||
drives.append(letter + ':/')
|
||||
bitmask >>= 1
|
||||
return drives
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
from __future__ import absolute_import
|
||||
import __init__
|
||||
|
||||
import wx, sys, os, math, threading, subprocess, time, re
|
||||
import wx, sys, os, shutil, math, threading, subprocess, time, re
|
||||
|
||||
from util import profile
|
||||
from util import sliceRun
|
||||
|
@ -70,6 +70,13 @@ class sliceProgessPanel(wx.Panel):
|
|||
def OnOpenFileLocation(self, e):
|
||||
exporer.openExporer(sliceRun.getExportFilename(self.filelist[0]))
|
||||
|
||||
def OnCopyToSD(self, e):
|
||||
exportFilename = sliceRun.getExportFilename(self.filelist[0])
|
||||
filename = os.path.basename(exportFilename)
|
||||
if profile.getPreference('sdshortnames') == 'True':
|
||||
filename = sliceRun.getShortFilename(filename)
|
||||
shutil.copy(exportFilename, os.path.join(profile.getPreference('sdpath'), filename))
|
||||
|
||||
def OnSliceDone(self, result):
|
||||
self.progressGauge.Destroy()
|
||||
self.abortButton.Destroy()
|
||||
|
@ -90,6 +97,10 @@ class sliceProgessPanel(wx.Panel):
|
|||
self.openFileLocationButton = wx.Button(self, -1, "Open file location")
|
||||
self.Bind(wx.EVT_BUTTON, self.OnOpenFileLocation, self.openFileLocationButton)
|
||||
self.sizer.Add(self.openFileLocationButton, 0)
|
||||
if profile.getPreference('sdpath') != '':
|
||||
self.copyToSDButton = wx.Button(self, -1, "To SDCard")
|
||||
self.Bind(wx.EVT_BUTTON, self.OnCopyToSD, self.copyToSDButton)
|
||||
self.sizer.Add(self.copyToSDButton, 0)
|
||||
self.showButton = wx.Button(self, -1, "Show result")
|
||||
self.Bind(wx.EVT_BUTTON, self.OnShowGCode, self.showButton)
|
||||
self.sizer.Add(self.showButton, 0)
|
||||
|
|
|
@ -161,6 +161,8 @@ preferencesDefaultSettings = {
|
|||
'save_profile': 'False',
|
||||
'filament_cost_kg': '0',
|
||||
'filament_cost_meter': '0',
|
||||
'sdpath': '',
|
||||
'sdshortnames': 'True',
|
||||
|
||||
'extruder_head_size_min_x': '70.0',
|
||||
'extruder_head_size_min_y': '18.0',
|
||||
|
|
|
@ -100,6 +100,12 @@ def runSlice(fileNames):
|
|||
def getExportFilename(filename, ext = "gcode"):
|
||||
return "%s_export.%s" % (filename[: filename.rfind('.')], ext)
|
||||
|
||||
#Get a short filename in 8.3 format for proper saving on SD.
|
||||
def getShortFilename(filename):
|
||||
ext = filename[filename.rfind('.'):]
|
||||
filename = filename[: filename.rfind('.')]
|
||||
return filename[:8] + ext[:2]
|
||||
|
||||
def getSliceCommand(filename):
|
||||
if profile.getPreference('slicer').startswith('Slic3r') and getSlic3rExe() != False:
|
||||
slic3rExe = getSlic3rExe()
|
||||
|
|
Loading…
Reference in New Issue