chiark / gitweb /
Support setting tags in start/end gcode.
authordaid <daid303@gmail.com>
Thu, 19 Apr 2012 13:08:50 +0000 (15:08 +0200)
committerdaid <daid303@gmail.com>
Thu, 19 Apr 2012 13:08:50 +0000 (15:08 +0200)
Cura/alterations/end.gcode
Cura/alterations/start.gcode
Cura/util/profile.py

index 4061667ec4374c48bd37a2a0d763ff5691e260f5..a84b13158efa40aade10e83a284e4533a266dffb 100644 (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
index 7db5699cfdabe3341ad31ef5dde264282040e869..94869d21b2128047c02f8237a5ef2d75a2f64fe5 100644 (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}
index dfc2afda055c0b8c0974f9caedc318163ca05d00..44d85994842a0f6abcb059e651a14486d9b82660 100644 (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.\r
 import __init__\r
 \r
-import ConfigParser\r
-import os\r
-import traceback\r
-import math\r
+import ConfigParser, os, traceback, math, re\r
 \r
 #########################################################\r
 ## Profile and preferences functions\r
@@ -64,10 +61,10 @@ profileDefaultSettings = {
        'bridge_material_amount': '100',\r
        'raft_margin': '5',\r
        'raft_base_material_amount': '100',\r
-       'raft_interface_material_amount': '100',
+       'raft_interface_material_amount': '100',\r
        'bottom_thickness': '0.3',\r
        'add_start_end_gcode': 'True',\r
-       'gcode_extension': 'gcode',
+       'gcode_extension': 'gcode',\r
 }\r
 preferencesDefaultSettings = {\r
        'wizardDone': 'False',\r
@@ -232,10 +229,16 @@ def getCuraBasePath():
 def getAlterationFilePath(filename):\r
        return os.path.join(getCuraBasePath(), "alterations", filename)\r
 \r
-def getAlterationFileContents(filename, allowMagicPrefix = True):\r
+def replaceTagMatch(m):\r
+       tag = m.group(0)[1:-1]\r
+       if tag in ['print_speed', 'retraction_speed', 'travel_speed', 'max_z_speed', 'bottom_layer_speed', 'cool_min_feedrate']:\r
+               return str(getProfileSettingFloat(tag) * 60)\r
+       return str(getProfileSettingFloat(tag))\r
+\r
+def getAlterationFileContents(filename, modifyForOutput = True):\r
        "Get the file from the fileName or the lowercase fileName in the alterations directories."\r
        prefix = ''\r
-       if allowMagicPrefix:\r
+       if modifyForOutput:\r
                if filename == 'start.gcode':\r
                        #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.\r
                        #We also set our steps per E here, if configured.\r
@@ -252,6 +255,8 @@ def getAlterationFileContents(filename, allowMagicPrefix = True):
                file = open(fullFilename, "r")\r
                fileText = file.read()\r
                file.close()\r
+               if modifyForOutput:\r
+                       fileText = re.sub("\{[^\}]*\}", replaceTagMatch, fileText)\r
                return prefix + fileText\r
        return prefix\r
 \r