Support setting tags in start/end gcode.

This commit is contained in:
daid 2012-04-19 15:08:50 +02:00
parent befa69dfa5
commit 814d4bfddb
3 changed files with 28 additions and 23 deletions

View file

@ -1,7 +1,6 @@
M104 S0 ;extruder heat off
G91 ;relative positioning
G1 Z+10 E-5 F400 ;move Z up a bit and retract filament by 5mm
G28 X0 Y0 ;move X/Y to min endstops, so the head is out of the way
M84 ;steppers off
G90 ;absolute positioning
M104 S0 ;extruder heat off
G91 ;relative positioning
G1 Z+10 E-5 F{max_z_speed} ;move Z up a bit and retract filament by 5mm
G28 X0 Y0 ;move X/Y to min endstops, so the head is out of the way
M84 ;steppers off
G90 ;absolute positioning

View file

@ -8,13 +8,14 @@ G28 Z0 ;move Z to min endstops
; to Z1.0 - the number after the Z is the actual, physical
; height of the nozzle in mm. This can take some messing around
; with to get just right...
G92 X0 Y0 Z0 E0 ;reset software position to front/left/z=0.0
G1 Z15.0 F400 ;move the platform down 15mm
G92 E0 ;zero the extruded length
G92 X0 Y0 Z0 E0 ;reset software position to front/left/z=0.0
G1 Z15.0 F{max_z_speed} ;move the platform down 15mm
G92 E0 ;zero the extruded length
G1 F75 E5 ;extrude 5mm of feed stock
G1 F75 E3.5 ;reverse feed stock by 1.5mm
G92 E0 ;zero the extruded length again
G1 F200 E5 ;extrude 5mm of feed stock
G1 F200 E3.5 ;reverse feed stock by 1.5mm
G92 E0 ;zero the extruded length again
G1 X100 Y100 F3500 ;go to the middle of the platform
G1 Z0.0 F400 ;back to Z=0 and start the print!
;go to the middle of the platform, and move to Z=0 before starting the print.
G1 X{machine_center_x} Y{machine_center_y} F{travel_speed}
G1 Z0.0 F{max_z_speed}

View file

@ -3,10 +3,7 @@ from __future__ import division
#Init has to be imported first because it has code to workaround the python bug where relative imports don't work if the module is imported as a main module.
import __init__
import ConfigParser
import os
import traceback
import math
import ConfigParser, os, traceback, math, re
#########################################################
## Profile and preferences functions
@ -64,10 +61,10 @@ profileDefaultSettings = {
'bridge_material_amount': '100',
'raft_margin': '5',
'raft_base_material_amount': '100',
'raft_interface_material_amount': '100',
'raft_interface_material_amount': '100',
'bottom_thickness': '0.3',
'add_start_end_gcode': 'True',
'gcode_extension': 'gcode',
'gcode_extension': 'gcode',
}
preferencesDefaultSettings = {
'wizardDone': 'False',
@ -232,10 +229,16 @@ def getCuraBasePath():
def getAlterationFilePath(filename):
return os.path.join(getCuraBasePath(), "alterations", filename)
def getAlterationFileContents(filename, allowMagicPrefix = True):
def replaceTagMatch(m):
tag = m.group(0)[1:-1]
if tag in ['print_speed', 'retraction_speed', 'travel_speed', 'max_z_speed', 'bottom_layer_speed', 'cool_min_feedrate']:
return str(getProfileSettingFloat(tag) * 60)
return str(getProfileSettingFloat(tag))
def getAlterationFileContents(filename, modifyForOutput = True):
"Get the file from the fileName or the lowercase fileName in the alterations directories."
prefix = ''
if allowMagicPrefix:
if modifyForOutput:
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.
@ -252,6 +255,8 @@ def getAlterationFileContents(filename, allowMagicPrefix = True):
file = open(fullFilename, "r")
fileText = file.read()
file.close()
if modifyForOutput:
fileText = re.sub("\{[^\}]*\}", replaceTagMatch, fileText)
return prefix + fileText
return prefix