Ejemplo n.º 1
0
    def OnRun(self):
        self.progressLog = []
        p = sliceRun.startSliceCommandProcess(self.sliceCommand)
        line = p.stdout.readline()
        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.")
                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.progressGauge2.SetValue(self.fileCount)

        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()
        if cost is not None:
            status += "\nCost: %s" % (cost)
        profile.replaceGCodeTags(self.resultFilename, gcode)
        wx.CallAfter(self.statusText.SetLabel, status)
        wx.CallAfter(self.OnSliceDone)
Ejemplo n.º 2
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()
Ejemplo n.º 3
0
    def OnRun(self, index):
        while self.cmdIndex < len(self.sliceCmdList):
            cmdIndex = self.cmdIndex
            self.cmdIndex += 1
            action = self.sliceCmdList[cmdIndex]
            wx.CallAfter(
                self.SetTitle,
                _("Building: [%(index)d/%(size)d]") %
                (self.sliceCmdList.index(action) + 1, len(self.sliceCmdList)))

            p = sliceRun.startSliceCommandProcess(action)
            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, index, progress[0],
                                 int(progress[1]), maxValue)
                else:
                    wx.CallAfter(self.statusText[index].SetLabel, line)
                if self.abort:
                    p.terminate()
                    wx.CallAfter(self.statusText[index].SetLabel,
                                 _("Aborted by user."))
                    return
                line = p.stdout.readline()
            self.returnCode = p.wait()

            # Update output gocde file...
            # Warning: the user could have changed the profile between the slcer run and this code.  We might be using old information.
            gcodeFilename = self.outputFilenameList[index]
            gcode = gcodeInterpreter.gcode()
            gcode.load(gcodeFilename)
            profile.replaceGCodeTags(gcodeFilename, gcode)

            wx.CallAfter(self.progressGauge[index].SetValue, 10000)
            self.totalDoneFactor[index] = 0.0
            wx.CallAfter(
                self.progressTextTotal.SetLabel,
                _("Done %(index)d/%(size)d") %
                (self.cmdIndex, len(self.sliceCmdList)))
            wx.CallAfter(self.progressGaugeTotal.SetValue, self.cmdIndex)
Ejemplo n.º 4
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()
Ejemplo n.º 5
0
	def OnRun(self):
		self.progressLog = []
		p = sliceRun.startSliceCommandProcess(self.sliceCommand)
		line = p.stdout.readline()
		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.")
				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.progressGauge2.SetValue(self.fileCount)

		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()
		if cost is not None:
			status += "\nCost: %s" % (cost)
		profile.replaceGCodeTags(self.resultFilename, gcode)
		wx.CallAfter(self.statusText.SetLabel, status)
		wx.CallAfter(self.OnSliceDone)
Ejemplo n.º 6
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()
Ejemplo n.º 7
0
	def OnRun(self, index):
		while self.cmdIndex < len(self.sliceCmdList):
			cmdIndex = self.cmdIndex;
			self.cmdIndex += 1			
			action = self.sliceCmdList[cmdIndex]
			wx.CallAfter(self.SetTitle, "Building: [%d/%d]"  % (self.sliceCmdList.index(action) + 1, len(self.sliceCmdList)))

			p = sliceRun.startSliceCommandProcess(action)
			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, index, progress[0], int(progress[1]), maxValue)
				else:
					wx.CallAfter(self.statusText[index].SetLabel, line)
				if self.abort:
					p.terminate()
					wx.CallAfter(self.statusText[index].SetLabel, "Aborted by user.")
					return
				line = p.stdout.readline()
			self.returnCode = p.wait()

			# Update output gocde file...
			# Warning: the user could have changed the profile between the slcer run and this code.  We might be using old information.
			gcodeFilename = self.outputFilenameList[index]
			gcode = gcodeInterpreter.gcode()
			gcode.load(gcodeFilename)
			profile.replaceGCodeTags(gcodeFilename, gcode)
			
			wx.CallAfter(self.progressGauge[index].SetValue, 10000)
			self.totalDoneFactor[index] = 0.0
			wx.CallAfter(self.progressTextTotal.SetLabel, "Done %d/%d" % (self.cmdIndex, len(self.sliceCmdList)))
			wx.CallAfter(self.progressGaugeTotal.SetValue, self.cmdIndex)
	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)