chiark / gitweb /
Added tool switching GCode. Made the E value reset after each layer for multiple...
authordaid <daid303@gmail.com>
Wed, 25 Apr 2012 11:34:25 +0000 (13:34 +0200)
committerdaid <daid303@gmail.com>
Wed, 25 Apr 2012 11:34:25 +0000 (13:34 +0200)
Cura/cura_sf/fabmetheus_utilities/settings.py
Cura/cura_sf/skeinforge_application/skeinforge_plugins/craft_plugins/dimension.py
Cura/cura_sf/skeinforge_application/skeinforge_plugins/craft_plugins/export_plugins/static_plugins/gcode_small.py
Cura/gui/projectPlanner.py
Cura/gui/sliceProgessPanel.py
Cura/util/profile.py

index 0e053c86b2c056536c5a9dd9af9b485f7ff8fd8e..08ad268d7691e7f16bb2159f724f4f58879a5752 100644 (file)
@@ -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 ##
index ce89001e4d1459ad33afb89f3e0da4f2d6615510..cf8f6bed582e4b2e1072aed57c9ccd42bc4fbdcc 100644 (file)
@@ -387,6 +387,10 @@ class DimensionSkein:
                elif firstWord == '(<layer>':
                        self.layerIndex += 1
                        settings.printProgress(self.layerIndex, 'dimension')
+               elif firstWord == '(</layer>)':
+                       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)
index 00e255405deaa818958f90a5b1ffb44704f56844..62c18e2affb4e22342f547aadc5ea29a7fc7e81d 100644 (file)
@@ -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
index 0d33b536af8fc192914764101503769f14d54172..18027f67f1f70ca653814063777f3c7a4d0349a8 100644 (file)
@@ -707,11 +707,11 @@ class ProjectSliceProgressWindow(wx.Frame):
                        \r
                        if action == self.actionList[0]:\r
                                resultFile.write(';TYPE:CUSTOM\n')\r
-                               resultFile.write(profile.getAlterationFileContents('start.gcode').encode('utf-8'))\r
+                               resultFile.write(profile.getAlterationFileContents('start.gcode'))\r
                        else:\r
                                #reset the extrusion length, and move to the next object center.\r
                                resultFile.write(';TYPE:CUSTOM\n')\r
-                               resultFile.write(profile.getAlterationFileContents('nextobject.gcode').encode('utf-8'))\r
+                               resultFile.write(profile.getAlterationFileContents('nextobject.gcode'))\r
                        resultFile.write(';PRINTNR:%d\n' % self.actionList.index(action))\r
                        profile.loadGlobalProfileFromString(oldProfile)\r
                        \r
@@ -727,7 +727,7 @@ class ProjectSliceProgressWindow(wx.Frame):
                        wx.CallAfter(self.progressGauge2.SetValue, self.actionList.index(action) + 1)\r
                \r
                resultFile.write(';TYPE:CUSTOM\n')\r
-               resultFile.write(profile.getAlterationFileContents('end.gcode').encode('utf-8'))\r
+               resultFile.write(profile.getAlterationFileContents('end.gcode'))\r
                resultFile.close()\r
                self.abort = True\r
                wx.CallAfter(self.abortButton.SetLabel, 'Close')\r
index 465dc2590214188e3185d01476eec75e771ee752..172565b5f71aeb42ebc99d5be5440c38525f5b3e 100644 (file)
@@ -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):
index eb6c4ec6bcba490228dbda0fba3c6172b2d22686..b6fb3ac75d6b49f9c217af85b6a142f74d91c2a9 100644 (file)
@@ -343,5 +343,5 @@ def getAlterationFileContents(filename):
                #Always remove the extruder on/off M codes. These are no longer needed in 5D printing.\r
                prefix = 'M101\nM103\n'\r
        \r
-       return prefix + re.sub("\{[^\}]*\}", replaceTagMatch, alterationContents)\r
+       return unicode(prefix + re.sub("\{[^\}]*\}", replaceTagMatch, alterationContents).rstrip() + '\n').encode('utf-8')\r
 \r