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()
def main(): parser = OptionParser(usage="usage: %prog [options] <X,Y> <filename>[, <X,Y> <filename>][, ...]") parser.add_option("-p", "--profile", action="store", type="string", dest="profile", help="Encoded profile to use for the print") parser.add_option("-o", "--output", action="store", type="string", dest="output", help="Output filename") (options, args) = parser.parse_args() if options.output is None: print 'Missing output filename' sys.exit(1) if options.profile is not None: profile.loadGlobalProfileFromString(options.profile) options.output = fixUTF8(options.output) clearZ = 0 resultFile = open(options.output, "w") for idx in xrange(0, len(args), 2): position = map(float, args[idx].split(',')) if len(position) < 9 + 2: position = position[0:2] position += [1,0,0] position += [0,1,0] position += [0,0,1] filenames = fixUTF8(args[idx + 1]).split('|') profile.setTempOverride('object_center_x', position[0]) profile.setTempOverride('object_center_y', position[1]) if idx == 0: resultFile.write(';TYPE:CUSTOM\n') resultFile.write(profile.getAlterationFileContents('start.gcode').replace('?filename?', ' '.join(filenames).encode('ascii', 'replace'))) else: resultFile.write(';TYPE:CUSTOM\n') n = output[-1].rfind('Z')+1 zString = output[-1][n:n+20] zString = zString[0:zString.find(' ')] clearZ = max(clearZ, float(zString) + 10) profile.setTempOverride('clear_z', clearZ) resultFile.write(profile.getAlterationFileContents('nextobject.gcode').replace('?filename?', ' '.join(filenames).encode('ascii', 'replace'))) output = [] for filename in filenames: extruderNr = filenames.index(filename) profile.resetTempOverride() if extruderNr > 0: profile.setTempOverride('object_center_x', position[0] - profile.getPreferenceFloat('extruder_offset_x%d' % (extruderNr))) profile.setTempOverride('object_center_y', position[1] - profile.getPreferenceFloat('extruder_offset_y%d' % (extruderNr))) profile.setTempOverride('fan_enabled', 'False') profile.setTempOverride('skirt_line_count', '0') profile.setTempOverride('alternative_center', filenames[0]) else: profile.setTempOverride('object_center_x', position[0]) profile.setTempOverride('object_center_y', position[1]) profile.setTempOverride('object_matrix', ','.join(map(str, position[2:11]))) output.append(export.getOutput(filename)) profile.resetTempOverride() if len(output) == 1: resultFile.write(output[0]) else: stitchMultiExtruder(output, resultFile) resultFile.write(';TYPE:CUSTOM\n') resultFile.write(profile.getAlterationFileContents('end.gcode')) resultFile.close() print "Running plugins" ret = profile.runPostProcessingPlugins(options.output) if ret is not None: print ret print "Finalizing %s" % (os.path.basename(options.output))
def main(): parser = OptionParser( usage= "usage: %prog [options] <X,Y> <filename>[, <X,Y> <filename>][, ...]") parser.add_option("-p", "--profile", action="store", type="string", dest="profile", help="Encoded profile to use for the print") parser.add_option("-o", "--output", action="store", type="string", dest="output", help="Output filename") (options, args) = parser.parse_args() if options.output is None: print 'Missing output filename' sys.exit(1) if options.profile is not None: profile.loadGlobalProfileFromString(options.profile) options.output = fixUTF8(options.output) clearZ = 0 resultFile = open(options.output, "w") for idx in xrange(0, len(args), 2): position = map(float, args[idx].split(',')) if len(position) < 9 + 2: position = position[0:2] position += [1, 0, 0] position += [0, 1, 0] position += [0, 0, 1] filenames = fixUTF8(args[idx + 1]).split('|') profile.setTempOverride('object_center_x', position[0]) profile.setTempOverride('object_center_y', position[1]) if idx == 0: resultFile.write(';TYPE:CUSTOM\n') resultFile.write( profile.getAlterationFileContents( 'start.gcode', len(filenames)).replace( '?filename?', ' '.join(filenames).encode('ascii', 'replace'))) else: resultFile.write(';TYPE:CUSTOM\n') n = output[-1].rfind('Z') + 1 zString = output[-1][n:n + 20] zString = zString[0:zString.find(' ')] clearZ = max(clearZ, float(zString) + 10) profile.setTempOverride('clear_z', clearZ) print position print profile.getAlterationFileContents('nextobject.gcode') resultFile.write( profile.getAlterationFileContents('nextobject.gcode').replace( '?filename?', ' '.join(filenames).encode('ascii', 'replace'))) output = [] for filename in filenames: extruderNr = filenames.index(filename) profile.resetTempOverride() if extruderNr > 0: profile.setTempOverride( 'object_center_x', position[0] - profile.getPreferenceFloat('extruder_offset_x%d' % (extruderNr))) profile.setTempOverride( 'object_center_y', position[1] - profile.getPreferenceFloat('extruder_offset_y%d' % (extruderNr))) profile.setTempOverride('fan_enabled', 'False') profile.setTempOverride('skirt_line_count', '0') profile.setTempOverride('alternative_center', filenames[0]) else: profile.setTempOverride('object_center_x', position[0]) profile.setTempOverride('object_center_y', position[1]) profile.setTempOverride('object_matrix', ','.join(map(str, position[2:11]))) if extruderNr > 0: if profile.getProfileSettingFloat('filament_diameter%d' % (extruderNr + 1)) > 0: profile.setTempOverride( 'filament_diameter', profile.getProfileSetting('filament_diameter%d' % (extruderNr + 1))) print extruderNr, profile.getPreferenceFloat( 'extruder_offset_x%d' % (extruderNr)), profile.getPreferenceFloat( 'extruder_offset_y%d' % (extruderNr)) output.append(export.getOutput(filename)) profile.resetTempOverride() if len(output) == 1: resultFile.write(output[0]) else: stitchMultiExtruder(output, resultFile) resultFile.write(';TYPE:CUSTOM\n') resultFile.write(profile.getAlterationFileContents('end.gcode')) resultFile.close() print "Running plugins" ret = profile.runPostProcessingPlugins(options.output) if ret is not None: print ret print "Finalizing %s" % (os.path.basename(options.output)) if profile.getPreference('submit_slice_information') == 'True': filenames = fixUTF8(args[idx + 1]).split('|') for filename in filenames: m = hashlib.sha512() f = open(filename, "rb") while True: chunk = f.read(1024) if not chunk: break m.update(chunk) f.close() data = { 'processor': platform.processor(), 'machine': platform.machine(), 'platform': platform.platform(), 'profile': profile.getGlobalProfileString(), 'preferences': profile.getGlobalPreferencesString(), 'modelhash': m.hexdigest(), 'version': version.getVersion(), } try: f = urllib2.urlopen("http://platform.ultimaker.com/curastats/", data=urllib.urlencode(data), timeout=5) f.read() f.close() except: pass
def _watchProcess(self, commandList, oldThread): if oldThread is not None: if self._process is not None: self._process.terminate() oldThread.join() self._id += 1 self._callback(-1.0, False) try: self._process = self._runSliceProcess(commandList) except OSError: traceback.print_exc() return if self._thread != threading.currentThread(): self._process.terminate() self._callback(0.0, False) self._sliceLog = [] self._printTimeSeconds = None self._filamentMM = [0.0, 0.0] line = self._process.stdout.readline() objectNr = 0 while len(line): line = line.strip() if line.startswith('Progress:'): line = line.split(':') if line[1] == 'process': objectNr += 1 elif line[1] in self._progressSteps: progressValue = float(line[2]) / float(line[3]) progressValue /= len(self._progressSteps) progressValue += 1.0 / len(self._progressSteps) * self._progressSteps.index(line[1]) progressValue /= self._objCount progressValue += 1.0 / self._objCount * objectNr try: self._callback(progressValue, False) except: pass elif line.startswith('Print time:'): self._printTimeSeconds = int(line.split(':')[1].strip()) elif line.startswith('Filament:'): self._filamentMM[0] = int(line.split(':')[1].strip()) if profile.getMachineSetting('gcode_flavor') == 'UltiGCode': radius = profile.getProfileSettingFloat('filament_diameter') / 2.0 self._filamentMM[0] /= (math.pi * radius * radius) elif line.startswith('Filament2:'): self._filamentMM[1] = int(line.split(':')[1].strip()) if profile.getMachineSetting('gcode_flavor') == 'UltiGCode': radius = profile.getProfileSettingFloat('filament_diameter') / 2.0 self._filamentMM[1] /= (math.pi * radius * radius) else: self._sliceLog.append(line.strip()) line = self._process.stdout.readline() for line in self._process.stderr: self._sliceLog.append(line.strip()) returnCode = self._process.wait() try: if returnCode == 0: pluginError = profile.runPostProcessingPlugins(self._exportFilename) if pluginError is not None: print pluginError self._sliceLog.append(pluginError) self._callback(1.0, True) else: for line in self._sliceLog: print line self._callback(-1.0, False) except: pass self._process = None
def main(): parser = OptionParser(usage="usage: %prog [options] <X,Y> <filename>[, <X,Y> <filename>][, ...]") parser.add_option("-p", "--profile", action="store", type="string", dest="profile", help="Encoded profile to use for the print") parser.add_option("-o", "--output", action="store", type="string", dest="output", help="Output filename") (options, args) = parser.parse_args() if options.output is None: print 'Missing output filename' sys.exit(1) if options.profile is not None: profile.loadGlobalProfileFromString(options.profile) options.output = fixUTF8(options.output) clearZ = 0 resultFile = open(options.output, "w") for idx in xrange(0, len(args), 2): position = map(float, args[idx].split(',')) if len(position) < 9 + 2: position = position[0:2] position += [1,0,0] position += [0,1,0] position += [0,0,1] filenames = fixUTF8(args[idx + 1]).split('|') profile.setTempOverride('object_center_x', position[0]) profile.setTempOverride('object_center_y', position[1]) if idx == 0: resultFile.write(';TYPE:CUSTOM\n') resultFile.write(profile.getAlterationFileContents('start.gcode', len(filenames)).replace('?filename?', ' '.join(filenames).encode('ascii', 'replace'))) else: resultFile.write(';TYPE:CUSTOM\n') n = output[-1].rfind('Z')+1 zString = output[-1][n:n+20] zString = zString[0:zString.find(' ')] clearZ = max(clearZ, float(zString) + 10) profile.setTempOverride('clear_z', clearZ) print position print profile.getAlterationFileContents('nextobject.gcode') resultFile.write(profile.getAlterationFileContents('nextobject.gcode').replace('?filename?', ' '.join(filenames).encode('ascii', 'replace'))) output = [] for filename in filenames: extruderNr = filenames.index(filename) profile.resetTempOverride() if extruderNr > 0: profile.setTempOverride('object_center_x', position[0] - profile.getPreferenceFloat('extruder_offset_x%d' % (extruderNr))) profile.setTempOverride('object_center_y', position[1] - profile.getPreferenceFloat('extruder_offset_y%d' % (extruderNr))) profile.setTempOverride('fan_enabled', 'False') profile.setTempOverride('skirt_line_count', '0') profile.setTempOverride('alternative_center', filenames[0]) else: profile.setTempOverride('object_center_x', position[0]) profile.setTempOverride('object_center_y', position[1]) profile.setTempOverride('object_matrix', ','.join(map(str, position[2:11]))) if extruderNr > 0: if profile.getProfileSettingFloat('filament_diameter%d' % (extruderNr + 1)) > 0: profile.setTempOverride('filament_diameter', profile.getProfileSetting('filament_diameter%d' % (extruderNr + 1))) print extruderNr, profile.getPreferenceFloat('extruder_offset_x%d' % (extruderNr)), profile.getPreferenceFloat('extruder_offset_y%d' % (extruderNr)) output.append(export.getOutput(filename)) profile.resetTempOverride() if len(output) == 1: resultFile.write(output[0]) else: stitchMultiExtruder(output, resultFile) resultFile.write(';TYPE:CUSTOM\n') resultFile.write(profile.getAlterationFileContents('end.gcode')) resultFile.close() print "Running plugins" ret = profile.runPostProcessingPlugins(options.output) if ret is not None: print ret print "Finalizing %s" % (os.path.basename(options.output)) if profile.getPreference('submit_slice_information') == 'True': filenames = fixUTF8(args[idx + 1]).split('|') for filename in filenames: m = hashlib.sha512() f = open(filename, "rb") while True: chunk = f.read(1024) if not chunk: break m.update(chunk) f.close() data = { 'processor': platform.processor(), 'machine': platform.machine(), 'platform': platform.platform(), 'profile': profile.getGlobalProfileString(), 'preferences': profile.getGlobalPreferencesString(), 'modelhash': m.hexdigest(), 'version': version.getVersion(), } try: f = urllib2.urlopen("http://platform.ultimaker.com/curastats/", data = urllib.urlencode(data), timeout = 5); f.read() f.close() except: pass
def _watchProcess(self, commandList, oldThread): if oldThread is not None: if self._process is not None: self._process.terminate() oldThread.join() self._id += 1 self._callback(-1.0, False) try: self._process = self._runSliceProcess(commandList) except OSError: traceback.print_exc() return if self._thread != threading.currentThread(): self._process.terminate() self._callback(0.0, False) self._sliceLog = [] self._printTimeSeconds = None self._filamentMM = [0.0, 0.0] line = self._process.stdout.readline() objectNr = 0 while len(line): line = line.strip() if line.startswith('Progress:'): line = line.split(':') if line[1] == 'process': objectNr += 1 elif line[1] in self._progressSteps: progressValue = float(line[2]) / float(line[3]) progressValue /= len(self._progressSteps) progressValue += 1.0 / len( self._progressSteps) * self._progressSteps.index( line[1]) progressValue /= self._objCount progressValue += 1.0 / self._objCount * objectNr try: self._callback(progressValue, False) except: pass elif line.startswith('Print time:'): self._printTimeSeconds = int(line.split(':')[1].strip()) elif line.startswith('Filament:'): self._filamentMM[0] = int(line.split(':')[1].strip()) if profile.getMachineSetting('gcode_flavor') == 'UltiGCode': radius = profile.getProfileSettingFloat( 'filament_diameter') / 2.0 self._filamentMM[0] /= (math.pi * radius * radius) elif line.startswith('Filament2:'): self._filamentMM[1] = int(line.split(':')[1].strip()) if profile.getMachineSetting('gcode_flavor') == 'UltiGCode': radius = profile.getProfileSettingFloat( 'filament_diameter') / 2.0 self._filamentMM[1] /= (math.pi * radius * radius) else: self._sliceLog.append(line.strip()) line = self._process.stdout.readline() for line in self._process.stderr: self._sliceLog.append(line.strip()) returnCode = self._process.wait() try: if returnCode == 0: pluginError = profile.runPostProcessingPlugins( self._exportFilename) if pluginError is not None: print pluginError self._sliceLog.append(pluginError) self._callback(1.0, True) else: for line in self._sliceLog: print line self._callback(-1.0, False) except: pass self._process = None
def main(): parser = OptionParser(usage="usage: %prog [options] <X,Y> <filename>[, <X,Y> <filename>][, ...]") parser.add_option( "-p", "--profile", action="store", type="string", dest="profile", help="Encoded profile to use for the print" ) parser.add_option("-o", "--output", action="store", type="string", dest="output", help="Output filename") (options, args) = parser.parse_args() if options.output is None: print "Missing output filename" sys.exit(1) if options.profile is not None: profile.loadGlobalProfileFromString(options.profile) options.output = fixUTF8(options.output) clearZ = 0 resultFile = open(options.output, "w") for idx in xrange(0, len(args), 2): position = map(float, args[idx].split(",")) if len(position) < 9 + 2: position = position[0:2] position += [1, 0, 0] position += [0, 1, 0] position += [0, 0, 1] filenames = fixUTF8(args[idx + 1]).split("|") profile.setTempOverride("object_center_x", position[0]) profile.setTempOverride("object_center_y", position[1]) if idx == 0: resultFile.write(";TYPE:CUSTOM\n") resultFile.write( profile.getAlterationFileContents("start.gcode").replace( "?filename?", " ".join(filenames).encode("ascii", "replace") ) ) else: resultFile.write(";TYPE:CUSTOM\n") n = output[-1].rfind("Z") + 1 zString = output[-1][n : n + 20] zString = zString[0 : zString.find(" ")] clearZ = max(clearZ, float(zString) + 10) profile.setTempOverride("clear_z", clearZ) print position print profile.getAlterationFileContents("nextobject.gcode") resultFile.write( profile.getAlterationFileContents("nextobject.gcode").replace( "?filename?", " ".join(filenames).encode("ascii", "replace") ) ) output = [] for filename in filenames: extruderNr = filenames.index(filename) profile.resetTempOverride() if extruderNr > 0: profile.setTempOverride( "object_center_x", position[0] - profile.getPreferenceFloat("extruder_offset_x%d" % (extruderNr)) ) profile.setTempOverride( "object_center_y", position[1] - profile.getPreferenceFloat("extruder_offset_y%d" % (extruderNr)) ) profile.setTempOverride("fan_enabled", "False") profile.setTempOverride("skirt_line_count", "0") profile.setTempOverride("alternative_center", filenames[0]) else: profile.setTempOverride("object_center_x", position[0]) profile.setTempOverride("object_center_y", position[1]) profile.setTempOverride("object_matrix", ",".join(map(str, position[2:11]))) output.append(export.getOutput(filename)) profile.resetTempOverride() if len(output) == 1: resultFile.write(output[0]) else: stitchMultiExtruder(output, resultFile) resultFile.write(";TYPE:CUSTOM\n") resultFile.write(profile.getAlterationFileContents("end.gcode")) resultFile.close() print "Running plugins" ret = profile.runPostProcessingPlugins(options.output) if ret is not None: print ret print "Finalizing %s" % (os.path.basename(options.output)) if profile.getPreference("submit_slice_information") == "True": filenames = fixUTF8(args[idx + 1]).split("|") for filename in filenames: m = hashlib.sha512() f = open(filename, "rb") while True: chunk = f.read(1024) if not chunk: break m.update(chunk) f.close() data = { "processor": platform.processor(), "machine": platform.machine(), "platform": platform.platform(), "profile": profile.getGlobalProfileString(), "preferences": profile.getGlobalPreferencesString(), "modelhash": m.hexdigest(), "version": version.getVersion(), } try: f = urllib2.urlopen("http://platform.ultimaker.com/curastats/", data=urllib.urlencode(data), timeout=5) f.read() f.close() except: pass