fix readme and type hints

This commit is contained in:
joergrs
2025-03-23 22:15:55 +01:00
parent 33462d7261
commit b8507c145f
2 changed files with 10 additions and 24 deletions

View File

@@ -42,11 +42,11 @@ class GcodeFileAnalyzer:
f.write('\n'.join(lines)) f.write('\n'.join(lines))
def __init__(self, lines): def __init__(self, lines):
self.curaVersion: tuple(int) = None self.curaVersion: tuple[int] = None
self.lines: list(str) = lines self.lines: list[str] = lines
self.header: list(str) = [] self.header: list[str] = []
self.footer: list(str) = [] self.footer: list[str] = []
self.layers: list('Layer') = [] self.layers: list['Layer'] = []
self.layerCount: int = 0 self.layerCount: int = 0
self.fanSpeedCode: str = '' self.fanSpeedCode: str = ''
self.__AnalyzeGcode() self.__AnalyzeGcode()
@@ -58,7 +58,7 @@ class GcodeFileAnalyzer:
versionMatch = RE_ENGINE_VERSION.search(fullCode) versionMatch = RE_ENGINE_VERSION.search(fullCode)
if versionMatch: if versionMatch:
self.curaVersion = tuple(int(v) for v in versionMatch.group(1).split('.')) self.curaVersion = tuple(int(v) for v in versionMatch.group(1).split('.'))
logging.info('Cura version {self.curaVersion}') logging.info(f'Cura version {self.curaVersion}')
else: else:
v5engineMatch = RE_ENGINE_V5.search(fullCode) v5engineMatch = RE_ENGINE_V5.search(fullCode)
if v5engineMatch: if v5engineMatch:
@@ -148,7 +148,7 @@ class GcodeFileAnalyzer:
# Add default header # Add default header
lines = list(self.header) lines = list(self.header)
logging.info('Exporting Layers {} ({} mm) ... {} ({} mm)' logging.info('Exporting Layers {} ({} mm) ... {} ({} mm)'
.format(startLayer.number + 1, startLayer.zHeight, .format(startLayer.number + 1, startLayer.zHeight,
endLayer.number + 1, endLayer.zHeight)) endLayer.number + 1, endLayer.zHeight))
if startLayer.number != 0: if startLayer.number != 0:
@@ -242,18 +242,4 @@ class Layer:
if __name__ == '__main__': if __name__ == '__main__':
# GcodeFileAnalyzer.SplitFileAtLayers('test/BigL.gcode', ['2.8001mm', 300]) GcodeFileAnalyzer.SplitFileAtLayers('test/BigL.gcode', ['2.8mm', 300])
# GcodeFileAnalyzer.SplitFileAtLayers(r"Q:\DIY\3Dprint\Models\Thingiverse\Murmelbahnen\The_Cyclone_triple_lift_triple_track_marble_machine\files\gcode\Marble_machine.gcode",
# ['97.3mm', 405, 480])
# GcodeFileAnalyzer.SplitFileAtLayers(r"Q:\DIY\3Dprint\Models\Thingiverse\Shuttle\Shuttle100.gcode",
# ['87.60mm'])
# GcodeFileAnalyzer.SplitFileAtLayers(r"Q:\DIY\3Dprint\Models\Geschenke\Nudossi\NudossiDeckel_Yakup.gcode",
# [124])
# GcodeFileAnalyzer.SplitFileAtLayers(r"Q:\DIY\3Dprint\Models\Geschenke\Nudossi\NudossiDeckel_Harun.gcode",
# [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\Benjamin\Vier_Cura5.1.1.gcode",
# [42])
GcodeFileAnalyzer.SplitFileAtLayers(r"Q:\DIY\3Dprint\Models\Geschenke\Mama\Herz\MarkusTinaHerz.gcode",
[31])

View File

@@ -13,7 +13,7 @@ Tested with GCode files from
## Requirements ## Requirements
* Python 3.7 * Python >=3.9
## Usage ## Usage
@@ -25,6 +25,6 @@ GcodeFileAnalyzer.SplitFileAtLayers(
) )
``` ```
* The Z position where to split the file can be given in layer number (starting with 0) or in millimeters (value must match an actual layer z position in the gcode file) * The Z position where to split the file can be given in layer number (starting with 1) or in millimeters (value must match an actual layer z position in the gcode file)
* Execute `GcodeFileSplitter.py` * Execute `GcodeFileSplitter.py`
* E.g.: `python GcodeFileSplitter.py` * E.g.: `python GcodeFileSplitter.py`