From 84dcb860524d13be57f997fb03ff730511a6faf9 Mon Sep 17 00:00:00 2001 From: Anson Liu Date: Sat, 1 Feb 2025 20:17:21 -0800 Subject: [PATCH] Fix bug where features could have WIPE_END in beginning and not at the end --- ...AofPlastic-dual-meters-Z200-rise1-5mm.json | 8 +++--- slicer-setup.md | 2 +- src/mfm/map_post_process.py | 27 +++++++++++++------ src/mfm/printing_constants.py | 1 + 4 files changed, 25 insertions(+), 13 deletions(-) diff --git a/premade_options/USAofPlastic-dual-meters-Z200-rise1-5mm.json b/premade_options/USAofPlastic-dual-meters-Z200-rise1-5mm.json index fa89985..bfba993 100644 --- a/premade_options/USAofPlastic-dual-meters-Z200-rise1-5mm.json +++ b/premade_options/USAofPlastic-dual-meters-Z200-rise1-5mm.json @@ -2,12 +2,12 @@ "modelToRealWorldDefaultUnits": 1000, "modelOneToNVerticalScale": 250000, "modelSeaLevelBaseThickness": 6.6, - "realWorldIsolineElevationInterval": 500, - "realWorldIsolineElevationStart": 500, + "realWorldIsolineElevationInterval": 300, + "realWorldIsolineElevationStart": 301, "realWorldIsolineElevationEnd": 30000, - "modelIsolineHeight": 0.1, + "modelIsolineHeight": 0.01, "isolineColorIndex": 2, - "isolineColorFeatureTypes": ["Outer wall", "Inner wall", "External perimeter", "Perimeter"], + "isolineColorFeatureTypes": ["Outer wall", "External perimeter"], "realWorldElevationReplacementColorStart": 2300, "realWorldElevationReplacementColorEnd": 30000, "replacementColorIndex": 3, diff --git a/slicer-setup.md b/slicer-setup.md index 655b405..70ed731 100644 --- a/slicer-setup.md +++ b/slicer-setup.md @@ -114,4 +114,4 @@ If you plan to do the processing through the standalone MFM GUI app, you can ski If you intend to add isolines and using Ironing on the top surface, the standard ironing inset will cover up the isoline color on the outer wall. -Set Ironing inset to your line width (nozzle diameter) * 1.25 to not obscure the isolines. \ No newline at end of file +Set Ironing inset to your line width (nozzle diameter) multiplied between 1 and 1.25 to not obscure the isolines. diff --git a/src/mfm/map_post_process.py b/src/mfm/map_post_process.py index 0120a7d..3b98c2c 100644 --- a/src/mfm/map_post_process.py +++ b/src/mfm/map_post_process.py @@ -783,14 +783,25 @@ def process(configuration: MFMConfiguration, statusQueue: queue.Queue): #print(f"start feature toolchange skip ") if curFeature.wipeEnd and f.tell() == curFeature.wipeEnd.start and curFeature.featureType not in RETAIN_WIPE_END_FEATURE_TYPES: - writeWithFilters(out, cl, loadedColors) - #print(f"Skipping feature WIPE_END. Start skip at {f.tell()}") - out.write(";WIPE_END placeholder for PrusaSlicer Gcode Viewer\n") - out.write("; WIPE_END placeholder for BambuStudio Gcode Preview\n") - out.write("; MFM Original WIPE_END skipped\n") - currentPrint.skipWrite = True - # Reference original pos as last wipe end pos for next layer - currentPrint.featureWipeEndPrime = currentPrint.originalPosition + # Keep wipe if WIPE_END is greater than N lines before feature end + linesUntilFeatureEnd = 0 + while f.tell() < curFeature.end and linesUntilFeatureEnd <= RETAIN_WIPE_END_IF_FEATURE_END_NOT_WITHIN_N_LINES: + _ = f.readline() + linesUntilFeatureEnd += 1 + + # Restore file position + f.seek(curFeature.wipeEnd.start) + + # Skip wipe end + if linesUntilFeatureEnd <= RETAIN_WIPE_END_IF_FEATURE_END_NOT_WITHIN_N_LINES: + writeWithFilters(out, cl, loadedColors) + #print(f"Skipping feature WIPE_END. Start skip at {f.tell()}") + out.write(";WIPE_END placeholder for PrusaSlicer Gcode Viewer\n") + out.write("; WIPE_END placeholder for BambuStudio Gcode Preview\n") + out.write("; MFM Original WIPE_END skipped\n") + currentPrint.skipWrite = True + # Reference original pos as last wipe end pos for next layer + currentPrint.featureWipeEndPrime = currentPrint.originalPosition # Write current line diff --git a/src/mfm/printing_constants.py b/src/mfm/printing_constants.py index dea1434..fe8fedc 100644 --- a/src/mfm/printing_constants.py +++ b/src/mfm/printing_constants.py @@ -67,6 +67,7 @@ WIPE_START = '^;\s?WIPE_START' WIPE_END = '^;\s?WIPE_END' RETAIN_WIPE_END_FEATURE_TYPES = ['Internal infill'] +RETAIN_WIPE_END_IF_FEATURE_END_NOT_WITHIN_N_LINES = 6 # Start and stop individual object #STOP_OBJECT = '^;\s(?:stop printing object)\s?(?:, unique label|.*)\sid:?\s?(\d*)'