From: daid Date: Wed, 25 Apr 2012 11:34:25 +0000 (+0200) Subject: Added tool switching GCode. Made the E value reset after each layer for multiple... X-Git-Tag: RC3~17 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=3770dea42c6b6ea85bd03ccd4da709c0cadf4a97;p=cura.git Added tool switching GCode. Made the E value reset after each layer for multiple extruder support. --- diff --git a/Cura/cura_sf/fabmetheus_utilities/settings.py b/Cura/cura_sf/fabmetheus_utilities/settings.py index 0e053c86..08ad268d 100644 --- a/Cura/cura_sf/fabmetheus_utilities/settings.py +++ b/Cura/cura_sf/fabmetheus_utilities/settings.py @@ -125,8 +125,8 @@ def getProfileInformation(): 'SVG_Viewer': DEFSET, },'preface': { 'Meta': DEFSET, - 'Set_Positioning_to_Absolute': DEFSET, - 'Set_Units_to_Millimeters': DEFSET, + 'Set_Positioning_to_Absolute': "False", + 'Set_Units_to_Millimeters': "False", 'Start_at_Home': DEFSET, 'Turn_Extruder_Off_at_Shut_Down': DEFSET, 'Turn_Extruder_Off_at_Start_Up': DEFSET, @@ -446,7 +446,7 @@ def getAlterationLines(fileName): return archive.getTextLines(getAlterationFile(fileName)) def getAlterationFile(fileName): - return unicode(profile.getAlterationFileContents(fileName)).encode("utf-8") + return profile.getAlterationFileContents(fileName) #################################### ## Configuration settings classes ## diff --git a/Cura/cura_sf/skeinforge_application/skeinforge_plugins/craft_plugins/dimension.py b/Cura/cura_sf/skeinforge_application/skeinforge_plugins/craft_plugins/dimension.py index ce89001e..cf8f6bed 100644 --- a/Cura/cura_sf/skeinforge_application/skeinforge_plugins/craft_plugins/dimension.py +++ b/Cura/cura_sf/skeinforge_application/skeinforge_plugins/craft_plugins/dimension.py @@ -387,6 +387,10 @@ class DimensionSkein: elif firstWord == '(': self.layerIndex += 1 settings.printProgress(self.layerIndex, 'dimension') + elif firstWord == '()': + if self.totalExtrusionDistance > 0.0 and not self.repository.relativeExtrusionDistance.value: + self.distanceFeedRate.addLine('G92 E0') + self.totalExtrusionDistance = 0.0 elif firstWord == 'M101': if self.addRetraction: self.addLinearMoveExtrusionDistanceLine(self.restartDistance * self.retractionRatio) diff --git a/Cura/cura_sf/skeinforge_application/skeinforge_plugins/craft_plugins/export_plugins/static_plugins/gcode_small.py b/Cura/cura_sf/skeinforge_application/skeinforge_plugins/craft_plugins/export_plugins/static_plugins/gcode_small.py index 00e25540..62c18e2a 100644 --- a/Cura/cura_sf/skeinforge_application/skeinforge_plugins/craft_plugins/export_plugins/static_plugins/gcode_small.py +++ b/Cura/cura_sf/skeinforge_application/skeinforge_plugins/craft_plugins/export_plugins/static_plugins/gcode_small.py @@ -92,6 +92,8 @@ class GcodeSmallSkein: return if firstWord[0] == '(': return + if firstWord == 'M108' or firstWord == 'M113': + return if firstWord != 'G1': self.output.write(line + '\n') return diff --git a/Cura/gui/projectPlanner.py b/Cura/gui/projectPlanner.py index 0d33b536..18027f67 100644 --- a/Cura/gui/projectPlanner.py +++ b/Cura/gui/projectPlanner.py @@ -707,11 +707,11 @@ class ProjectSliceProgressWindow(wx.Frame): if action == self.actionList[0]: resultFile.write(';TYPE:CUSTOM\n') - resultFile.write(profile.getAlterationFileContents('start.gcode').encode('utf-8')) + resultFile.write(profile.getAlterationFileContents('start.gcode')) else: #reset the extrusion length, and move to the next object center. resultFile.write(';TYPE:CUSTOM\n') - resultFile.write(profile.getAlterationFileContents('nextobject.gcode').encode('utf-8')) + resultFile.write(profile.getAlterationFileContents('nextobject.gcode')) resultFile.write(';PRINTNR:%d\n' % self.actionList.index(action)) profile.loadGlobalProfileFromString(oldProfile) @@ -727,7 +727,7 @@ class ProjectSliceProgressWindow(wx.Frame): wx.CallAfter(self.progressGauge2.SetValue, self.actionList.index(action) + 1) resultFile.write(';TYPE:CUSTOM\n') - resultFile.write(profile.getAlterationFileContents('end.gcode').encode('utf-8')) + resultFile.write(profile.getAlterationFileContents('end.gcode')) resultFile.close() self.abort = True wx.CallAfter(self.abortButton.SetLabel, 'Close') diff --git a/Cura/gui/sliceProgessPanel.py b/Cura/gui/sliceProgessPanel.py index 465dc259..172565b5 100644 --- a/Cura/gui/sliceProgessPanel.py +++ b/Cura/gui/sliceProgessPanel.py @@ -43,7 +43,7 @@ class sliceProgessPanel(wx.Panel): self.statusText = wx.StaticText(self, -1, "Starting...") self.progressGauge = wx.Gauge(self, -1) - self.progressGauge.SetRange(10000) + 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) @@ -60,8 +60,10 @@ class sliceProgessPanel(wx.Panel): cmdList = [] oldProfile = profile.getGlobalProfileString() for filename in self.filelist: + print filename, self.filelist.index(filename) if self.filelist.index(filename) > 0: profile.putProfileSetting('fan_enabled', 'False') + profile.putProfileSetting('skirt_lines', '0') if len(self.filelist) > 1: profile.putProfileSetting('add_start_end_gcode', 'False') profile.putProfileSetting('gcode_extension', 'multi_extrude_tmp') @@ -146,7 +148,7 @@ class WorkerThread(threading.Thread): maxValue = int(progress[2]) wx.CallAfter(self.notifyWindow.SetProgress, progress[0], int(progress[1]), maxValue) else: - print line + #print line self.progressLog.append(line) wx.CallAfter(self.notifyWindow.statusText.SetLabel, line) if self.notifyWindow.abort: @@ -172,25 +174,40 @@ class WorkerThread(threading.Thread): files = [] resultFile = open(self.filelist[0][:self.filelist[0].rfind('.')]+'_export.gcode', "w") resultFile.write(';TYPE:CUSTOM\n') - resultFile.write(unicode(profile.getAlterationFileContents('start.gcode')).encode('utf-8')) + resultFile.write(profile.getAlterationFileContents('start.gcode')) for filename in self.filelist: files.append(open(filename[:filename.rfind('.')]+'_export.multi_extrude_tmp', "r")) + currentExtruder = 0 + layerNr = -1 hasLine = True while hasLine: hasLine = False for f in files: + layerHasLine = False for line in f: - resultFile.write(line) hasLine = True if line.startswith(';LAYER:'): break + if not layerHasLine: + nextExtruder = files.index(f) + resultFile.write(';LAYER:%d\n' % (layerNr)) + resultFile.write(';EXTRUDER:%d\n' % (nextExtruder)) + if nextExtruder != currentExtruder: + resultFile.write("G1 E-2 F3000\n") + resultFile.write("T%d\n" % (nextExtruder)) + resultFile.write("G1 E2 F3000\n") + resultFile.write("M92 E0\n") + currentExtruder = nextExtruder + layerHasLine = True + resultFile.write(line) + layerNr += 1 for f in files: f.close() for filename in self.filelist: os.remove(filename[:filename.rfind('.')]+'_export.multi_extrude_tmp') resultFile.write(';TYPE:CUSTOM\n') - resultFile.write(unicode(profile.getAlterationFileContents('end.gcode')).encode('utf-8')) + resultFile.write(profile.getAlterationFileContents('end.gcode')) resultFile.close() class LogWindow(wx.Frame): diff --git a/Cura/util/profile.py b/Cura/util/profile.py index eb6c4ec6..b6fb3ac7 100644 --- a/Cura/util/profile.py +++ b/Cura/util/profile.py @@ -343,5 +343,5 @@ def getAlterationFileContents(filename): #Always remove the extruder on/off M codes. These are no longer needed in 5D printing. prefix = 'M101\nM103\n' - return prefix + re.sub("\{[^\}]*\}", replaceTagMatch, alterationContents) + return unicode(prefix + re.sub("\{[^\}]*\}", replaceTagMatch, alterationContents).rstrip() + '\n').encode('utf-8')