chiark / gitweb /
Add start/end code to Slic3r engine. Fix for SF engine crash
authordaid <daid303@gmail.com>
Tue, 27 Mar 2012 11:48:40 +0000 (13:48 +0200)
committerdaid <daid303@gmail.com>
Tue, 27 Mar 2012 11:48:40 +0000 (13:48 +0200)
16 files changed:
Cura/alterations/end.gcode [moved from Cura/skeinforge_application/alterations/end.gcode with 100% similarity]
Cura/alterations/example_cool_end.gcode [moved from Cura/skeinforge_application/alterations/example_cool_end.gcode with 100% similarity]
Cura/alterations/example_cool_start.gcode [moved from Cura/skeinforge_application/alterations/example_cool_start.gcode with 100% similarity]
Cura/alterations/example_end.gcode [moved from Cura/skeinforge_application/alterations/example_end.gcode with 100% similarity]
Cura/alterations/example_home.gcode [moved from Cura/skeinforge_application/alterations/example_home.gcode with 100% similarity]
Cura/alterations/example_replace.csv [moved from Cura/skeinforge_application/alterations/example_replace.csv with 100% similarity]
Cura/alterations/example_replace_M108.csv [moved from Cura/skeinforge_application/alterations/example_replace_M108.csv with 100% similarity]
Cura/alterations/example_start.gcode [moved from Cura/skeinforge_application/alterations/example_start.gcode with 100% similarity]
Cura/alterations/example_support_end.gcode [moved from Cura/skeinforge_application/alterations/example_support_end.gcode with 100% similarity]
Cura/alterations/example_support_start.gcode [moved from Cura/skeinforge_application/alterations/example_support_start.gcode with 100% similarity]
Cura/alterations/start.gcode [moved from Cura/skeinforge_application/alterations/start.gcode with 100% similarity]
Cura/fabmetheus_utilities/settings.py
Cura/newui/alterationPanel.py
Cura/newui/gcodeInterpreter.py
Cura/newui/profile.py
Cura/newui/sliceRun.py

index d9573c3fbde3a5b122dfca1f3950174e97227920..567b5a8c55a0a71118c6279743341a39402b5e80 100644 (file)
@@ -105,7 +105,7 @@ def getProfileInformation():
                },'inset': {
                        'Add_Custom_Code_for_Temperature_Reading': DEFSET,
                        'Infill_in_Direction_of_Bridge': "True",
-                       'Infill_Width': getProfileSetting("nozzle_size"),
+                       'Infill_Width': storedSetting("nozzle_size"),
                        'Loop_Order_Choice': DEFSET,
                        'Overlap_Removal_Width_over_Perimeter_Width_ratio': DEFSET,
                        'Turn_Extruder_Heater_Off_at_Shut_Down': DEFSET,
@@ -133,7 +133,7 @@ def getProfileInformation():
                        'Line': ifSettingIs('infill_type', 'Line'),
                        'Infill_Perimeter_Overlap_ratio': storedPercentSetting('fill_overlap'),
                        'Infill_Solidity_ratio': storedPercentSetting('fill_density'),
-                       'Infill_Width': getProfileSetting("nozzle_size"),
+                       'Infill_Width': storedSetting("nozzle_size"),
                        'Sharpest_Angle_degrees': DEFSET,
                        'Solid_Surface_Thickness_layers': calculateSolidLayerCount,
                        'Start_From_Choice': DEFSET,
@@ -410,27 +410,8 @@ def getAlterationFileLines(fileName):
 def getAlterationLines(fileName):
        return archive.getTextLines(getAlterationFile(fileName))
 
-def getAlterationFile(fileName, allowMagicPrefix = True):
-       "Get the file from the fileName or the lowercase fileName in the alterations directories."
-       #print ('getAlterationFile:', fileName)
-       prefix = ''
-       if allowMagicPrefix:
-               if fileName == 'start.gcode':
-                       #For the start code, hack the temperature and the steps per E value into it. So the temperature is reached before the start code extrusion.
-                       #We also set our steps per E here, if configured.
-                       eSteps = float(profile.getPreference('steps_per_e'))
-                       if eSteps > 0:
-                               prefix += 'M92 E'+str(eSteps)+'\n'
-                       temp = float(profile.getProfileSetting('print_temperature'))
-                       if temp > 0:
-                               prefix += 'M109 S'+str(temp)+'\n'
-               elif fileName == 'replace.csv':
-                       prefix = 'M101\nM103\n'
-       alterationsDirectory = archive.getSkeinforgePath('alterations')
-       fullFilename = os.path.join(alterationsDirectory, fileName)
-       if os.path.isfile(fullFilename):
-               return prefix + archive.getFileText( fullFilename )
-       return prefix
+def getAlterationFile(fileName):
+       return profile.getAlterationFileContents(fileName)
 
 ####################################
 ## Configuration settings classes ##
index 453cdd4d07b9106abf947d87fcb872ac7aef0c6b..c25a1dd209f3c7dffaba1c50aabb8648611a76e8 100644 (file)
@@ -1,14 +1,13 @@
 import wx\r
 import sys,math,threading,os\r
 \r
-from fabmetheus_utilities import settings\r
-from fabmetheus_utilities import archive\r
+from newui import profile\r
 \r
 class alterationPanel(wx.Panel):\r
        def __init__(self, parent):\r
                wx.Panel.__init__(self, parent,-1)\r
 \r
-               self.alterationFileList = ['start.gcode', 'end.gcode', 'cool_start.gcode', 'cool_end.gcode']\r
+               self.alterationFileList = ['start.gcode', 'end.gcode', 'cool_start.gcode', 'cool_end.gcode', 'replace.csv']\r
                self.currentFile = None\r
 \r
                self.textArea = wx.TextCtrl(self, style=wx.TE_MULTILINE|wx.TE_DONTWRAP|wx.TE_PROCESS_TAB)\r
@@ -32,11 +31,11 @@ class alterationPanel(wx.Panel):
                self.currentFile = self.list.GetSelection()\r
 \r
        def loadFile(self, filename):\r
-               self.textArea.SetValue(unicode(settings.getAlterationFile(filename, False), "utf-8"))\r
+               self.textArea.SetValue(unicode(profile.getAlterationFileContents(filename, False), "utf-8"))\r
 \r
        def OnFocusLost(self, e):\r
                if self.currentFile == self.list.GetSelection():\r
-                       filename = os.path.join(archive.getSkeinforgePath('alterations'), self.alterationFileList[self.list.GetSelection()])\r
+                       filename = profile.getAlterationFilePath(self.alterationFileList[self.list.GetSelection()])\r
                        f = open(filename, "wb")\r
                        f.write(self.textArea.GetValue().encode("utf-8"))\r
                        f.close()\r
index 5424cfea3865e4f8e91ead8dcbc92c45408db10d..334d475683b75621f20d5084dce384c44632579c 100644 (file)
@@ -54,7 +54,9 @@ class gcode():
                                pathType = line[6:].strip()
                                if pathType != "CUSTOM":
                                        startCodeDone = True
+                                       
                        if ';' in line:
+                               #Slic3r GCode comment parser
                                comment = line[line.find(';')+1:].strip()
                                if comment == 'fill':
                                        pathType = 'FILL'
@@ -65,6 +67,7 @@ class gcode():
                                if pathType != "CUSTOM":
                                        startCodeDone = True
                                line = line[0:line.find(';')]
+                       
                        G = self.getCodeInt(line, 'G')
                        if G is not None:
                                if G == 0 or G == 1:    #Move
index 96e56ad37a7a92fc78bd2aeffc302f08436ebdc7..d52396209805acbae494ec42400e8f75b42d8eab 100644 (file)
@@ -7,6 +7,10 @@ import os
 import traceback\r
 import math\r
 \r
+#########################################################\r
+## Profile and preferences functions\r
+#########################################################\r
+\r
 #Single place to store the defaults, so we have a consistent set of default settings.\r
 profileDefaultSettings = {\r
        'nozzle_size': '0.4',\r
@@ -149,8 +153,9 @@ def putPreference(name, value):
        globalPreferenceParser.set('preference', name, str(value))\r
        globalPreferenceParser.write(open(getPreferencePath(), 'w'))\r
 \r
+#########################################################\r
 ## Utility functions to calculate common profile values\r
-\r
+#########################################################\r
 def calculateEdgeWidth():\r
        wallThickness = float(getProfileSetting('wall_thickness'))\r
        nozzleSize = float(getProfileSetting('nozzle_size'))\r
@@ -184,3 +189,35 @@ def calculateSolidLayerCount():
        solidThickness = float(getProfileSetting('solid_layer_thickness'))\r
        return int(math.ceil(solidThickness / layerHeight - 0.0001))\r
 \r
+#########################################################\r
+## Alteration file functions\r
+#########################################################\r
+def getCuraBasePath():\r
+       return os.path.abspath(os.path.join(os.path.dirname(os.path.abspath(__file__)), ".."))\r
+\r
+def getAlterationFilePath(filename):\r
+       return os.path.join(getCuraBasePath(), "alterations", filename)\r
+\r
+def getAlterationFileContents(filename, allowMagicPrefix = True):\r
+       "Get the file from the fileName or the lowercase fileName in the alterations directories."\r
+       prefix = ''\r
+       if allowMagicPrefix:\r
+               if filename == 'start.gcode':\r
+                       #For the start code, hack the temperature and the steps per E value into it. So the temperature is reached before the start code extrusion.\r
+                       #We also set our steps per E here, if configured.\r
+                       eSteps = float(getPreference('steps_per_e'))\r
+                       if eSteps > 0:\r
+                               prefix += 'M92 E'+str(eSteps)+'\n'\r
+                       temp = float(getProfileSetting('print_temperature'))\r
+                       if temp > 0:\r
+                               prefix += 'M109 S'+str(temp)+'\n'\r
+               elif filename == 'replace.csv':\r
+                       prefix = 'M101\nM103\n'\r
+       fullFilename = getAlterationFilePath(filename)\r
+       if os.path.isfile(fullFilename):\r
+               file = open(fullFilename, "r")\r
+               fileText = file.read()\r
+               file.close()\r
+               return prefix + fileText\r
+       return prefix\r
+\r
index b4d30dce4964a18a218e5aff621f6e4506b09fdf..d81f4aa1fa4d484e507167145ceb1c18195654cf 100644 (file)
@@ -91,8 +91,8 @@ def getSliceCommand(filename):
                        '--fill-angle', '45',
                        '--fill-pattern', 'rectilinear',
                        '--solid-fill-pattern', 'rectilinear',
-                       '--start-gcode', '',
-                       '--end-gcode', '',
+                       '--start-gcode', profile.getAlterationFilePath('start.gcode'),
+                       '--end-gcode', profile.getAlterationFilePath('end.gcode'),
                        '--retract-length', profile.getProfileSetting('retraction_amount'),
                        '--retract-speed', str(int(float(profile.getProfileSetting('retraction_speed')))),
                        '--retract-restart-extra', profile.getProfileSetting('retraction_extra'),