Offset Fill traveling issue

Hello!
Is it possible for “Offset Fill” mode do not travel between parts of shapes when it was not already engraved there, so it brakes the drill all the time :frowning:
For example I need to engrave “C” character, but it starts from top makes 1 line and then trying to move to another part of “C” but there is still material and drill is broken
Thanks!

So I don’t want to travel on the places where is not engraving at all. As you can see on the image it travles just trough “C” where is any engraving


On this image it is clear that traveling happening not inside the shape.
Any solution, any way to make it not traveling around but only in the shape boundaries?

I think, those requirements are mostly relevant for CNCs, but not that much for lasers. Rather than making LB work for your use case, I’d check out MillMage, which is the CNC software from LB. It is not released officially, but you might reach out to the team if a test is possible.

3 Likes

okay, I see. Maybe here some solution which will move Z up before each traveling?

I feel like I can write simple script which will add Z-traveling before XY-traveling in gcode…

Here is my solution

import sys
import os

def is_g0_no_z(line):
    stripped = line.strip().upper()
    return (stripped.startswith("G0") or stripped.startswith("G00")) and "Z" not in stripped

def is_g0_with_z(line):
    stripped = line.strip().upper()
    return (stripped.startswith("G0") or stripped.startswith("G00")) and "Z" in stripped

def process_gcode(file_path, z_offset):
    z_offset = float(z_offset)
    new_lines = []
    valid_g0_indices = []

    with open(file_path, 'r') as f:
        lines = f.readlines()

    # Find all G0/G00 without Z
    for i, line in enumerate(lines):
        if is_g0_no_z(line):
            valid_g0_indices.append(i)

    # Filter based on skipping first 3 and last 2
    g0s_to_check = valid_g0_indices[3:-2]

    # Final list of lines to modify
    to_modify = []

    for idx in g0s_to_check:
        prev = lines[idx - 1] if idx > 0 else ""
        next = lines[idx + 1] if idx + 1 < len(lines) else ""

        if not (is_g0_with_z(prev) and is_g0_with_z(next)):
            to_modify.append(idx)

    to_modify_set = set(to_modify)

    # Process and insert extra Z moves
    for i, line in enumerate(lines):
        if i in to_modify_set:
            new_lines.append(f"G0 Z{z_offset}\n")
            new_lines.append(line)
            new_lines.append(f"G0 Z-{z_offset}\n")
        else:
            new_lines.append(line)

    # Save modified G-code
    base, ext = os.path.splitext(file_path)
    new_file_path = f"{base}_FIX{ext}"

    with open(new_file_path, 'w') as f:
        f.writelines(new_lines)

    print(f"Modified G-code saved to: {new_file_path}")

if __name__ == "__main__":
    if len(sys.argv) < 3:
        print("Usage: python script.py <gcode_file> <z_offset>")
    else:
        process_gcode(sys.argv[1], sys.argv[2])

python3 fixer.py foo.gcode 3
where 3 is 3mm for Z traveling before each G0 traveling

The Custom GCode profile allows you to lift for all rapid movements if you want:

3 Likes