Bulge G-Code Builder ๐ ๏ธ
A high-performance library for converting geometry defined as Polylines (with Bulge parameters) into CNC-compatible G-Code. Written in Rust and available for WebAssembly.
โ Why Bulge?
In CAD systems like AutoCAD (DXF), arcs are often stored not as centers and radii, but as a Bulge value on a polyline vertex.
- Calculating the center, radius, and start/end angles manually is tedious and error-prone.
- This library handles all the math for you. It converts Bulge-defined segments directly into standard
G02/G03(CW/CCW) circular interpolation commands, saving you hours of geometry implementation.
๐ Installation
For Rust Projects
Add this to your Cargo.toml:
[]
= { = "https://github.com/sagittaracc/bulge-gcode" }
For Web / Node.js (WASM)
Download the latest archive from the Releases page.
import init from './pkg/web/bulge_gcode.js';
๐ป Usage
Rust Example
use ;
WASM / JavaScript Example
// Data format: [x, y, bulge, x, y, bulge, ...]
const data = ;
const places = 3; // Decimal places
const scale = 1.0; // Multiplier (e.g., 1000 for microns)
const gcode = ;
console.log;
๐ Features
- Arc Support: Full support for circular interpolation via Bulge.
- Precision Control: Configurable decimal places and scaling (microns/mm/inches).
- Dialects: Support for both
G0/G1andG00/G01command styles. - Cross-Platform: Works in native Rust, Browser, and Node.js.
๐งช Development
Run tests: cargo test
Build all WASM targets: ./build.sh
๐ References
This project implements geometric algorithms based on the following resources:
- Lee Mac: Bulge Conversion Functions โ A comprehensive guide to working with Bulge geometry in CAD systems.
- DXF Reference - Polyline Bulge โ Official Autodesk documentation on the Bulge parameter.
โ๏ธ License
This project is licensed under either of:
at your option.
Copyright ยฉ 2024-present, Yuriy Arutyunyan