Exemplo n.º 1
0
	def OnPrint(self, e):
		if len(self.filelist) < 1:
			wx.MessageBox('You need to load a file and prepare it before you can print.', 'Print error', wx.OK | wx.ICON_INFORMATION)
			return
		if not os.path.exists(sliceRun.getExportFilename(self.filelist[0])):
			wx.MessageBox('You need to prepare a print before you can run the actual print.', 'Print error', wx.OK | wx.ICON_INFORMATION)
			return
		printWindow.printFile(sliceRun.getExportFilename(self.filelist[0]))
Exemplo n.º 2
0
 def OnPrint(self, e):
     if len(self.filelist) < 1:
         wx.MessageBox(
             'You need to load a file and prepare it before you can print.',
             'Print error', wx.OK | wx.ICON_INFORMATION)
         return
     if not os.path.exists(sliceRun.getExportFilename(self.filelist[0])):
         wx.MessageBox(
             'You need to prepare a print before you can run the actual print.',
             'Print error', wx.OK | wx.ICON_INFORMATION)
         return
     printWindow.printFile(sliceRun.getExportFilename(self.filelist[0]))
Exemplo n.º 3
0
	def loadModelFiles(self, filelist, showWarning = False):
		while len(filelist) > len(self.objectList):
			self.objectList.append(previewObject())
		for idx in xrange(len(filelist), len(self.objectList)):
			self.objectList[idx].mesh = None
			self.objectList[idx].filename = None
		for idx in xrange(0, len(filelist)):
			obj = self.objectList[idx]
			if obj.filename != filelist[idx]:
				obj.fileTime = None
				self.gcodeFileTime = None
				self.logFileTime = None
			obj.filename = filelist[idx]
		
		self.gcodeFilename = sliceRun.getExportFilename(filelist[0])
		#Do the STL file loading in a background thread so we don't block the UI.
		if self.loadThread is not None and self.loadThread.isAlive():
			self.abortLoading = True
			self.loadThread.join()
		self.abortLoading = False
		self.loadThread = threading.Thread(target=self.doFileLoadThread)
		self.loadThread.daemon = True
		self.loadThread.start()
		
		if showWarning:
			if (self.matrix - numpy.matrix([[1,0,0],[0,1,0],[0,0,1]], numpy.float64)).any() or len(profile.getPluginConfig()) > 0:
				self.ShowWarningPopup('Reset scale, rotation, mirror and plugins?', self.OnResetAll)
Exemplo n.º 4
0
	def OnCopyToSD(self, e):
		for f in self.filenameList:
			exportFilename = sliceRun.getExportFilename(f)
			filename = os.path.basename(exportFilename)
			if profile.getPreference('sdshortnames') == 'True':
				filename = sliceRun.getShortFilename(filename)
			shutil.copy(exportFilename, os.path.join(profile.getPreference('sdpath'), filename))
Exemplo n.º 5
0
 def OnCopyToSD(self, e):
     if profile.getPreference('sdpath') == '':
         wx.MessageBox(
             "You need to configure your SD card drive first before you can copy files to it.\nOpening the preferences now.",
             'No SD card drive.', wx.OK | wx.ICON_INFORMATION)
         prefDialog = preferencesDialog.preferencesDialog(self.GetParent())
         prefDialog.Centre()
         prefDialog.Show(True)
         if profile.getPreference('sdpath') == '':
             print "No path set"
             return
     exportFilename = sliceRun.getExportFilename(self.filelist[0])
     filename = os.path.basename(exportFilename)
     if profile.getPreference('sdshortnames') == 'True':
         filename = sliceRun.getShortFilename(filename)
     try:
         shutil.copy(
             exportFilename,
             os.path.join(profile.getPreference('sdpath'), filename))
     except:
         self.GetParent().preview3d.ShowWarningPopup(
             "Failed to copy file to SD card.")
         return
     self.GetParent().preview3d.ShowWarningPopup(
         "Copy finished, safely remove SD card?", self.OnSafeRemove)
Exemplo n.º 6
0
	def __init__(self, mainWindow, parent, filelist):
		wx.Panel.__init__(self, parent, -1)
		self.mainWindow = mainWindow
		self.filelist = filelist
		self.abort = False
		
		box = wx.StaticBox(self, -1, filelist[0])
		self.sizer = wx.StaticBoxSizer(box, wx.HORIZONTAL)

		mainSizer = wx.BoxSizer(wx.VERTICAL) 
		mainSizer.Add(self.sizer, 0, flag=wx.EXPAND)

		self.statusText = wx.StaticText(self, -1, "Starting...")
		self.progressGauge = wx.Gauge(self, -1)
		self.progressGauge.SetRange(10000 * len(filelist))
		self.abortButton = wx.Button(self, -1, "X", style=wx.BU_EXACTFIT)
		self.sizer.Add(self.statusText, 2, flag=wx.ALIGN_CENTER )
		self.sizer.Add(self.progressGauge, 2)
		self.sizer.Add(self.abortButton, 0)

		self.Bind(wx.EVT_BUTTON, self.OnAbort, self.abortButton)

		self.SetSizer(mainSizer)
		self.prevStep = 'start'
		self.totalDoneFactor = 0.0
		self.startTime = time.time()
		if profile.getPreference('save_profile') == 'True':
			profile.saveGlobalProfile(self.filelist[0][: self.filelist[0].rfind('.')] + "_profile.ini")
		center = profile.getMachineCenterCoords() + profile.getObjectMatrix()
		cmdList = [sliceRun.getSliceCommand(sliceRun.getExportFilename(self.filelist[0]), ['|'.join(self.filelist)], [center])]
		self.thread = WorkerThread(self, filelist, cmdList)
Exemplo n.º 7
0
    def loadModelFiles(self, filelist, showWarning=False):
        while len(filelist) > len(self.objectList):
            self.objectList.append(previewObject())
        for idx in xrange(len(filelist), len(self.objectList)):
            self.objectList[idx].mesh = None
            self.objectList[idx].filename = None
        for idx in xrange(0, len(filelist)):
            obj = self.objectList[idx]
            if obj.filename != filelist[idx]:
                obj.fileTime = None
                self.gcodeFileTime = None
                self.logFileTime = None
                obj.mesh = None
            obj.filename = filelist[idx]

        self.deselectTool()
        self.gcodeFilename = sliceRun.getExportFilename(filelist[0])
        self.gcode = None
        #Do the STL file loading in a background thread so we don't block the UI.
        if self.loadThread is not None and self.loadThread.isAlive():
            self.abortLoading = True
            self.loadThread.join()
        self.abortLoading = False
        self.loadThread = threading.Thread(target=self.doFileLoadThread)
        self.loadThread.daemon = True
        self.loadThread.start()

        if showWarning:
            if (self.matrix - numpy.matrix([[1, 0, 0], [0, 1, 0], [0, 0, 1]],
                                           numpy.float64)).any() or len(
                                               profile.getPluginConfig()) > 0:
                self.ShowWarningPopup(
                    'Reset scale, rotation, mirror and plugins?',
                    self.OnResetAll)
Exemplo n.º 8
0
	def OnCopyToSD(self, e):
		for f in self.filenameList:
			exportFilename = sliceRun.getExportFilename(f)
			filename = os.path.basename(exportFilename)
			if profile.getPreference('sdshortnames') == 'True':
				filename = sliceRun.getShortFilename(filename)
			shutil.copy(exportFilename, os.path.join(profile.getPreference('sdpath'), filename))
Exemplo n.º 9
0
	def loadModelFiles(self, filelist, showWarning = False):
		while len(filelist) > len(self.objectList):
			self.objectList.append(previewObject())
		for idx in xrange(len(filelist), len(self.objectList)):
			self.objectList[idx].mesh = None
			self.objectList[idx].filename = None
		for idx in xrange(0, len(filelist)):
			obj = self.objectList[idx]
			if obj.filename != filelist[idx]:
				obj.fileTime = None
				self.gcodeFileTime = None
				self.logFileTime = None
			obj.filename = filelist[idx]
		
		self.gcodeFilename = sliceRun.getExportFilename(filelist[0])
		#Do the STL file loading in a background thread so we don't block the UI.
		if self.loadThread != None and self.loadThread.isAlive():
			self.loadThread.join()
		self.loadThread = threading.Thread(target=self.doFileLoadThread)
		self.loadThread.daemon = True
		self.loadThread.start()
		
		if showWarning:
			if profile.getProfileSettingFloat('model_scale') != 1.0 or profile.getProfileSettingFloat('model_rotate_base') != 0 or profile.getProfileSetting('flip_x') != 'False' or profile.getProfileSetting('flip_y') != 'False' or profile.getProfileSetting('flip_z') != 'False' or profile.getProfileSetting('swap_xz') != 'False' or profile.getProfileSetting('swap_yz') != 'False' or len(profile.getPluginConfig()) > 0:
				self.ShowWarningPopup('Reset scale, rotation, mirror and plugins?', self.OnResetAll)
Exemplo n.º 10
0
	def _stitchMultiExtruder(self):
		files = []
		resultFile = open(sliceRun.getExportFilename(self.filelist[0]), "w")
		resultFile.write(';TYPE:CUSTOM\n')
		resultFile.write(profile.getAlterationFileContents('start.gcode'))
		for filename in self.filelist:
			if os.path.isfile(sliceRun.getExportFilename(filename, 'multi_extrude_tmp')):
				files.append(open(sliceRun.getExportFilename(filename, 'multi_extrude_tmp'), "r"))
			else:
				return
		
		currentExtruder = 0
		resultFile.write('T%d\n' % (currentExtruder))
		layerNr = -1
		hasLine = True
		filesOrder = files[:]
		while hasLine:
			hasLine = False
			filesOrder.reverse()
			for f in filesOrder:
				layerHasLine = False
				for line in f:
					hasLine = True
					if line.startswith(';LAYER:'):
						break
					if 'Z' in line:
						lastZ = float(re.search('Z([^\s]+)', line).group(1))
					if not layerHasLine:
						nextExtruder = files.index(f)
						resultFile.write(';LAYER:%d\n' % (layerNr))
						resultFile.write(';EXTRUDER:%d\n' % (nextExtruder))
						if nextExtruder != currentExtruder:
							resultFile.write(';TYPE:CUSTOM\n')
							profile.setTempOverride('extruder', nextExtruder)
							resultFile.write(profile.getAlterationFileContents('switchExtruder.gcode') + '\n')
							profile.resetTempOverride()
							currentExtruder = nextExtruder
						layerHasLine = True
					resultFile.write(line)
			layerNr += 1
		for f in files:
			f.close()
		for filename in self.filelist:
			os.remove(sliceRun.getExportFilename(filename, 'multi_extrude_tmp'))
		resultFile.write(';TYPE:CUSTOM\n')
		resultFile.write(profile.getAlterationFileContents('end.gcode'))
		resultFile.close()
Exemplo n.º 11
0
	def OnSlice(self, e):
		sliceCmdList = []
		center = profile.getMachineCenterCoords()
		for filename in self.list:
			sliceCmdList.append(sliceRun.getSliceCommand(sliceRun.getExportFilename(filename), [filename], [center]))
		bspw = BatchSliceProgressWindow(self.list[:], sliceCmdList)
		bspw.Centre()
		bspw.Show(True)
Exemplo n.º 12
0
    def __init__(self, mainWindow, parent, filelist):
        wx.Panel.__init__(self, parent, -1)
        self.mainWindow = mainWindow
        self.filelist = filelist
        self.abort = False

        box = wx.StaticBox(self, -1, filelist[0])
        self.sizer = wx.StaticBoxSizer(box, wx.HORIZONTAL)

        mainSizer = wx.BoxSizer(wx.VERTICAL)
        mainSizer.Add(self.sizer, 0, flag=wx.EXPAND)

        self.statusText = wx.StaticText(self, -1, "Starting...")
        self.progressGauge = wx.Gauge(self, -1)
        self.progressGauge.SetRange(10000 * len(filelist))
        self.abortButton = wx.Button(self, -1, "X", style=wx.BU_EXACTFIT)
        self.sizer.Add(self.statusText, 2, flag=wx.ALIGN_CENTER)
        self.sizer.Add(self.progressGauge, 2)
        self.sizer.Add(self.abortButton, 0)

        self.Bind(wx.EVT_BUTTON, self.OnAbort, self.abortButton)

        self.SetSizer(mainSizer)
        self.prevStep = 'start'
        self.totalDoneFactor = 0.0
        self.startTime = time.time()
        if profile.getPreference('save_profile') == 'True':
            profile.saveGlobalProfile(
                self.filelist[0][:self.filelist[0].rfind('.')] +
                "_profile.ini")
        center = profile.getMachineCenterCoords() + profile.getObjectMatrix()
        outputFilename = sliceRun.getExportFilename(self.filelist[0])

        if profile.getPreference('filename_prompt') == 'True' or (
                os.path.exists(outputFilename)
                and profile.getPreference('file_overwrite_prompt') == 'True'):
            style = wx.FD_SAVE
            if profile.getPreference('file_overwrite_prompt') == 'True':
                style = style | wx.FD_OVERWRITE_PROMPT
            dlg = wx.FileDialog(self,
                                "Select gcode file to save",
                                os.path.split(outputFilename)[0],
                                os.path.split(outputFilename)[1],
                                style=style)
            dlg.SetWildcard("gcode files (*.gcode, *.g)|*.gcode;*.g")
            if dlg.ShowModal() != wx.ID_OK:
                dlg.Destroy()
                self.abort = True
                self.statusText.SetLabel("Aborted by user.")
                return
            outputFilename = dlg.GetPath()
            dlg.Destroy()

        cmdList = [
            sliceRun.getSliceCommand(outputFilename, ['|'.join(self.filelist)],
                                     [center])
        ]
        self.thread = WorkerThread(self, filelist, cmdList)
Exemplo n.º 13
0
    def __init__(self, mainWindow, parent, filelist):
        wx.Panel.__init__(self, parent, -1)
        self.mainWindow = mainWindow
        self.filelist = filelist
        self.abort = False

        box = wx.StaticBox(self, -1, filelist[0])
        self.sizer = wx.StaticBoxSizer(box, wx.HORIZONTAL)

        mainSizer = wx.BoxSizer(wx.VERTICAL)
        mainSizer.Add(self.sizer, 0, flag=wx.EXPAND)

        self.statusText = wx.StaticText(self, -1, "Starting...")
        self.progressGauge = wx.Gauge(self, -1)
        self.progressGauge.SetRange(10000 * len(filelist))
        self.abortButton = wx.Button(self, -1, "X", style=wx.BU_EXACTFIT)
        self.sizer.Add(self.statusText, 2, flag=wx.ALIGN_CENTER)
        self.sizer.Add(self.progressGauge, 2)
        self.sizer.Add(self.abortButton, 0)

        self.Bind(wx.EVT_BUTTON, self.OnAbort, self.abortButton)

        self.SetSizer(mainSizer)
        self.prevStep = "start"
        self.totalDoneFactor = 0.0
        self.startTime = time.time()
        if profile.getPreference("save_profile") == "True":
            profile.saveGlobalProfile(self.filelist[0][: self.filelist[0].rfind(".")] + "_profile.ini")
        center = profile.getMachineCenterCoords() + profile.getObjectMatrix()
        outputFilename = sliceRun.getExportFilename(self.filelist[0])

        if profile.getPreference("filename_prompt") == "True" or (
            os.path.exists(outputFilename) and profile.getPreference("file_overwrite_prompt") == "True"
        ):
            style = wx.FD_SAVE
            if profile.getPreference("file_overwrite_prompt") == "True":
                style = style | wx.FD_OVERWRITE_PROMPT
            dlg = wx.FileDialog(
                self,
                "Select gcode file to save",
                os.path.split(outputFilename)[0],
                os.path.split(outputFilename)[1],
                style=style,
            )
            dlg.SetWildcard("gcode files (*.gcode, *.g)|*.gcode;*.g")
            if dlg.ShowModal() != wx.ID_OK:
                dlg.Destroy()
                self.abort = True
                self.statusText.SetLabel("Aborted by user.")
                return
            outputFilename = dlg.GetPath()
            dlg.Destroy()

        cmdList = [sliceRun.getSliceCommand(outputFilename, ["|".join(self.filelist)], [center])]
        self.thread = WorkerThread(self, filelist, cmdList)
Exemplo n.º 14
0
	def OnSlice(self, e):
		sliceCmdList = []
		outputFilenameList = []
		center = profile.getMachineCenterCoords() + profile.getObjectMatrix()
		for filename in self.list:
			outputFilename = sliceRun.getExportFilename(filename)
			outputFilenameList.append(outputFilename)
			sliceCmdList.append(sliceRun.getSliceCommand(outputFilename, [filename], [center]))
		bspw = BatchSliceProgressWindow(self.list[:], outputFilenameList, sliceCmdList)
		bspw.Centre()
		bspw.Show(True)
Exemplo n.º 15
0
	def run(self):
		p = sliceRun.startSliceCommandProcess(self.cmdList[self.fileIdx])
		line = p.stdout.readline()
		self.progressLog = []
		maxValue = 1
		while(len(line) > 0):
			line = line.rstrip()
			if line[0:9] == "Progress[" and line[-1:] == "]":
				progress = line[9:-1].split(":")
				if len(progress) > 2:
					maxValue = int(progress[2])
				wx.CallAfter(self.notifyWindow.SetProgress, progress[0], int(progress[1]), maxValue)
			else:
				self.progressLog.append(line)
				wx.CallAfter(self.notifyWindow.statusText.SetLabel, line)
			if self.notifyWindow.abort:
				p.terminate()
				wx.CallAfter(self.notifyWindow.statusText.SetLabel, "Aborted by user.")
				return
			line = p.stdout.readline()
		line = p.stderr.readline()
		while(len(line) > 0):
			line = line.rstrip()
			self.progressLog.append(line)
			line = p.stderr.readline()
		self.returnCode = p.wait()
		self.fileIdx += 1
		if self.fileIdx == len(self.cmdList):
			if len(self.filelist) > 1:
				self._stitchMultiExtruder()
			gcodeFilename = sliceRun.getExportFilename(self.filelist[0])
			gcodefile = open(gcodeFilename, "a")
			for logLine in self.progressLog:
				if logLine.startswith('Model error('):
					gcodefile.write(';%s\n' % (logLine))
			gcodefile.close()
			wx.CallAfter(self.notifyWindow.statusText.SetLabel, "Running plugins")
			ret = profile.runPostProcessingPlugins(gcodeFilename)
			if ret != None:
				self.progressLog.append(ret)
			self.gcode = gcodeInterpreter.gcode()
			self.gcode.load(gcodeFilename)
			profile.replaceGCodeTags(gcodeFilename, self.gcode)
			wx.CallAfter(self.notifyWindow.OnSliceDone, self)
		else:
			self.run()
Exemplo n.º 16
0
 def run(self):
     p = sliceRun.startSliceCommandProcess(self.cmdList[self.fileIdx])
     line = p.stdout.readline()
     self.progressLog = []
     maxValue = 1
     starttime = time.time()
     while len(line) > 0:
         line = line.rstrip()
         if line[0:9] == "Progress[" and line[-1:] == "]":
             progress = line[9:-1].split(":")
             if len(progress) > 2:
                 maxValue = int(progress[2])
             wx.CallAfter(self.notifyWindow.SetProgress, progress[0],
                          int(progress[1]), maxValue)
         else:
             self.progressLog.append("%0.2f: %s" %
                                     (time.time() - starttime, line))
             wx.CallAfter(self.notifyWindow.statusText.SetLabel, line)
         if self.notifyWindow.abort:
             p.terminate()
             wx.CallAfter(self.notifyWindow.mainWindow.removeSliceProgress,
                          self.notifyWindow)
             return
         line = p.stdout.readline()
     line = p.stderr.readline()
     while len(line) > 0:
         line = line.rstrip()
         self.progressLog.append(line)
         line = p.stderr.readline()
     self.returnCode = p.wait()
     self.fileIdx += 1
     if self.fileIdx == len(self.cmdList):
         gcodeFilename = sliceRun.getExportFilename(self.filelist[0])
         gcodefile = open(gcodeFilename, "a")
         for logLine in self.progressLog:
             if logLine.startswith('Model error('):
                 gcodefile.write(';%s\n' % (logLine))
         gcodefile.close()
         self.gcode = gcodeInterpreter.gcode()
         self.gcode.load(gcodeFilename)
         profile.replaceGCodeTags(gcodeFilename, self.gcode)
         wx.CallAfter(self.notifyWindow.OnSliceDone, self)
     else:
         self.run()
Exemplo n.º 17
0
	def OnCopyToSD(self, e):
		if profile.getPreference('sdpath') == '':
			wx.MessageBox("You need to configure your SD card drive first before you can copy files to it.\nOpening the preferences now.", 'No SD card drive.', wx.OK | wx.ICON_INFORMATION)
			prefDialog = preferencesDialog.preferencesDialog(self.GetParent())
			prefDialog.Centre()
			prefDialog.Show(True)
			if profile.getPreference('sdpath') == '':
				print "No path set"
				return
		exportFilename = sliceRun.getExportFilename(self.filelist[0])
		filename = os.path.basename(exportFilename)
		if profile.getPreference('sdshortnames') == 'True':
			filename = sliceRun.getShortFilename(filename)
		try:
			shutil.copy(exportFilename, os.path.join(profile.getPreference('sdpath'), filename))
		except:
			self.GetParent().preview3d.ShowWarningPopup("Failed to copy file to SD card.")
			return
		self.GetParent().preview3d.ShowWarningPopup("Copy finished, safely remove SD card?", self.OnSafeRemove)
Exemplo n.º 18
0
	def run(self):
		p = sliceRun.startSliceCommandProcess(self.cmdList[self.fileIdx])
		line = p.stdout.readline()
		self.progressLog = []
		maxValue = 1
		starttime = time.time()
		while len(line) > 0:
			line = line.rstrip()
			if line[0:9] == "Progress[" and line[-1:] == "]":
				progress = line[9:-1].split(":")
				if len(progress) > 2:
					maxValue = int(progress[2])
				wx.CallAfter(self.notifyWindow.SetProgress, progress[0], int(progress[1]), maxValue)
			else:
				self.progressLog.append("%0.2f: %s" % (time.time() - starttime, line))
				wx.CallAfter(self.notifyWindow.statusText.SetLabel, line)
			if self.notifyWindow.abort:
				p.terminate()
				wx.CallAfter(self.notifyWindow.mainWindow.removeSliceProgress, self.notifyWindow)
				return
			line = p.stdout.readline()
		line = p.stderr.readline()
		while len(line) > 0:
			line = line.rstrip()
			self.progressLog.append(line)
			line = p.stderr.readline()
		self.returnCode = p.wait()
		self.fileIdx += 1
		if self.fileIdx == len(self.cmdList):
			gcodeFilename = sliceRun.getExportFilename(self.filelist[0])
			gcodefile = open(gcodeFilename, "a")
			for logLine in self.progressLog:
				if logLine.startswith('Model error('):
					gcodefile.write(';%s\n' % (logLine))
			gcodefile.close()
			self.gcode = gcodeInterpreter.gcode()
			self.gcode.load(gcodeFilename)
			profile.replaceGCodeTags(gcodeFilename, self.gcode)
			wx.CallAfter(self.notifyWindow.OnSliceDone, self)
		else:
			self.run()
Exemplo n.º 19
0
    def __init__(self, mainWindow, parent, filelist):
        wx.Panel.__init__(self, parent, -1)
        self.mainWindow = mainWindow
        self.filelist = filelist
        self.abort = False

        box = wx.StaticBox(self, -1, filelist[0])
        self.sizer = wx.StaticBoxSizer(box, wx.HORIZONTAL)

        mainSizer = wx.BoxSizer(wx.VERTICAL)
        mainSizer.Add(self.sizer, 0, flag=wx.EXPAND)

        self.statusText = wx.StaticText(self, -1, "Starting...")
        self.progressGauge = wx.Gauge(self, -1)
        self.progressGauge.SetRange(10000 * len(filelist))
        self.abortButton = wx.Button(self, -1, "X", style=wx.BU_EXACTFIT)
        self.sizer.Add(self.statusText, 2, flag=wx.ALIGN_CENTER)
        self.sizer.Add(self.progressGauge, 2)
        self.sizer.Add(self.abortButton, 0)

        self.Bind(wx.EVT_BUTTON, self.OnAbort, self.abortButton)

        self.SetSizer(mainSizer)
        self.prevStep = 'start'
        self.totalDoneFactor = 0.0
        self.startTime = time.time()
        if profile.getPreference('save_profile') == 'True':
            profile.saveGlobalProfile(
                self.filelist[0][:self.filelist[0].rfind('.')] +
                "_profile.ini")
        center = profile.getMachineCenterCoords() + profile.getObjectMatrix()
        cmdList = [
            sliceRun.getSliceCommand(
                sliceRun.getExportFilename(self.filelist[0]),
                ['|'.join(self.filelist)], [center])
        ]
        self.thread = WorkerThread(self, filelist, cmdList)
	def OnRun(self):
		resultFile = open(self.resultFilename, "w")
		put = profile.setTempOverride
		self.progressLog = []
		for action in self.actionList:
			wx.CallAfter(self.SetTitle, "Building: [%d/%d]"  % (self.actionList.index(action) + 1, len(self.actionList)))
			if not action.usePreviousSlice:
				p = sliceRun.startSliceCommandProcess(action.sliceCmd)
				line = p.stdout.readline()
		
				maxValue = 1
				while(len(line) > 0):
					line = line.rstrip()
					if line[0:9] == "Progress[" and line[-1:] == "]":
						progress = line[9:-1].split(":")
						if len(progress) > 2:
							maxValue = int(progress[2])
						wx.CallAfter(self.SetProgress, progress[0], int(progress[1]), maxValue)
					else:
						self.progressLog.append(line)
						wx.CallAfter(self.statusText.SetLabel, line)
					if self.abort:
						p.terminate()
						wx.CallAfter(self.statusText.SetLabel, "Aborted by user.")
						resultFile.close()
						return
					line = p.stdout.readline()
				self.returnCode = p.wait()
			
			put('object_center_x', action.centerX - self.extruderOffset[action.extruder][0])
			put('object_center_y', action.centerY - self.extruderOffset[action.extruder][1])
			put('clear_z', action.clearZ)
			put('extruder', action.extruder)
			put('print_temperature', action.temperature)
			
			if action == self.actionList[0]:
				resultFile.write(';TYPE:CUSTOM\n')
				resultFile.write('T%d\n' % (action.extruder))
				currentExtruder = action.extruder
				prevTemp = action.temperature
				startGCode = profile.getAlterationFileContents('start.gcode')
				startGCode = startGCode.replace('?filename?', 'Multiple files')
				resultFile.write(startGCode)
			else:
				#reset the extrusion length, and move to the next object center.
				resultFile.write(';TYPE:CUSTOM\n')
				if prevTemp != action.temperature and action.temperature > 0:
					resultFile.write('M104 S%d\n' % (int(action.temperature)))
					prevTemp = action.temperature
				resultFile.write(profile.getAlterationFileContents('nextobject.gcode'))
			resultFile.write(';PRINTNR:%d\n' % self.actionList.index(action))
			profile.resetTempOverride()
			
			if not action.usePreviousSlice:
				f = open(sliceRun.getExportFilename(action.filename, "project_tmp"), "r")
				data = f.read(4096)
				while data != '':
					resultFile.write(data)
					data = f.read(4096)
				f.close()
				savedCenterX = action.centerX
				savedCenterY = action.centerY
			else:
				f = open(sliceRun.getExportFilename(action.filename, "project_tmp"), "r")
				for line in f:
					if line[0] != ';':
						if 'X' in line:
							line = self._adjustNumberInLine(line, 'X', action.centerX - savedCenterX)
						if 'Y' in line:
							line = self._adjustNumberInLine(line, 'Y', action.centerY - savedCenterY)
					resultFile.write(line)
				f.close()

			if not action.leaveResultForNextSlice:
				os.remove(sliceRun.getExportFilename(action.filename, "project_tmp"))
			
			wx.CallAfter(self.progressGauge.SetValue, 10000)
			self.totalDoneFactor = 0.0
			wx.CallAfter(self.progressGauge2.SetValue, self.actionList.index(action) + 1)
		
		resultFile.write(';TYPE:CUSTOM\n')
		if len(self.actionList) > 1 and self.actionList[-1].clearZ > 1:
			#only move to higher Z if we have sliced more then 1 object. This solves the "move into print after printing" problem with the print-all-at-once option.
			resultFile.write('G1 Z%f F%f\n' % (self.actionList[-1].clearZ, profile.getProfileSettingFloat('max_z_speed') * 60))
		resultFile.write(profile.getAlterationFileContents('end.gcode'))
		resultFile.close()
		
		gcode = gcodeInterpreter.gcode()
		gcode.load(self.resultFilename)
		
		self.abort = True
		sliceTime = time.time() - self.sliceStartTime
		status = "Build: %s" % (self.resultFilename)
		status += "\nSlicing took: %02d:%02d" % (sliceTime / 60, sliceTime % 60)
		status += "\nFilament: %.2fm %.2fg" % (gcode.extrusionAmount / 1000, gcode.calculateWeight() * 1000)
		status += "\nPrint time: %02d:%02d" % (int(gcode.totalMoveTimeMinute / 60), int(gcode.totalMoveTimeMinute % 60))
		cost = gcode.calculateCost()
		self.totalMoveTimeMinute = gcode.totalMoveTimeMinute
		if cost != False:
			status += "\nCost: %s" % (cost)
		profile.replaceGCodeTags(self.resultFilename, gcode)

		wx.CallAfter(self.statusText.SetLabel, status)
		wx.CallAfter(self.OnSliceDone)
Exemplo n.º 21
0
	def OnOpenFileLocation(self, e):
		explorer.openExplorer(sliceRun.getExportFilename(self.filelist[0]))
Exemplo n.º 22
0
 def OnOpenFileLocation(self, e):
     explorer.openExplorer(sliceRun.getExportFilename(self.filelist[0]))