Skip to content

A fast, dependency-free Python library for extracting bounding boxes from NC files and generating framing G-code.

License

Notifications You must be signed in to change notification settings

offerrall/gcode-bounds

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gcode-bounds

Fast G-code frame bounding box generator and framing G-code generator in pure C, designed for CNC, laser, and 3D printer files. This library is optimized for speed and efficiency, making it ideal for processing large files quickly.

Note: Only X and Y coordinates are considered for bounding boxes, as Z coordinates are not considered in the bounding box calculations.

Features

  • Pure C implementation - 26x faster than Python
  • Zero runtime dependencies - only Python standard library
  • Universal compatibility - handles CNC (.nc), laser (.gcode), 3D printer files
  • Professional grade - processes 500MB+ files in seconds
  • Cross-platform - Windows, macOS, Linux with automatic compilation

Install

git clone https://github.com/offerrall/gcode-bounds
cd gcode-bounds
pip install .

Use

from gcode_bounds import get_bounding_box, generate_framing_gcode

# Get bounding box
bounds = get_bounding_box("part.nc")

# Generate frame
gcode = generate_framing_gcode(*bounds, power=15, speed=1500)

# Save
with open("frame.gcode", "w") as f:
    f.write("\n".join(gcode))

Performance

Implementation 500MB file Lines/sec
gcode-bounds 2.8s 13.4M
Python regex 75s 500K

Compatible

  • CNC files (.nc)
  • Laser files (.gcode)
  • 3D printer files (.gcode)

Requirements

  • Python 3.8+
  • C compiler (auto-detected)

Troubleshooting

Windows: Install Visual Studio Build Tools
Linux: sudo apt install build-essential python3-dev
macOS: xcode-select --install

License

MIT

About

A fast, dependency-free Python library for extracting bounding boxes from NC files and generating framing G-code.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published