diff --git a/README.md b/README.md index 5e84990..a7d5ac0 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,8 @@ Restart Inkscape and you're done. if you are just changing the `.py` you dont ha ![XY Plotter tool panel](img/GcodePanelByLOD.jpeg) +**Note:** Hidden layers (eye icon disabled in Inkscape) are automatically skipped during G-code generation. + | Name | Definition | Default | Gcode Result | |---|---| --- | --- | | **Drawing On Command** | Gcode commande to lower down the Z-axis | `M3` | `M3 S1000` | @@ -29,8 +31,9 @@ Restart Inkscape and you're done. if you are just changing the `.py` you dont ha | **Pen Up Travel speed** | Travel speed with Pen Up | `3000` | `G1 F3000` | | **Pen Down Travel speed** | Travel speed when drawing | `1500` | `G1 F1500` | | **Pen Active Power** | command value to lower the pen | `1000` | `M3 S1000` | -| **Pen On Delay** | Delay after moving and before drawing | `0,1` | `G4 P0.1` | -| **Pen Off Delay** | Delay after drawing and before moving | `0,2` | `G4 P0.2` | +| **Settling Delay** | Delay after movement to allow mechanical settling | `0.15` | `G4 P0.15` | +| **Pen On Delay** | Delay after pen-down before drawing | `0.2` | `G4 P0.2` | +| **Pen Off Delay** | Delay after drawing before pen-up | `0.2` | `G4 P0.2` | | **X Offset** | X-axis offset for plotter start position | `180` | All X coordinates shifted by offset value | | **Y Offset** | Y-axis offset for plotter start position | `0` | All Y coordinates shifted by offset value | | **Passes** | Number of Passes | | | diff --git a/plotter-lod.py b/plotter-lod.py index a40776e..c709d65 100644 --- a/plotter-lod.py +++ b/plotter-lod.py @@ -1137,6 +1137,7 @@ class LaserGcode(inkex.Effect): self.paths = {} self.orientation_points = {} self.layers = [self.document.getroot()] + self.hidden_layers = set() self.Zcoordinates = {} self.transform_matrix = {} self.transform_matrix_reverse = {} @@ -1150,6 +1151,10 @@ class LaserGcode(inkex.Effect): self.selected_hack[i.get("id")] = i if i.tag == inkex.addNS("g", 'svg') and i.get(inkex.addNS('groupmode', 'inkscape')) == 'layer': self.layers += [i] + # Check if layer is hidden + if self.is_layer_hidden(i): + self.hidden_layers.add(i) + print_("Skipping hidden layer: '%s'" % i.get(inkex.addNS('label', 'inkscape'))) recursive_search(i, i) elif i.get('gcodetools') == "Gcodetools orientation group": points = self.get_orientation_points(i) @@ -1178,6 +1183,23 @@ class LaserGcode(inkex.Effect): recursive_search(self.document.getroot(), self.document.getroot()) + def is_layer_hidden(self, layer): + """Check if a layer is hidden based on Inkscape visibility settings""" + # Check style attribute for display:none + style = layer.get('style', '') + if 'display:none' in style.replace(' ', ''): + return True + + # Check sodipodi:insensitive attribute (layer locked/hidden) + if layer.get(inkex.addNS('insensitive', 'sodipodi')) == 'true': + return True + + # Check inkscape:groupmode and style combination + if layer.get('display') == 'none': + return True + + return False + def get_orientation_points(self, g): items = g.getchildren() items.reverse() @@ -1341,6 +1363,11 @@ class LaserGcode(inkex.Effect): print_(("self.layers=", self.layers)) print_(("paths=", paths)) for layer in self.layers: + # Skip hidden layers + if layer in self.hidden_layers: + print_("Skipping hidden layer in gcode generation: '%s'" % layer.get(inkex.addNS('label', 'inkscape'))) + continue + if layer in paths: print_(("layer", layer)) p = []