Added support

Added a few comments to export so preview and future advanced tuning can
be done
Speed up preview of GCode
Added last used file reload
This commit is contained in:
Daid 2012-02-26 14:30:34 +01:00
parent cc62bcae48
commit f5c5f67f62
4 changed files with 119 additions and 38 deletions

View file

@ -19,6 +19,9 @@ def defaultSetting(setting):
def storedSetting(name):
return lambda setting: getSetting(name, setting.value)
def ifSettingAboveZero(name):
return lambda setting: float(getSetting(name, '0.0')) > 0
def storedPercentSetting(name):
return lambda setting: float(getSetting(name, setting.value)) / 100
@ -97,7 +100,7 @@ def getSkeinPyPyProfileInformation():
'Turn_Extruder_Heater_Off_at_Shut_Down': defaultSetting,
'Volume_Fraction_ratio': defaultSetting,
},'fill': {
'Activate_Fill': defaultSetting,
'Activate_Fill': "True",
'Diaphragm_Period_layers': defaultSetting,
'Diaphragm_Thickness_layers': defaultSetting,
'Extra_Shells_on_Alternating_Solid_Layer_layers': calculateShells,
@ -151,24 +154,24 @@ def getSkeinPyPyProfileInformation():
'Perimeter_Flow_Rate_Multiplier_ratio': defaultSetting,
'Travel_Feed_Rate_mm/s': storedSetting("travel_speed"),
},'temperature': {
'Activate_Temperature': "False",
'Activate_Temperature': defaultSetting,#ifSettingAboveZero('print_temperature'),
'Cooling_Rate_Celcius/second': defaultSetting,
'Heating_Rate_Celcius/second': defaultSetting,
'Base_Temperature_Celcius': defaultSetting,
'Interface_Temperature_Celcius': defaultSetting,
'Object_First_Layer_Infill_Temperature_Celcius': defaultSetting,
'Object_First_Layer_Perimeter_Temperature_Celcius': defaultSetting,
'Object_Next_Layers_Temperature_Celcius': defaultSetting,
'Support_Layers_Temperature_Celcius': defaultSetting,
'Supported_Layers_Temperature_Celcius': defaultSetting,
'Base_Temperature_Celcius': defaultSetting,#storedSetting("print_temperature"),
'Interface_Temperature_Celcius': defaultSetting,#storedSetting("print_temperature"),
'Object_First_Layer_Infill_Temperature_Celcius': defaultSetting,#storedSetting("print_temperature"),
'Object_First_Layer_Perimeter_Temperature_Celcius': defaultSetting,#storedSetting("print_temperature"),
'Object_Next_Layers_Temperature_Celcius': defaultSetting,#storedSetting("print_temperature"),
'Support_Layers_Temperature_Celcius': defaultSetting,#storedSetting("print_temperature"),
'Supported_Layers_Temperature_Celcius': defaultSetting,#storedSetting("print_temperature"),
},'raft': {
'Activate_Raft': "False",
'Activate_Raft': "True",
'Add_Raft,_Elevate_Nozzle,_Orbit': defaultSetting,
'Base_Feed_Rate_Multiplier_ratio': defaultSetting,
'Base_Flow_Rate_Multiplier_ratio': defaultSetting,
'Base_Infill_Density_ratio': defaultSetting,
'Base_Layer_Thickness_over_Layer_Thickness': defaultSetting,
'Base_Layers_integer': defaultSetting,
'Base_Layers_integer': '0',
'Base_Nozzle_Lift_over_Base_Layer_Thickness_ratio': defaultSetting,
'Initial_Circling': defaultSetting,
'Infill_Overhang_over_Extrusion_Width_ratio': defaultSetting,
@ -176,17 +179,17 @@ def getSkeinPyPyProfileInformation():
'Interface_Flow_Rate_Multiplier_ratio': defaultSetting,
'Interface_Infill_Density_ratio': defaultSetting,
'Interface_Layer_Thickness_over_Layer_Thickness': defaultSetting,
'Interface_Layers_integer': defaultSetting,
'Interface_Layers_integer': '0',
'Interface_Nozzle_Lift_over_Interface_Layer_Thickness_ratio': defaultSetting,
'Name_of_Support_End_File': defaultSetting,
'Name_of_Support_Start_File': defaultSetting,
'Operating_Nozzle_Lift_over_Layer_Thickness_ratio': defaultSetting,
'Raft_Additional_Margin_over_Length_%': defaultSetting,
'Raft_Margin_mm': defaultSetting,
'Support_Cross_Hatch': defaultSetting,
'Support_Cross_Hatch': 'False',
'Support_Flow_Rate_over_Operating_Flow_Rate_ratio': defaultSetting,
'Support_Gap_over_Perimeter_Extrusion_Width_ratio': defaultSetting,
'Support_Material_Choice_': defaultSetting,
'Support_Material_Choice_': storedSetting("support"),
'Support_Minimum_Angle_degrees': defaultSetting,
},'skirt': {
'Skirt_line_count': storedSetting("skirt_line_count"),
@ -345,7 +348,7 @@ def getSkeinPyPyProfileInformation():
'gcode_small': defaultSetting,
'File_Extension': defaultSetting,
'Name_of_Replace_File': defaultSetting,
'Save_Penultimate_Gcode': defaultSetting,
'Save_Penultimate_Gcode': "False",
}
}

View file

@ -1,7 +1,8 @@
from __future__ import absolute_import
import __init__
import wx, os, platform
import wx, os, platform, types
import ConfigParser
from fabmetheus_utilities import settings
@ -37,7 +38,7 @@ class mainWindow(wx.Frame):
wx.ToolTip.SetDelay(0)
self.lastPath = ""
self.filename = None
self.filename = getPreference('lastFile', None)
self.progressPanelList = []
self.settingControlList = []
@ -68,15 +69,20 @@ class mainWindow(wx.Frame):
validators.validInt(c, 0, 10)
c = SettingRow(left, "Start distance (mm)", 'skirt_gap', '6.0', 'The distance between the skirt and the first layer.\nThis is the minimal distance, multiple skirt lines will be put outwards from this distance.')
validators.validFloat(c, 0.0)
TitleRow(right, "Speed")
c = SettingRow(right, "Print speed (mm/s)", 'print_speed', '50')
validators.validFloat(c, 1.0)
validators.warningAbove(c, 150.0, "It is highly unlikely that your machine can achieve a printing speed above 150mm/s")
#Printing temperature is a problem right now, as our start code depends on a heated head.
#TitleRow(right, "Temperature")
#c = SettingRow(right, "Printing temperature", 'print_temperature', '0', 'Temperature used for printing. Set at 0 to pre-heat yourself')
#validators.validFloat(c, 0.0, 350.0)
#validators.warningAbove(c, 260.0, "Temperatures above 260C could damage your machine.")
TitleRow(right, "Cool")
#c = SettingRow(right, "Cool type", self.plugins['cool'].preferencesDict['Cool_Type'])
c = SettingRow(right, "Minimal layer time (sec)", 'cool_min_layer_time', '10', 'Minimum time spend in a layer, gives the layer time to cool down before the next layer is put on top. If the layer will be placed down too fast the printer will slow down to make sure it has spend atleast this amount of seconds printing this layer.')
validators.validFloat(c, 0.0)
TitleRow(right, "Temperature")
TitleRow(right, "Support")
c = SettingRow(right, "Support type", 'support', ['None', 'Exterior only', 'Everywhere', 'Empty layers only'], 'Type of support structure build.\nNone does not do any support.\nExterior only only creates support on the outside.\nEverywhere creates support even on the insides of the model.\nOnly on empty layers is for stacked objects.')
(left, right) = self.CreateConfigTab(nb, 'Machine && Filament')
@ -117,6 +123,11 @@ class mainWindow(wx.Frame):
c = SettingRow(right, "Bottom layer speed", 'bottom_layer_speed', '25')
validators.validFloat(c, 0.0)
TitleRow(right, "Cool")
#c = SettingRow(right, "Cool type", self.plugins['cool'].preferencesDict['Cool_Type'])
c = SettingRow(right, "Minimal layer time (sec)", 'cool_min_layer_time', '10', 'Minimum time spend in a layer, gives the layer time to cool down before the next layer is put on top. If the layer will be placed down too fast the printer will slow down to make sure it has spend atleast this amount of seconds printing this layer.')
validators.validFloat(c, 0.0)
TitleRow(right, "Filament")
c = SettingRow(right, "Diameter (mm)", 'filament_diameter', '2.98', 'Diameter of your filament, as accurately as possible.\nIf you cannot measure this value you will have to callibrate it, a higher number means less extrusion, a smaller number generates more extrusion.')
validators.validFloat(c, 1.0)
@ -150,7 +161,10 @@ class mainWindow(wx.Frame):
self.popup.sizer.Add(self.popup.text, flag=wx.EXPAND|wx.ALL, border=1)
self.popup.SetSizer(self.popup.sizer)
if self.filename != None:
self.preview3d.loadModelFile(self.filename)
self.lastPath = os.path.split(self.filename)[0]
self.updateProfileToControls()
self.Fit()
@ -228,6 +242,7 @@ class mainWindow(wx.Frame):
dlg.SetWildcard("OBJ, STL files (*.stl;*.obj)|*.stl;*.obj")
if dlg.ShowModal() == wx.ID_OK:
self.filename=dlg.GetPath()
putPreference('lastFile', self.filename)
if not(os.path.exists(self.filename)):
return
self.lastPath = os.path.split(self.filename)[0]
@ -297,7 +312,10 @@ class SettingRow():
self.configName = configName
self.label = wx.StaticText(panel, -1, label)
self.ctrl = wx.TextCtrl(panel, -1, settings.getSetting(configName, defaultValue))
if isinstance(defaultValue, types.StringTypes):
self.ctrl = wx.TextCtrl(panel, -1, settings.getSetting(configName, defaultValue))
else:
self.ctrl = wx.ComboBox(panel, -1, settings.getSetting(configName, defaultValue[0]), choices=defaultValue, style=wx.CB_DROPDOWN|wx.CB_READONLY)
#self.helpButton = wx.Button(panel, -1, "?", style=wx.BU_EXACTFIT)
#self.helpButton.SetToolTip(wx.ToolTip(help))
@ -354,3 +372,28 @@ class settingNotify():
return validators.SUCCESS, ''
except ValueError:
return validators.SUCCESS, ''
def getPreferencePath():
return os.path.normpath(os.path.join(os.path.dirname(os.path.abspath(__file__)), "../preferences.ini"))
def getPreference(name, default):
if not globals().has_key('globalPreferenceParser'):
globalPreferenceParser = ConfigParser.ConfigParser()
globalPreferenceParser.read(getPreferencePath())
if not globalPreferenceParser.has_option('preference', name):
if not globalPreferenceParser.has_section('preference'):
globalPreferenceParser.add_section('preference')
globalPreferenceParser.set('preference', name, str(default))
print name + " not found in profile, so using default"
return default
return globalPreferenceParser.get('preference', name)
def putPreference(name, value):
#Check if we have a configuration file loaded, else load the default.
if not globals().has_key('globalPreferenceParser'):
globalPreferenceParser = ConfigParser.ConfigParser()
globalPreferenceParser.read(getPreferencePath())
if not globalPreferenceParser.has_section('preference'):
globalPreferenceParser.add_section('preference')
globalPreferenceParser.set('preference', name, str(value))
globalPreferenceParser.write(open(getPreferencePath(), 'w'))

View file

@ -69,6 +69,7 @@ class previewPanel(wx.Panel):
def DoModelLoad(self):
self.modelDirty = False
self.triangleMesh = fabmetheus_interpret.getCarving(self.modelFilename)
self.pathList = None
self.moveModel()
self.glCanvas.Refresh()
@ -99,7 +100,10 @@ class previewPanel(wx.Panel):
currentPath = {'type': 'move', 'list': [pos.copy()]}
scale = 1.0
posAbs = True
pathType = 'CUSTOM';
for line in f:
if line.startswith(';TYPE:'):
pathType = line[6:].strip()
G = self.getCodeInt(line, 'G')
if G is not None:
if G == 0 or G == 1: #Move
@ -132,7 +136,7 @@ class previewPanel(wx.Panel):
currentE = e
if currentPath['type'] != type:
pathList.append(currentPath)
currentPath = {'type': type, 'list': [currentPath['list'][-1]]}
currentPath = {'type': type, 'pathType': pathType, 'list': [currentPath['list'][-1]]}
currentPath['list'].append(newPoint)
elif G == 20: #Units are inches
scale = 25.4
@ -170,8 +174,10 @@ class previewPanel(wx.Panel):
posOffset.z = pos.z + z
else:
print "Unknown G code:" + str(G)
self.modelDirty = False
self.pathList = pathList
self.triangleMesh = None
self.modelDirty = True
self.glCanvas.Refresh()
def OnConfigClick(self, e):
@ -283,17 +289,29 @@ class PreviewGLCanvas(GLCanvas):
glEnd()
if self.parent.pathList != None:
for path in self.parent.pathList:
if path['type'] == 'move':
glColor3f(0,0,1)
if path['type'] == 'extrude':
glColor3f(1,0,0)
if path['type'] == 'retract':
glColor3f(0,1,0)
glBegin(GL_LINE_STRIP)
for v in path['list']:
glVertex3f(v.x, v.y, v.z)
glEnd()
if self.modelDisplayList == None:
self.modelDisplayList = glGenLists(1);
if self.parent.modelDirty:
self.parent.modelDirty = False
glNewList(self.modelDisplayList, GL_COMPILE)
for path in self.parent.pathList:
if path['type'] == 'move':
glColor3f(0,0,1)
if path['type'] == 'extrude':
if path['pathType'] == 'FILL':
glColor3f(0.5,0.5,0)
elif path['pathType'] == 'WALL-INNER':
glColor3f(0,1,0)
else:
glColor3f(1,0,0)
if path['type'] == 'retract':
glColor3f(0,1,1)
glBegin(GL_LINE_STRIP)
for v in path['list']:
glVertex3f(v.x, v.y, v.z)
glEnd()
glEndList()
glCallList(self.modelDisplayList)
if self.parent.triangleMesh != None:
if self.modelDisplayList == None:

View file

@ -78,6 +78,11 @@ class GcodeSmallSkein:
def parseLine(self, line):
"Parse a gcode line."
if len(line) < 1:
return
if line[0] == '(':
self.parseComment(line)
return
splitLine = getSplitLineBeforeBracketSemicolon(line)
if len(splitLine) < 1:
return
@ -108,3 +113,15 @@ class GcodeSmallSkein:
self.lastFeedRateString = feedRateString
self.lastZString = zString
self.output.write('\n')
def parseComment(self, line):
if line.startswith('(<skirt>'):
self.output.write(';TYPE:SKIRT\n');
elif line.startswith('(<edge>'):
self.output.write(';TYPE:WALL-OUTER\n');
elif line.startswith('(<loop>'):
self.output.write(';TYPE:WALL-INNER\n');
elif line.startswith('(<infill>'):
self.output.write(';TYPE:FILL\n');
elif line.startswith('(<alteration>'):
self.output.write(';TYPE:CUSTOM\n');