G-code generation algorithms for GRBL diode lasers from different sources; raster Line-to-Line (LaserGRBL-faithful) available today
Project description
PyGrbl_Build 0.1.0
A collection of algorithms to generate G-code for GRBL diode lasers from different sources. Three algorithms today:
- Line-to-Line (
l2l_gcode) — raster engraving from an image, with LaserGRBL fidelity. - SVG vector (
svg_gcode) — vector tracing from an SVG (paths, basic shapes, groups, transforms), a faithful port of LaserGRBL's SVG import. Pure Python, no extra dependency. - Image vector (
img2vector_gcode) — outline tracing from a raster image (LaserGRBL's "Vectorize!"): the image is reduced to black/white, Potrace traces its outlines as closed contours, and each curve is emitted as G2/G3 arcs. Pure Python, Pillow only. Outlines only today (no interior filling yet).
Part of the pygrbl family, a set of libraries to manage GRBL.
Companion to pygrbl_streamer
Speed
This is the whole point. A full 300 mm @ 10 lines/mm raster job — nearly 4.7 million lines of G-code — comes out in ~0.34 s. LaserGRBL can take around 2 minutes to produce the same job: that's roughly a 350× speedup, and byte-for-byte the same output.
Install
pip install pygrbl-build
The only requirements are Pillow and a C compiler. Pillow is the single Python dependency (image loading and resizing); the C compiler is needed at install time because the raster engine ships as a C extension. Nothing else — no numpy, no runtime toolchain.
Usage
Each algorithm pairs a *_gcode generator with its own *Profile
config, so adding one never touches the others.
Raster Line-to-Line (l2l_gcode + L2LProfile):
from pygrbl_build import L2LProfile, l2l_gcode, write_gcode
profile = L2LProfile(width_mm=300.0, lines_per_mm=10.0, feed=3000, s_max=100)
write_gcode(l2l_gcode("shield.png", profile), "shield.nc")
SVG vector (svg_gcode + SvgProfile):
from pygrbl_build import SvgProfile, svg_gcode, write_gcode
profile = SvgProfile(feed=1000, s_max=255)
write_gcode(svg_gcode("logo.svg", profile), "logo.nc")
SvgProfile's defaults reproduce LaserGRBL's own SVG-import defaults, so
the output matches the desktop app for the same drawing. text and
image elements are skipped — convert text to paths in your editor
first.
Image vector (img2vector_gcode + Img2VectorProfile):
from pygrbl_build import Img2VectorProfile, img2vector_gcode, write_gcode
profile = Img2VectorProfile(width_mm=80.0, quality=10.0, feed=1000, s_max=1000)
write_gcode(img2vector_gcode("logo.png", profile), "logo.nc")
img2vector_gcode is a faithful port of LaserGRBL's "Vectorize!": the
image is reduced to black/white (resize, grayscale, white-clip, optional
threshold), Potrace traces its outlines, and each cubic Bezier is
approximated by biarcs and emitted as G2/G3 arcs (with a G1
fallback). width_mm sets the physical width and quality the tracing
resolution in pixels/mm. The Img2VectorProfile defaults follow Potrace's
classic settings (smooth curves, optimization on); set alphamax=0.0 and
opticurve=False to mimic LaserGRBL's own out-of-the-box UI defaults.
write_gcode writes the path verbatim, so you choose the extension
(.nc, .gcode, .g, ...). It's just a convenience: every *_gcode
generator is a lazy iterator of lines, so anything beyond writing a
plain file (compression, network shipping, streaming to the machine) is
the upper layer's job — consume the iterator with whatever sink you need.
Public API: L2LProfile, l2l_gcode, SvgProfile, svg_gcode,
Img2VectorProfile, img2vector_gcode, write_gcode. See the docstrings.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pygrbl_build-0.1.0.tar.gz.
File metadata
- Download URL: pygrbl_build-0.1.0.tar.gz
- Upload date:
- Size: 42.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9e7c17b3343860b0d52e944f63f4abf55f611dce89cab1b2d517d249376afe62
|
|
| MD5 |
0eedb88a5977e3e2cc9b698eda89c09f
|
|
| BLAKE2b-256 |
c7338927c18475ef18fd2be8f492c02c982b0f1acc68371ae48d84e30e816c47
|
File details
Details for the file pygrbl_build-0.1.0-cp313-cp313-win_amd64.whl.
File metadata
- Download URL: pygrbl_build-0.1.0-cp313-cp313-win_amd64.whl
- Upload date:
- Size: 49.6 kB
- Tags: CPython 3.13, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4366d9737f5556819d6ebfb7132abcfe443aa7a558bdcc0d00cfb787038ee2de
|
|
| MD5 |
ba3f94155db9a2e76dfa1026cf4e6a09
|
|
| BLAKE2b-256 |
c327a571f9f700842a98827c73f37a3bed1ba7d962bc797b119a6c492cedeb91
|