Add start/end code to Slic3r engine. Fix for SF engine crash
parent
356f6c70a9
commit
168e748724
|
@ -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 ##
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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'),
|
||||
|
|
Loading…
Reference in New Issue