diff --git a/Cura/skeinforge_application/alterations/end.gcode b/Cura/alterations/end.gcode similarity index 100% rename from Cura/skeinforge_application/alterations/end.gcode rename to Cura/alterations/end.gcode diff --git a/Cura/skeinforge_application/alterations/example_cool_end.gcode b/Cura/alterations/example_cool_end.gcode similarity index 100% rename from Cura/skeinforge_application/alterations/example_cool_end.gcode rename to Cura/alterations/example_cool_end.gcode diff --git a/Cura/skeinforge_application/alterations/example_cool_start.gcode b/Cura/alterations/example_cool_start.gcode similarity index 100% rename from Cura/skeinforge_application/alterations/example_cool_start.gcode rename to Cura/alterations/example_cool_start.gcode diff --git a/Cura/skeinforge_application/alterations/example_end.gcode b/Cura/alterations/example_end.gcode similarity index 100% rename from Cura/skeinforge_application/alterations/example_end.gcode rename to Cura/alterations/example_end.gcode diff --git a/Cura/skeinforge_application/alterations/example_home.gcode b/Cura/alterations/example_home.gcode similarity index 100% rename from Cura/skeinforge_application/alterations/example_home.gcode rename to Cura/alterations/example_home.gcode diff --git a/Cura/skeinforge_application/alterations/example_replace.csv b/Cura/alterations/example_replace.csv similarity index 100% rename from Cura/skeinforge_application/alterations/example_replace.csv rename to Cura/alterations/example_replace.csv diff --git a/Cura/skeinforge_application/alterations/example_replace_M108.csv b/Cura/alterations/example_replace_M108.csv similarity index 100% rename from Cura/skeinforge_application/alterations/example_replace_M108.csv rename to Cura/alterations/example_replace_M108.csv diff --git a/Cura/skeinforge_application/alterations/example_start.gcode b/Cura/alterations/example_start.gcode similarity index 100% rename from Cura/skeinforge_application/alterations/example_start.gcode rename to Cura/alterations/example_start.gcode diff --git a/Cura/skeinforge_application/alterations/example_support_end.gcode b/Cura/alterations/example_support_end.gcode similarity index 100% rename from Cura/skeinforge_application/alterations/example_support_end.gcode rename to Cura/alterations/example_support_end.gcode diff --git a/Cura/skeinforge_application/alterations/example_support_start.gcode b/Cura/alterations/example_support_start.gcode similarity index 100% rename from Cura/skeinforge_application/alterations/example_support_start.gcode rename to Cura/alterations/example_support_start.gcode diff --git a/Cura/skeinforge_application/alterations/start.gcode b/Cura/alterations/start.gcode similarity index 100% rename from Cura/skeinforge_application/alterations/start.gcode rename to Cura/alterations/start.gcode diff --git a/Cura/fabmetheus_utilities/settings.py b/Cura/fabmetheus_utilities/settings.py index d9573c3..567b5a8 100644 --- a/Cura/fabmetheus_utilities/settings.py +++ b/Cura/fabmetheus_utilities/settings.py @@ -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 ## diff --git a/Cura/newui/alterationPanel.py b/Cura/newui/alterationPanel.py index 453cdd4..c25a1dd 100644 --- a/Cura/newui/alterationPanel.py +++ b/Cura/newui/alterationPanel.py @@ -1,14 +1,13 @@ import wx import sys,math,threading,os -from fabmetheus_utilities import settings -from fabmetheus_utilities import archive +from newui import profile class alterationPanel(wx.Panel): def __init__(self, parent): wx.Panel.__init__(self, parent,-1) - self.alterationFileList = ['start.gcode', 'end.gcode', 'cool_start.gcode', 'cool_end.gcode'] + self.alterationFileList = ['start.gcode', 'end.gcode', 'cool_start.gcode', 'cool_end.gcode', 'replace.csv'] self.currentFile = None self.textArea = wx.TextCtrl(self, style=wx.TE_MULTILINE|wx.TE_DONTWRAP|wx.TE_PROCESS_TAB) @@ -32,11 +31,11 @@ class alterationPanel(wx.Panel): self.currentFile = self.list.GetSelection() def loadFile(self, filename): - self.textArea.SetValue(unicode(settings.getAlterationFile(filename, False), "utf-8")) + self.textArea.SetValue(unicode(profile.getAlterationFileContents(filename, False), "utf-8")) def OnFocusLost(self, e): if self.currentFile == self.list.GetSelection(): - filename = os.path.join(archive.getSkeinforgePath('alterations'), self.alterationFileList[self.list.GetSelection()]) + filename = profile.getAlterationFilePath(self.alterationFileList[self.list.GetSelection()]) f = open(filename, "wb") f.write(self.textArea.GetValue().encode("utf-8")) f.close() diff --git a/Cura/newui/gcodeInterpreter.py b/Cura/newui/gcodeInterpreter.py index 5424cfe..334d475 100644 --- a/Cura/newui/gcodeInterpreter.py +++ b/Cura/newui/gcodeInterpreter.py @@ -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 diff --git a/Cura/newui/profile.py b/Cura/newui/profile.py index 96e56ad..d523962 100644 --- a/Cura/newui/profile.py +++ b/Cura/newui/profile.py @@ -7,6 +7,10 @@ import os import traceback import math +######################################################### +## Profile and preferences functions +######################################################### + #Single place to store the defaults, so we have a consistent set of default settings. profileDefaultSettings = { 'nozzle_size': '0.4', @@ -149,8 +153,9 @@ def putPreference(name, value): globalPreferenceParser.set('preference', name, str(value)) globalPreferenceParser.write(open(getPreferencePath(), 'w')) +######################################################### ## Utility functions to calculate common profile values - +######################################################### def calculateEdgeWidth(): wallThickness = float(getProfileSetting('wall_thickness')) nozzleSize = float(getProfileSetting('nozzle_size')) @@ -184,3 +189,35 @@ def calculateSolidLayerCount(): solidThickness = float(getProfileSetting('solid_layer_thickness')) return int(math.ceil(solidThickness / layerHeight - 0.0001)) +######################################################### +## Alteration file functions +######################################################### +def getCuraBasePath(): + return os.path.abspath(os.path.join(os.path.dirname(os.path.abspath(__file__)), "..")) + +def getAlterationFilePath(filename): + return os.path.join(getCuraBasePath(), "alterations", filename) + +def getAlterationFileContents(filename, allowMagicPrefix = True): + "Get the file from the fileName or the lowercase fileName in the alterations directories." + 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(getPreference('steps_per_e')) + if eSteps > 0: + prefix += 'M92 E'+str(eSteps)+'\n' + temp = float(getProfileSetting('print_temperature')) + if temp > 0: + prefix += 'M109 S'+str(temp)+'\n' + elif filename == 'replace.csv': + prefix = 'M101\nM103\n' + fullFilename = getAlterationFilePath(filename) + if os.path.isfile(fullFilename): + file = open(fullFilename, "r") + fileText = file.read() + file.close() + return prefix + fileText + return prefix + diff --git a/Cura/newui/sliceRun.py b/Cura/newui/sliceRun.py index b4d30dc..d81f4aa 100644 --- a/Cura/newui/sliceRun.py +++ b/Cura/newui/sliceRun.py @@ -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'),