works with Cura 5.1.1

This commit is contained in:
2022-10-31 19:07:24 +01:00
parent f70ccf1e78
commit 180b4ef5ec

View File

@@ -11,6 +11,7 @@ logging.basicConfig(level=logging.DEBUG,
FLOAT_OR_INT = r'-?\d+(\.\d*)?'
RE_ENGINE_VERSION = re.compile(r'SteamEngine (\d+\.\d+\.\d+)')
RE_ENGINE_V5 = re.compile(r'\n(.*SteamEngine main.*)\n')
RE_LAYER_COUNT = re.compile(r';LAYER_COUNT:(\d+)', re.MULTILINE)
RE_LAYER_NUMBER = re.compile(r';LAYER:(\d+)')
RE_FOOTER_START = re.compile(r'(;TIME_ELAPSED:\d+\.\d+)\n[^;]', re.MULTILINE)
@@ -55,7 +56,18 @@ class GcodeFileAnalyzer:
fullCode = '\n'.join(self.lines)
versionMatch = RE_ENGINE_VERSION.search(fullCode)
self.curaVersion = tuple(int(v) for v in versionMatch.group(1).split('.'))
if versionMatch:
self.curaVersion = tuple(int(v) for v in versionMatch.group(1).split('.'))
logging.info('Cura version {self.curaVersion}')
else:
v5engineMatch = RE_ENGINE_V5.search(fullCode)
if v5engineMatch:
logging.info('Cura version not specified. Assuming 5.x')
logging.info(f' -> {v5engineMatch.group(1)}')
self.curaVersion = (5, 0, 0)
else:
raise ValueError('Could not find ";Generated with Cura_SteamEngine" '
'in GCODE. Can\'t proceed')
# Find footer
footerStartMatch = RE_FOOTER_START.search(fullCode)
@@ -240,5 +252,5 @@ if __name__ == '__main__':
# [124])
# GcodeFileAnalyzer.SplitFileAtLayers(r"Q:\DIY\3Dprint\Models\Thingiverse\MoonLamp\gcode\moon5inches.gcode",
# [100, 200, 400, 600, 700])
GcodeFileAnalyzer.SplitFileAtLayers(r"Q:\DIY\3Dprint\Models\Pi\PiJukebox\bottom_2020-11-22\bottom.gcode",
[87])
GcodeFileAnalyzer.SplitFileAtLayers(r"Q:\DIY\3Dprint\Models\Benjamin\Vier_Cura5.1.1.gcode",
[42])