scene.add(m)
slicer.runSlicer(scene)
else:
- #Place any unused arguments as last file, so Cura starts with opening those files.
- if len(args) > 0:
- profile.putPreference('lastFile', ';'.join(args))
- profile.setPluginConfig([])
-
- #Do not import anything from Cura.gui before this spot, as the above code also needs to run in pypy.
from Cura.gui import app
- app.CuraApp().MainLoop()
+ app.CuraApp(args).MainLoop()
if __name__ == '__main__':
main()
import wx._core
class CuraApp(wx.App):
- def __init__(self):
+ def __init__(self, files):
if platform.system() == "Windows" and not 'PYCHARM_HOSTED' in os.environ:
super(CuraApp, self).__init__(redirect = True, filename = 'output.txt')
else:
self.mainWindow = None
self.splash = None
+ self.loadFiles = files
if sys.platform.startswith('darwin'):
#Do not show a splashscreen on OSX, as by Apple guidelines
def MacOpenFile(self, path):
try:
- self.mainWindow._loadModels([path])
+ self.mainWindow.OnDropFiles([path])
except Exception as e:
warnings.warn("File at {p} cannot be read: {e}".format(p=path, e=str(e)))
#If we haven't run it before, run the configuration wizard.
if profile.getPreference('machine_type') == 'unknown':
- if platform.system() == "Darwin":
+ if platform.system() == "Windows":
+ exampleFile = os.path.normpath(os.path.join(resources.resourceBasePath, 'example', 'UltimakerRobot_support.stl'))
+ else:
#Check if we need to copy our examples
exampleFile = os.path.expanduser('~/CuraExamples/UltimakerRobot_support.stl')
if not os.path.isfile(exampleFile):
pass
for filename in glob.glob(os.path.normpath(os.path.join(resources.resourceBasePath, 'example', '*.*'))):
shutil.copy(filename, os.path.join(os.path.dirname(exampleFile), os.path.basename(filename)))
- profile.putPreference('lastFile', exampleFile)
+ self.loadFiles = [exampleFile]
+ if self.splash is not None:
+ self.splash.Show(False)
configWizard.configWizard()
- #Hide the splashscreen before showing the main window.
- if self.splash is not None:
- self.splash.Show(False)
if profile.getPreference('check_for_updates') == 'True':
newVersion = version.checkForNewerVersion()
if newVersion is not None:
+ if self.splash is not None:
+ self.splash.Show(False)
if wx.MessageBox('A new version of Cura is available, would you like to download?', 'New version available', wx.YES_NO | wx.ICON_INFORMATION) == wx.YES:
webbrowser.open(newVersion)
return
self.mainWindow = mainWindow.mainWindow()
+ if self.splash is not None:
+ self.splash.Show(False)
+ self.mainWindow.Show()
+ self.mainWindow.OnDropFiles(self.loadFiles)
setFullScreenCapable(self.mainWindow)
self.menubar.Append(helpMenu, 'Help')
self.SetMenuBar(self.menubar)
- if profile.getPreference('lastFile') != '':
- self.filelist = profile.getPreference('lastFile').split(';')
- else:
- self.filelist = []
-
self.splitter = wx.SplitterWindow(self, style = wx.SP_3D | wx.SP_LIVE_UPDATE)
self.leftPane = wx.Panel(self.splitter, style=wx.BORDER_NONE)
self.rightPane = wx.Panel(self.splitter, style=wx.BORDER_NONE)
sizer.Layout()
self.sizer = sizer
- if len(self.filelist) > 0:
- self.scene.loadScene(self.filelist)
-
- # Update the Model MRU
- for idx in xrange(0, len(self.filelist)):
- self.addToModelMRU(self.filelist[idx])
-
self.updateProfileToControls()
self.SetBackgroundColour(self.normalSettingsPanel.GetBackgroundColour())
self.updateSliceMode()
- self.Show(True)
-
def updateSliceMode(self):
isSimple = profile.getPreference('startMode') == 'Simple'
self.glReleaseList.append(vbo)
self._gcodeVBOs = []
if ready:
+ print self._slicer.getFilamentAmount()
+ print self._slicer.getPrintTime()
+ print self._slicer.getFilamentCost()
self._gcode = gcodeInterpreter.gcode()
self._gcode.progressCallback = self._gcodeLoadCallback
self._thread = threading.Thread(target=self._loadGCode)
import subprocess
import time
+import math
import numpy
import os
import warnings
self._progressSteps = ['inset', 'skin', 'export']
self._objCount = 0
self._sliceLog = []
+ self._printTimeSeconds = None
+ self._filamentMM = None
def cleanup(self):
self.abortSlicer()
def getSliceLog(self):
return self._sliceLog
+ def getFilamentWeight(self):
+ #Calculates the weight of the filament in kg
+ radius = float(profile.getProfileSetting('filament_diameter')) / 2
+ volumeM3 = (self._filamentMM * (math.pi * radius * radius)) / (1000*1000*1000)
+ return volumeM3 * profile.getPreferenceFloat('filament_physical_density')
+
+ def getFilamentCost(self):
+ cost_kg = profile.getPreferenceFloat('filament_cost_kg')
+ cost_meter = profile.getPreferenceFloat('filament_cost_meter')
+ if cost_kg > 0.0 and cost_meter > 0.0:
+ return "%.2f / %.2f" % (self.getFilamentWeight() * cost_kg, self._filamentMM / 1000.0 * cost_meter)
+ elif cost_kg > 0.0:
+ return "%.2f" % (self.getFilamentWeight() * cost_kg)
+ elif cost_meter > 0.0:
+ return "%.2f" % (self._filamentMM / 1000.0 * cost_meter)
+ return None
+
+ def getPrintTime(self):
+ return '%02d:%02d' % (int(self._printTimeSeconds / 60 / 60), int(self._printTimeSeconds / 60) % 60)
+
+ def getFilamentAmount(self):
+ return '%0.2fm' % (float(self._filamentMM) / 1000.0)
+
def runSlicer(self, scene):
self.abortSlicer()
self._callback(0.0, False)
def _watchProcess(self):
self._callback(0.0, False)
self._sliceLog = []
+ self._printTimeSeconds = None
+ self._filamentMM = None
+
line = self._process.stdout.readline()
objectNr = 0
while len(line):
self._callback(progressValue, False)
except:
pass
+ elif line.startswith('Print time:'):
+ self._printTimeSeconds = int(line.split(':')[1].strip())
+ elif line.startswith('Filament:'):
+ self._filamentMM = int(line.split(':')[1].strip())
else:
self._sliceLog.append(line.strip())
line = self._process.stdout.readline()