Add start/end code to Slic3r engine. Fix for SF engine crash
This commit is contained in:
parent
356f6c70a9
commit
168e748724
16 changed files with 51 additions and 31 deletions
|
@ -105,7 +105,7 @@ def getProfileInformation():
|
||||||
},'inset': {
|
},'inset': {
|
||||||
'Add_Custom_Code_for_Temperature_Reading': DEFSET,
|
'Add_Custom_Code_for_Temperature_Reading': DEFSET,
|
||||||
'Infill_in_Direction_of_Bridge': "True",
|
'Infill_in_Direction_of_Bridge': "True",
|
||||||
'Infill_Width': getProfileSetting("nozzle_size"),
|
'Infill_Width': storedSetting("nozzle_size"),
|
||||||
'Loop_Order_Choice': DEFSET,
|
'Loop_Order_Choice': DEFSET,
|
||||||
'Overlap_Removal_Width_over_Perimeter_Width_ratio': DEFSET,
|
'Overlap_Removal_Width_over_Perimeter_Width_ratio': DEFSET,
|
||||||
'Turn_Extruder_Heater_Off_at_Shut_Down': DEFSET,
|
'Turn_Extruder_Heater_Off_at_Shut_Down': DEFSET,
|
||||||
|
@ -133,7 +133,7 @@ def getProfileInformation():
|
||||||
'Line': ifSettingIs('infill_type', 'Line'),
|
'Line': ifSettingIs('infill_type', 'Line'),
|
||||||
'Infill_Perimeter_Overlap_ratio': storedPercentSetting('fill_overlap'),
|
'Infill_Perimeter_Overlap_ratio': storedPercentSetting('fill_overlap'),
|
||||||
'Infill_Solidity_ratio': storedPercentSetting('fill_density'),
|
'Infill_Solidity_ratio': storedPercentSetting('fill_density'),
|
||||||
'Infill_Width': getProfileSetting("nozzle_size"),
|
'Infill_Width': storedSetting("nozzle_size"),
|
||||||
'Sharpest_Angle_degrees': DEFSET,
|
'Sharpest_Angle_degrees': DEFSET,
|
||||||
'Solid_Surface_Thickness_layers': calculateSolidLayerCount,
|
'Solid_Surface_Thickness_layers': calculateSolidLayerCount,
|
||||||
'Start_From_Choice': DEFSET,
|
'Start_From_Choice': DEFSET,
|
||||||
|
@ -410,27 +410,8 @@ def getAlterationFileLines(fileName):
|
||||||
def getAlterationLines(fileName):
|
def getAlterationLines(fileName):
|
||||||
return archive.getTextLines(getAlterationFile(fileName))
|
return archive.getTextLines(getAlterationFile(fileName))
|
||||||
|
|
||||||
def getAlterationFile(fileName, allowMagicPrefix = True):
|
def getAlterationFile(fileName):
|
||||||
"Get the file from the fileName or the lowercase fileName in the alterations directories."
|
return profile.getAlterationFileContents(fileName)
|
||||||
#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
|
|
||||||
|
|
||||||
####################################
|
####################################
|
||||||
## Configuration settings classes ##
|
## Configuration settings classes ##
|
||||||
|
|
|
@ -1,14 +1,13 @@
|
||||||
import wx
|
import wx
|
||||||
import sys,math,threading,os
|
import sys,math,threading,os
|
||||||
|
|
||||||
from fabmetheus_utilities import settings
|
from newui import profile
|
||||||
from fabmetheus_utilities import archive
|
|
||||||
|
|
||||||
class alterationPanel(wx.Panel):
|
class alterationPanel(wx.Panel):
|
||||||
def __init__(self, parent):
|
def __init__(self, parent):
|
||||||
wx.Panel.__init__(self, parent,-1)
|
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.currentFile = None
|
||||||
|
|
||||||
self.textArea = wx.TextCtrl(self, style=wx.TE_MULTILINE|wx.TE_DONTWRAP|wx.TE_PROCESS_TAB)
|
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()
|
self.currentFile = self.list.GetSelection()
|
||||||
|
|
||||||
def loadFile(self, filename):
|
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):
|
def OnFocusLost(self, e):
|
||||||
if self.currentFile == self.list.GetSelection():
|
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 = open(filename, "wb")
|
||||||
f.write(self.textArea.GetValue().encode("utf-8"))
|
f.write(self.textArea.GetValue().encode("utf-8"))
|
||||||
f.close()
|
f.close()
|
||||||
|
|
|
@ -54,7 +54,9 @@ class gcode():
|
||||||
pathType = line[6:].strip()
|
pathType = line[6:].strip()
|
||||||
if pathType != "CUSTOM":
|
if pathType != "CUSTOM":
|
||||||
startCodeDone = True
|
startCodeDone = True
|
||||||
|
|
||||||
if ';' in line:
|
if ';' in line:
|
||||||
|
#Slic3r GCode comment parser
|
||||||
comment = line[line.find(';')+1:].strip()
|
comment = line[line.find(';')+1:].strip()
|
||||||
if comment == 'fill':
|
if comment == 'fill':
|
||||||
pathType = 'FILL'
|
pathType = 'FILL'
|
||||||
|
@ -65,6 +67,7 @@ class gcode():
|
||||||
if pathType != "CUSTOM":
|
if pathType != "CUSTOM":
|
||||||
startCodeDone = True
|
startCodeDone = True
|
||||||
line = line[0:line.find(';')]
|
line = line[0:line.find(';')]
|
||||||
|
|
||||||
G = self.getCodeInt(line, 'G')
|
G = self.getCodeInt(line, 'G')
|
||||||
if G is not None:
|
if G is not None:
|
||||||
if G == 0 or G == 1: #Move
|
if G == 0 or G == 1: #Move
|
||||||
|
|
|
@ -7,6 +7,10 @@ import os
|
||||||
import traceback
|
import traceback
|
||||||
import math
|
import math
|
||||||
|
|
||||||
|
#########################################################
|
||||||
|
## Profile and preferences functions
|
||||||
|
#########################################################
|
||||||
|
|
||||||
#Single place to store the defaults, so we have a consistent set of default settings.
|
#Single place to store the defaults, so we have a consistent set of default settings.
|
||||||
profileDefaultSettings = {
|
profileDefaultSettings = {
|
||||||
'nozzle_size': '0.4',
|
'nozzle_size': '0.4',
|
||||||
|
@ -149,8 +153,9 @@ def putPreference(name, value):
|
||||||
globalPreferenceParser.set('preference', name, str(value))
|
globalPreferenceParser.set('preference', name, str(value))
|
||||||
globalPreferenceParser.write(open(getPreferencePath(), 'w'))
|
globalPreferenceParser.write(open(getPreferencePath(), 'w'))
|
||||||
|
|
||||||
|
#########################################################
|
||||||
## Utility functions to calculate common profile values
|
## Utility functions to calculate common profile values
|
||||||
|
#########################################################
|
||||||
def calculateEdgeWidth():
|
def calculateEdgeWidth():
|
||||||
wallThickness = float(getProfileSetting('wall_thickness'))
|
wallThickness = float(getProfileSetting('wall_thickness'))
|
||||||
nozzleSize = float(getProfileSetting('nozzle_size'))
|
nozzleSize = float(getProfileSetting('nozzle_size'))
|
||||||
|
@ -184,3 +189,35 @@ def calculateSolidLayerCount():
|
||||||
solidThickness = float(getProfileSetting('solid_layer_thickness'))
|
solidThickness = float(getProfileSetting('solid_layer_thickness'))
|
||||||
return int(math.ceil(solidThickness / layerHeight - 0.0001))
|
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
|
||||||
|
|
||||||
|
|
|
@ -91,8 +91,8 @@ def getSliceCommand(filename):
|
||||||
'--fill-angle', '45',
|
'--fill-angle', '45',
|
||||||
'--fill-pattern', 'rectilinear',
|
'--fill-pattern', 'rectilinear',
|
||||||
'--solid-fill-pattern', 'rectilinear',
|
'--solid-fill-pattern', 'rectilinear',
|
||||||
'--start-gcode', '',
|
'--start-gcode', profile.getAlterationFilePath('start.gcode'),
|
||||||
'--end-gcode', '',
|
'--end-gcode', profile.getAlterationFilePath('end.gcode'),
|
||||||
'--retract-length', profile.getProfileSetting('retraction_amount'),
|
'--retract-length', profile.getProfileSetting('retraction_amount'),
|
||||||
'--retract-speed', str(int(float(profile.getProfileSetting('retraction_speed')))),
|
'--retract-speed', str(int(float(profile.getProfileSetting('retraction_speed')))),
|
||||||
'--retract-restart-extra', profile.getProfileSetting('retraction_extra'),
|
'--retract-restart-extra', profile.getProfileSetting('retraction_extra'),
|
||||||
|
|
Loading…
Reference in a new issue