chiark / gitweb /
Added slice date/time and basic settings to start GCode. And made export preserve...
authorDaid <daid303@gmail.com>
Sun, 20 May 2012 09:15:20 +0000 (11:15 +0200)
committerDaid <daid303@gmail.com>
Sun, 20 May 2012 09:15:20 +0000 (11:15 +0200)
Cura/cura_sf/skeinforge_application/skeinforge_plugins/craft_plugins/alteration.py
Cura/cura_sf/skeinforge_application/skeinforge_plugins/craft_plugins/export.py
Cura/cura_sf/skeinforge_application/skeinforge_plugins/craft_plugins/export_plugins/static_plugins/gcode_small.py
Cura/util/profile.py

index be5eb4fa066f0da47245030740f0dbd94dd47e4a..38aab5b4d21c0756977dbe9ddc549a3e469c568f 100644 (file)
@@ -164,7 +164,7 @@ class AlterationSkein:
        "A class to alteration a skein of extrusions."
        def __init__(self):
                'Initialize.'
-               self.distanceFeedRate = gcodec.DistanceFeedRate()
+               self.distanceFeedRate = gcodec.DistanceFeedRate()
                self.lineIndex = 0
                self.settingDictionary = None
 
@@ -211,7 +211,7 @@ class AlterationSkein:
                if self.settingDictionary == None:
                        return self.distanceFeedRate.output.getvalue().replace('(<alterationDeleteThisPrefix/>)', '')
                lines = archive.getTextLines(self.distanceFeedRate.output.getvalue())
-               distanceFeedRate = gcodec.DistanceFeedRate()
+               distanceFeedRate = gcodec.DistanceFeedRate()
                for line in lines:
                        if line.startswith('(<alterationDeleteThisPrefix/>)'):
                                line = self.getReplacedAlterationLine(line[len('(<alterationDeleteThisPrefix/>)') :])
index 08eb6667f92168ac166de5437a410b1c50477ea0..72b0760a92d4bcc839c30c209fc5550a44b0fac2 100644 (file)
@@ -398,6 +398,7 @@ class ExportSkein:
                'Parse a gcode line.'
                splitLine = gcodec.getSplitLineBeforeBracketSemicolon(line)
                if len(splitLine) < 1:
+                       self.addLine(line)
                        return
                firstWord = splitLine[0]
                if firstWord == '(</crafting>)':
index 62c18e2affb4e22342f547aadc5ea29a7fc7e81d..4a02b282d2e6d3d3ebb4ec1abf54de5ab5c5f9ac 100644 (file)
@@ -69,6 +69,7 @@ class GcodeSmallSkein:
                self.lastZString = None
                self.output = cStringIO.StringIO()
                self.layerNr = 0
+               self.parsingAlteration = False
 
        def getCraftedGcode( self, gcodeText ):
                "Parse gcode text and store the gcode."
@@ -127,7 +128,10 @@ class GcodeSmallSkein:
                elif line.startswith('(<infill>'):
                        self.output.write(';TYPE:FILL\n');
                elif line.startswith('(<alteration>'):
-                       self.output.write(';TYPE:CUSTOM\n');
+                       self.output.write(';TYPE:CUSTOM X\n');
+                       self.parsingAlteration = True
+               elif line.startswith('(</alteration>)'):
+                       self.parsingAlteration = False
                elif line.startswith('(<supportLayer>'):
                        self.output.write(';TYPE:SUPPORT\n');
                elif line.startswith('(<layer>'):
index a6aa6d6841c3d1142af674567ce8ca4665d40dd8..235f1c388ecc9541073dfa98415382c22ae795f4 100644 (file)
@@ -3,7 +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, os, traceback, math, re, zlib, base64\r
+import ConfigParser, os, traceback, math, re, zlib, base64, time\r
 \r
 #########################################################\r
 ## Default settings when none are found.\r
@@ -76,7 +76,8 @@ profileDefaultSettings = {
 }\r
 alterationDefault = {\r
 #######################################################################################\r
-       'start.gcode': """;Start GCode\r
+       'start.gcode': """;Sliced at: {day} {date} {time}\r
+;Basic settings: Layer height: {layer_height} Walls: {wall_thickness} Fill: {fill_density}\r
 G21        ;metric values\r
 G90        ;absolute positioning\r
 M107       ;start with the fan off\r
@@ -364,6 +365,12 @@ def calculateSolidLayerCount():
 #########################################################\r
 def replaceTagMatch(m):\r
        tag = m.group(0)[1:-1]\r
+       if tag == 'time':\r
+               return time.strftime('%H:%M:%S')\r
+       if tag == 'date':\r
+               return time.strftime('%d %b %Y')\r
+       if tag == 'day':\r
+               return time.strftime('%a')\r
        if tag in ['print_speed', 'retraction_speed', 'travel_speed', 'max_z_speed', 'bottom_layer_speed', 'cool_min_feedrate']:\r
                f = getProfileSettingFloat(tag) * 60\r
        elif isProfileSetting(tag):\r