Repository navigation
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.
- 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.
- Open Preferences > Excellon for drilling, or Preferences > Geometry for milling.
- In Path Optimization, select Algorithm. Rtree is the default for milling. MetaHeuristic and Basic need 64-bit Python.
- For MetaHeuristic or Basic, set Duration (seconds).
- Make the job again. The rapid travel of the new G-code is shorter when the job has many holes or paths.
| 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 |
| 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 |
| 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 |
| 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. |
- 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.
- 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.
| 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. |
- None keeps the paths in the order they were made. It shows the effect of the optimization.
- The
cncjobTcl command also has a search time option (see Tcl Command Reference).
FlatCAM Evo Manual · Source code · Report a problem · MIT license
Start here
- Installation
- Getting Started
- Tutorial: Single-Sided PCB
- Tutorial: Double-Sided PCB
- User Interface
- Keyboard Shortcuts
- Glossary
- FAQ and Troubleshooting
Files and projects
Objects
Editors
PCB operations
- Isolation Routing
- Non-Copper Clearing
- Paint
- Cutout
- Drilling
- Milling
- Follow
- Double-Sided
- Solder Paste
- Film
- Panelize
- Copper Thieving
- Fiducials
- Markers
- Punch Gerber
- Invert Gerber
- Etch Compensation
- Extract
- Rules Check
- QR Code
Utility plugins
- Align Objects
- Calculators
- Distance · Object Distance
- Optimal
- Move · Transform
- Subtract
- Image Import · PDF Import
- PCB Wizard
- Report
- Tcl Shell
Machine control (in development)
Advanced
- Tools Database
- Preprocessors
- Path Optimization
- Tcl Scripting
- Tcl Command Reference
- Developer Guide
- Translating
Preferences