# Optimize Sequence: Small Holes First

Souce of Documentation: [https://github.com/L0laapk3/inkscape-laser-sequence-extension](https://github.com/L0laapk3/inkscape-laser-sequence-extension)

If you use(d) inkscape to create models for laser cutting, chances are you have ran into the following problem: the laser cutter first cuts the large shape, then it ever so slightly moves, then the holes in that shape are created but with a small offset. Thats why I created this simple extension to deal with this! The extension exists out of a couple lines of code that will re-arrange the order of the vectors for you, so the small holes get cut first.

<p class="callout warning">You might need to combine the desired contours using ctrl + K to build up a long "total path" object.</p>

<p class="callout info">Also have a look at [Line Sorting](https://wiki.stadtfabrikanten.org/books/fablab-chemnitz/page/line-sorting) and [Optimize Sequence: Travel Distances](https://wiki.stadtfabrikanten.org/books/fablab-chemnitz/page/optimize-sequence-travel-distances)</p>

## Example

### Draw some closed contours.

Make some "bad" order (first rectangle in the middle, then a small one, then a large outer one)

[![grafik.png](https://wiki.stadtfabrikanten.org/uploads/images/gallery/2025-05/scaled-1680-/ngjRRoJcF5v7Qk3v-grafik.png)](https://wiki.stadtfabrikanten.org/uploads/images/gallery/2025-05/ngjRRoJcF5v7Qk3v-grafik.png)

### Combine and check

Combine the paths to common contour using ctrl + K. Check the 'd' node of the XML item to see how the path actually looks alike.

[![grafik.png](https://wiki.stadtfabrikanten.org/uploads/images/gallery/2025-05/scaled-1680-/Zk4t4ow3p5eKHN1F-grafik.png)](https://wiki.stadtfabrikanten.org/uploads/images/gallery/2025-05/Zk4t4ow3p5eKHN1F-grafik.png)

```ini
M 7.1105146,29.996967 H 173.07073 V 142.51136 H 7.1105146 Z M 23.630058,57.496723 h 41.639881 v 26.55864 H 23.630058 Z M 21.166666,44.450001 H 137.58332 V 120.65 H 21.166666 Z
```

### Run the extension and check the 'd' node again

```ini
M 7.1105146,29.996967 H 173.07073 V 142.51136 H 7.1105146 Z M 23.630058,57.496723 h 41.639881 v 26.55864 H 23.630058 Z M 21.166666,44.450001 H 137.58332 V 120.65 H 21.166666 Z
```