Skip to main content
← Projects

Pynest

Pynest is a Python reimplementation of Deepnest-style 2D nesting. It packs polygonal parts onto rectangular or polygonal sheets, with optional rotations, SVG/DXF input, and a Tkinter UI.

Source: github.com/sarweshsoman/Pynest.

What it does

  • Loads parts from SVG (polygons, polylines, paths with arcs) and DXF polylines
  • Greedy placement with candidate sampling: sheet edges, a grid, and neighbors of already-placed parts
  • Rotation variants at 0°, 90°, 180°, 270°
  • Overlap, containment, and distance checks so parts don’t collide
  • Library API, CLI, and a desktop UI for loading files and copying output SVG

Largest parts are placed first. Scoring prefers tight packing from the top-left.

How to run

Python 3.10+.

git clone https://github.com/sarweshsoman/Pynest.git
cd Pynest
python -m venv .venv
source .venv/bin/activate
pip install -e ".[dev]"

python -m ui.tk_app
# or
python -m pynest.cli sheet.svg part1.svg part2.svg

Library usage:

from pynest import load_parts_from_svg, nest, export_svg
from pynest.geometry.types import rect

parts = load_parts_from_svg("parts.svg")
sheet = rect(0, 0, 1000, 600)
result = nest(parts, [sheet])
print(export_svg(result, [sheet]))