The open-source specification, interactive fiber laser simulator, Python library, CLI tool, and AI Agent Skill for Gweike mLaser / NexCut .chf (scFlie) laser cutting and engraving job files.
Launch Interactive Web Simulator - Drop any .chf file in your browser to watch animated laser head motion, verify PWM ON/OFF polarity, estimate cycle time, and catch inverted overscan burns before cutting metal.
Reverse-engineered cleanly to document the scFlie v7-v9 file format, simulate hardware beam firing, convert DXF artwork into ready-to-run .chf jobs (with pre-sliced Layer 6 linear fill engraving and inside-to-outside Layer 0 cuts), validate PWM scan-path modulation, and render SVG previews before you ever touch metal.
Importing a DXF into mLaser normally forces you to select text manually, run Linear Fill, assign layers, and fix cut ordering every single time. Programmatically generating .chf files solves that, except for a nasty trap between mLaser versions:
- In older mLaser Beta (
scFliev7),<Scan path>started directly on letter stroke 1 (t = 0.0= laser ON) with2*M - 2PWM toggles and no initial lead-in. - In newer mLaser SP1 (
scFliev9),<Scan path>starts with a60 mmPWM-0 gray lead-in, emits2*MPWM toggles (even = ON, odd = OFF), ends with a60 mmPWM-0 gray lead-out, and adds<Vision Feature>+ scan-mode'4'.
If a generator emits v7-style 2*M - 2 toggles without the 60 mm PWM-0 lead-in, mLaser looks fine on screen, but the laser fires 100% inverted on the machine - keeping the beam OFF over your text and burning solid horizontal bars across all the gray overscan lines. mlaser-chf implements and validates the exact v9 format so gray overscan lines stay strictly at PWM 0.
# Library + CLI only (pure Python standard library, zero runtime dependencies)
pip install git+https://github.com/TheYieldPoint/mlaser-chf.git
# With DXF -> CHF conversion support (adds ezdxf)
pip install "mlaser-chf[dxf] @ git+https://github.com/TheYieldPoint/mlaser-chf.git"npx skills add https://github.com/TheYieldPoint/mlaser-chfOr copy skills/mlaser-chf into your agent's skills folder (~/.agents/skills/mlaser-chf or .gemini/skills/mlaser-chf).
# Inspect graphs, layers, bounds, and scan-path PWM mode in any .chf
mlaser-chf inspect part.chf
# Simulate hardware execution (verify SAFE vs DANGER overscan burns & export standalone HTML)
mlaser-chf simulate part.chf --controller sp1_v9 -o part_sim.html --open
# Strictly validate scan continuity, total length, 60 mm lead-in/out, and 2*M PWM polarity
mlaser-chf validate part.chf
# Render a dark-theme SVG preview (Cyan = PWM ON, Gray = PWM OFF overscan/turns, Green = Layer 0 Cut)
mlaser-chf preview part.chf -o preview.svg
# Convert a DXF (with CUT + ETCH layers) directly into a ready-to-run scFlie v9 .chf
mlaser-chf dxf2chf coupon.dxf -o coupon.chf --cut-layer CUT --fill-layer ETCH
# Upgrade a legacy scFlie v7 .chf file to safe scFlie v9 PWM framing
mlaser-chf migrate legacy_v7.chf -o modern_v9.chf --version 9from mlaser_chf import (
ChfDocument,
build_circle_contour,
build_linear_fill_scan,
build_polyline_contour,
render_svg,
validate_document,
write_chf_file,
)
# Closed rectangle to linear-fill on Engraving Layer 6
rect_etch = [[(15.0, 45.0), (55.0, 45.0), (55.0, 51.0), (15.0, 51.0)]]
doc = ChfDocument(
version=9,
graphs=[
# 1. Engraving scan FIRST (Layer 6, 0.10 mm hatch, 60 mm PWM-0 overscan)
build_linear_fill_scan(rect_etch, layer=6, line_spacing=0.10, overscan=60.0),
# 2. Inner hole SECOND (Layer 0, flag=2)
build_circle_contour(35.0, 28.0, 5.0, layer=0, contour_flag=2),
# 3. Outer perimeter LAST (Layer 0, flag=1)
build_polyline_contour(
[(10.0, 10.0, 0.0), (60.0, 10.0, 0.0), (60.0, 55.0, 0.0), (10.0, 55.0, 0.0)],
closed=True,
layer=0,
contour_flag=1,
),
],
)
report = validate_document(doc)
assert report.ok, report.errors
write_chf_file(doc, "tag.chf")
with open("tag_preview.svg", "w", encoding="utf-8") as f:
f.write(render_svg(doc))SPEC.md- Full line-by-line specification ofscFliev7-v9, all 5 graph types (8..12), all 7 primitive glyph types (1..7),<Crafts>,<PWM Control>, cubic B-spline turnaround knots, and the v7 vs v9 PWM polarity table.skills/mlaser-chf/SKILL.md- Agent Skill definition for automated DXF/CHF workflows and troubleshooting.examples/sample_tag.py- Standalone example that generates and validates a multi-layer.chf+.svgpreview.
Always inspect new or programmatically generated .chf files in mLaser and run mlaser-chf validate + mlaser-chf preview before firing the laser. Verify that gray overscan/lead-in lines are not marked as laser-ON and check soft-limit travel clearance for the 60 mm left/right scan overscan extensions.
MIT - see LICENSE. Created by The Yield Point.