Skip to content

Pocket/Rough operation off-by-one: generates N-1 passes instead of N #471

@KevinTurnbull

Description

@KevinTurnbull

When using a 2D pocket operation, if the step-down value does not divide evenly into the total cut depth, Kiri:Moto calculates the correct number of equal passes but only generates N-1 of them, leaving the pocket short of the target depth.

Steps to Reproduce

  1. Create a 2D pocket operation
  2. Set cut depth to 5mm
  3. Set step-down to 2.49mm
  4. Z origin: top of stock
  5. Stock offset: 0x0x0
  6. Slice and inspect the generated G-code

Expected Behavior

5mm / 2.49mm = 2.008 → rounds up to 3 passes:

  • Pass 1: Z = -1.667
  • Pass 2: Z = -3.333
  • Pass 3: Z = -5.000

Actual Behavior

Only 2 of 3 passes are generated:

  • Pass 1: Z = -1.6766
  • Pass 2: Z = -3.3433
  • Pass 3: missing

The pocket is cut to -3.3433mm instead of the requested -5mm.

Analysis

It appears the total depth is divided by the correct number of passes (3), producing equal step sizes (~1.667mm), but only N-1 passes are executed. This looks like an off-by-one error in the pass generation loop.

Workaround

Use a step-down value that divides evenly into the total depth (e.g., 2.5mm for a 5mm cut).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions