Parse single-line gcode for SVG preview
Browse files
app.py
CHANGED
|
@@ -268,11 +268,13 @@ def gcode_to_svg(gcode: str) -> str:
|
|
| 268 |
x, y = 0.0, 0.0
|
| 269 |
pen_down = False
|
| 270 |
|
|
|
|
| 271 |
lines = []
|
| 272 |
-
for line in gcode.split("\n"):
|
| 273 |
line = line.strip()
|
| 274 |
if not line:
|
| 275 |
continue
|
|
|
|
| 276 |
parts = re.split(r'(?=[GM]\d)', line)
|
| 277 |
for part in parts:
|
| 278 |
part = part.strip()
|
|
|
|
| 268 |
x, y = 0.0, 0.0
|
| 269 |
pen_down = False
|
| 270 |
|
| 271 |
+
# Split on newlines OR command boundaries (for single-line gcode)
|
| 272 |
lines = []
|
| 273 |
+
for line in gcode.replace(";", "\n;").split("\n"):
|
| 274 |
line = line.strip()
|
| 275 |
if not line:
|
| 276 |
continue
|
| 277 |
+
# Split on G/M commands
|
| 278 |
parts = re.split(r'(?=[GM]\d)', line)
|
| 279 |
for part in parts:
|
| 280 |
part = part.strip()
|