From 95f06877648058ed7026fd1e7ea50ec429625703 Mon Sep 17 00:00:00 2001 From: Jochen Ullrich Date: Fri, 8 Dec 2023 16:56:23 +0100 Subject: [PATCH] Fix logic for Slic3r as well --- preprocess_cancellation.py | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/preprocess_cancellation.py b/preprocess_cancellation.py index 526d3aa..e6357e6 100644 --- a/preprocess_cancellation.py +++ b/preprocess_cancellation.py @@ -329,19 +329,21 @@ def preprocess_slicer(infile): y = float(params["Y"]) current_hull.add_point(Point(x, y)) + infile.seek(0) for line in infile: - yield line if line.strip() and not line.startswith(";"): + # Inject custom marker + yield from header(len(known_objects)) + for object_id, hull in known_objects.values(): + yield from define_object( + object_id, + center=hull.center(), + polygon=hull.exterior(), + ) + yield line break - - yield from header(len(known_objects)) - for object_id, hull in known_objects.values(): - yield from define_object( - object_id, - center=hull.center(), - polygon=hull.exterior(), - ) + yield line for line in infile: yield line