From 3192b0ac71f238d4bd6d0573574f880182b49396 Mon Sep 17 00:00:00 2001 From: Daid Date: Sun, 20 May 2012 11:15:20 +0200 Subject: [PATCH] Added slice date/time and basic settings to start GCode. And made export preserve lines that only had comments. --- .../skeinforge_plugins/craft_plugins/alteration.py | 4 ++-- .../skeinforge_plugins/craft_plugins/export.py | 1 + .../export_plugins/static_plugins/gcode_small.py | 6 +++++- Cura/util/profile.py | 11 +++++++++-- 4 files changed, 17 insertions(+), 5 deletions(-) diff --git a/Cura/cura_sf/skeinforge_application/skeinforge_plugins/craft_plugins/alteration.py b/Cura/cura_sf/skeinforge_application/skeinforge_plugins/craft_plugins/alteration.py index be5eb4fa..38aab5b4 100644 --- a/Cura/cura_sf/skeinforge_application/skeinforge_plugins/craft_plugins/alteration.py +++ b/Cura/cura_sf/skeinforge_application/skeinforge_plugins/craft_plugins/alteration.py @@ -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('()', '') lines = archive.getTextLines(self.distanceFeedRate.output.getvalue()) - distanceFeedRate = gcodec.DistanceFeedRate() + distanceFeedRate = gcodec.DistanceFeedRate() for line in lines: if line.startswith('()'): line = self.getReplacedAlterationLine(line[len('()') :]) diff --git a/Cura/cura_sf/skeinforge_application/skeinforge_plugins/craft_plugins/export.py b/Cura/cura_sf/skeinforge_application/skeinforge_plugins/craft_plugins/export.py index 08eb6667..72b0760a 100644 --- a/Cura/cura_sf/skeinforge_application/skeinforge_plugins/craft_plugins/export.py +++ b/Cura/cura_sf/skeinforge_application/skeinforge_plugins/craft_plugins/export.py @@ -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 == '()': diff --git a/Cura/cura_sf/skeinforge_application/skeinforge_plugins/craft_plugins/export_plugins/static_plugins/gcode_small.py b/Cura/cura_sf/skeinforge_application/skeinforge_plugins/craft_plugins/export_plugins/static_plugins/gcode_small.py index 62c18e2a..4a02b282 100644 --- a/Cura/cura_sf/skeinforge_application/skeinforge_plugins/craft_plugins/export_plugins/static_plugins/gcode_small.py +++ b/Cura/cura_sf/skeinforge_application/skeinforge_plugins/craft_plugins/export_plugins/static_plugins/gcode_small.py @@ -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('('): self.output.write(';TYPE:FILL\n'); elif line.startswith('('): - self.output.write(';TYPE:CUSTOM\n'); + self.output.write(';TYPE:CUSTOM X\n'); + self.parsingAlteration = True + elif line.startswith('()'): + self.parsingAlteration = False elif line.startswith('('): self.output.write(';TYPE:SUPPORT\n'); elif line.startswith('('): diff --git a/Cura/util/profile.py b/Cura/util/profile.py index a6aa6d68..235f1c38 100644 --- a/Cura/util/profile.py +++ b/Cura/util/profile.py @@ -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. import __init__ -import ConfigParser, os, traceback, math, re, zlib, base64 +import ConfigParser, os, traceback, math, re, zlib, base64, time ######################################################### ## Default settings when none are found. @@ -76,7 +76,8 @@ profileDefaultSettings = { } alterationDefault = { ####################################################################################### - 'start.gcode': """;Start GCode + 'start.gcode': """;Sliced at: {day} {date} {time} +;Basic settings: Layer height: {layer_height} Walls: {wall_thickness} Fill: {fill_density} G21 ;metric values G90 ;absolute positioning M107 ;start with the fan off @@ -364,6 +365,12 @@ def calculateSolidLayerCount(): ######################################################### def replaceTagMatch(m): tag = m.group(0)[1:-1] + if tag == 'time': + return time.strftime('%H:%M:%S') + if tag == 'date': + return time.strftime('%d %b %Y') + if tag == 'day': + return time.strftime('%a') if tag in ['print_speed', 'retraction_speed', 'travel_speed', 'max_z_speed', 'bottom_layer_speed', 'cool_min_feedrate']: f = getProfileSettingFloat(tag) * 60 elif isProfileSetting(tag): -- 2.30.2