Skip to content

Path Optimization

Marius Stanciu edited this page Oct 29, 2026 · 1 revision

Path optimization sets the order in which the tool visits the paths of a job, or the holes of a drill job. A good order makes the rapid (empty) travel short and the job faster.

Where to find it

  • Path Optimization group of the Excellon (drilling) preferences: see Preferences Excellon.
  • Path Optimization group of the Geometry preferences (milling, isolation, NCC, paint, cutout): see Preferences Geometry.
  • Path Optimization group in the Milling tool, which stores the choice for each tool.

Quick start

  1. Open Preferences > Excellon for drilling, or Preferences > Geometry for milling.
  2. In Path Optimization, select Algorithm. Rtree is the default for milling. MetaHeuristic and Basic need 64-bit Python.
  3. For MetaHeuristic or Basic, set Duration (seconds).
  4. Make the job again. The rapid travel of the new G-code is shorter when the job has many holes or paths.

Parameters

Excellon (drilling) preferences

Parameter Description Default
Algorithm Rtree: nearest neighbour walk, then a pass that shortens the travel. MetaHeuristic: OR-Tools guided local search. Basic: OR-Tools basic search. TSA: nearest neighbour order (travelling salesman heuristic). Basic (B)
Duration Time limit of the OR-Tools search (MetaHeuristic and Basic), in seconds. 0 uses 3 seconds. 3

Geometry preferences

Parameter Description Default
Algorithm Rtree, MetaHeuristic, Basic, TSA, and None. None keeps the order in which the paths were made (no optimization). Rtree (R)
Duration Time limit of the OR-Tools search, in seconds (as above). 3

Milling tool

Parameter Description Default
Algorithm The same choices as the Geometry preferences. The tool stores its own choice. A tool that has no choice takes the Geometry preference. Rtree
Duration The OR-Tools time limit for this tool. 3

Advanced

The algorithms

Code Name What it does
R Rtree A nearest neighbour walk on a grid of the path end points, then a pass (2-opt, or Or-opt for one path) that only shortens the travel. A path can be cut from its first or its last point. The result is the same for the same input. The time is bounded by a step count, not by the clock.
M MetaHeuristic Google OR-Tools routing with the guided local search metaheuristic. The search stops after the Duration.
B Basic Google OR-Tools routing with the basic search. The search stops after the Duration.
T TSA A nearest neighbour order from the start point. It is quick, and it is O(N^2) in time. It does not add two duplicate points in a row.
N None No optimization (milling only). The paths are cut in the order they were made.

Starting point

  • Milling with Rtree: the walk starts at (0, 0), the origin of the workpiece.
  • Exact duplicate holes are drilled once. The first one keeps its place in the list.

Fallbacks

  • The OR-Tools algorithms (MetaHeuristic and Basic) need OR-Tools, which is available only with 64-bit Python. Without it these choices are disabled, and the job uses Rtree.
  • If an OR-Tools search finds no route, the job uses Rtree.
  • When the job has no paths or no holes, the job reports that no usable geometry was found.

Parameters that are stored

Option Default Meaning
excellon_optimization_type B Excellon algorithm (preferences).
excellon_search_time 3 Excellon search time, in seconds.
tools_mill_optimization_type R Geometry and milling algorithm.
tools_mill_search_time 3 Geometry and milling search time.

Tips

  • None keeps the paths in the order they were made. It shows the effect of the optimization.
  • The cncjob Tcl command also has a search time option (see Tcl Command Reference).

See also

Clone this wiki locally