From 51a436ff5ba0a333b253835fd879b8bf4ff4cab7 Mon Sep 17 00:00:00 2001 From: devdesk Date: Wed, 3 Dec 2025 19:43:40 +0200 Subject: [PATCH] Add configurable X/Y offset parameters for plotter positioning - Added offset-x and offset-y parameters to plotter-lod.inx (default: X=180, Y=0) - Updated plotter-lod.py to apply offsets to all G-code coordinates - Modified footer to use dynamic offset values - Allows users to adjust plotter start position through GUI without code changes --- plotter-lod.inx | 2 ++ plotter-lod.py | 15 +++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/plotter-lod.inx b/plotter-lod.inx index 2e3a092..abc0ac5 100644 --- a/plotter-lod.inx +++ b/plotter-lod.inx @@ -12,6 +12,8 @@ 1000 0,2 0,2 + 180 + 0 1 1 diff --git a/plotter-lod.py b/plotter-lod.py index c2c9b2d..4590798 100644 --- a/plotter-lod.py +++ b/plotter-lod.py @@ -134,6 +134,7 @@ G0 Z0 'footer': """G1 X0 Y0 """ + # Note: footer will be dynamically updated with offset values in check_dir() } intersection_recursion_depth = 10 @@ -642,6 +643,12 @@ class LaserGcode(inkex.Effect): {"name": "--plotter-off-delay", "type": str, "dest": "plotter_off_delay", "default": "0", "help": "Laser power-on delay (ms},"}, + {"name": "--offset-x", "type": float, "dest": "offset_x", + "default": 180.0, "help": "X axis offset (mm or in)"}, + + {"name": "--offset-y", "type": float, "dest": "offset_y", + "default": 0.0, "help": "Y axis offset (mm or in)"}, + {"name": "--suppress-all-messages", "type": inkex.Boolean, "dest": "suppress_all_messages", "default": True, "help": "Hide messages during g-code generation"}, @@ -825,6 +832,9 @@ class LaserGcode(inkex.Effect): f.close() else: self.footer = defaults['footer'] + + # Always apply dynamic offset values to footer + self.footer = "G1 X%s Y%s\n\n" % (self.options.offset_x, self.options.offset_y) if self.options.unit == "G21 (All units in mm)": self.header += "G21\n" @@ -878,6 +888,11 @@ class LaserGcode(inkex.Effect): def c(c): c = [c[i] if i < len(c) else None for i in range(6)] if c[5] == 0: c[5] = None + # Apply plotter offset from options + if c[0] != None: + c[0] = c[0] + self.options.offset_x + if c[1] != None: + c[1] = c[1] + self.options.offset_y s = [" X", " Y", " Z", " I", " J", " K"] r = '' for i in range(6):