Real-World Projects
Complete, production-ready GScript programs for actual projects. These examples demonstrate practical applications and real workflows.
PCB Isolation Routing
Mill isolation traces on a PCB for prototyping. Perfect for hobbyists and small-batch production.
Project: Single-sided PCB with isolation routing Time: ~25 minutes Difficulty: Intermediate
meta:
part_name: "pcb-arduino-shield"
material: "fr4-copper-clad"
units: mm
origin: {x:0, y:0, z:0}
tooling:
# V-bit for isolation routing
- id: vbit-30deg
type: endmill
diameter: 0.2 # Tip diameter
max_rpm: 18000
# Standard drill bits for holes
- id: drill-0.8mm
type: drill
diameter: 0.8
max_rpm: 12000
- id: drill-1.0mm
type: drill
diameter: 1.0
max_rpm: 12000
# Larger drill for mounting holes
- id: drill-3mm
type: drill
diameter: 3.0
max_rpm: 8000
# Endmill for board outline
- id: endmill-2mm
type: endmill
diameter: 2.0
max_rpm: 15000
setup:
stock: {x:70, y:55, z:1.6} # Standard PCB thickness
safe_height: 2
# Z-zero critical: Set on copper surface!
program:
# Step 1: Isolation routing (traces)
# Note: In production, you'd import trace paths from PCB software
# This example shows the structure for a simple circuit
# Isolation pass 1: Main power traces (wider)
- op: contour
tool: vbit-30deg
depth: 0.15 # Just through copper layer
pass_depth: 0.15
feed: 400
path:
- {x:10, y:10, z:0}
- {x:60, y:10, z:0}
- {x:60, y:45, z:0}
- {x:10, y:45, z:0}
- {x:10, y:10, z:0}
# Isolation pass 2: Signal traces
- op: contour
tool: vbit-30deg
depth: 0.15
pass_depth: 0.15
feed: 400
path:
- {x:15, y:15, z:0}
- {x:55, y:15, z:0}
- {x:55, y:20, z:0}
- {x:15, y:20, z:0}
- op: contour
tool: vbit-30deg
depth: 0.15
pass_depth: 0.15
feed: 400
path:
- {x:15, y:25, z:0}
- {x:55, y:25, z:0}
- {x:55, y:30, z:0}
- {x:15, y:30, z:0}
# Step 2: Drill component holes (0.8mm for IC pins)
- op: drill
tool: drill-0.8mm
depth: 1.7 # Through board + bit extra
feed: 100
peck_depth: 0.6
locations:
- {x:20, y:35, z:0}
- {x:23, y:35, z:0}
- {x:26, y:35, z:0}
- {x:29, y:35, z:0}
- {x:32, y:35, z:0}
- {x:35, y:35, z:0}
- {x:38, y:35, z:0}
- {x:41, y:35, z:0}
# Drill 1.0mm holes for resistors/caps
- op: drill
tool: drill-1.0mm
depth: 1.7
feed: 120
peck_depth: 0.6
locations:
- {x:15, y:40, z:0}
- {x:25, y:40, z:0}
- {x:35, y:40, z:0}
- {x:45, y:40, z:0}
- {x:55, y:40, z:0}
# Step 3: Mounting holes (corners)
- op: drill
tool: drill-3mm
depth: 1.7
feed: 150
locations:
- {x:5, y:5, z:0}
- {x:65, y:5, z:0}
- {x:5, y:50, z:0}
- {x:65, y:50, z:0}
# Step 4: Cut out board outline
- op: contour
tool: endmill-2mm
depth: 1.7 # Cut through completely
pass_depth: 0.6
feed: 300
closed: true
path:
- {x:0, y:0, z:0}
- {x:70, y:0, z:0}
- {x:70, y:55, z:0}
- {x:0, y:55, z:0}
export:
backend: grbl
optimization: O1
post_process: trueTips for PCB Routing:
- Z-Zero is critical - Set on copper surface precisely
- Use peck drilling - FR4 is abrasive, helps chip clearing
- Slow feeds - Copper clad requires slower speeds than aluminum
- Tool selection: V-bits give cleanest isolation
- Double-sided: Requires flipping and alignment holes
- Import from PCB software: Use KiCad, Eagle, etc. to generate paths
Typical Settings:
- Isolation depth: 0.1-0.2mm (just through copper)
- Drill speed: 8,000-12,000 RPM
- Feed rate: 300-500 mm/min for isolation
- Tool: 20-30° V-bit, 0.1-0.2mm tip
Custom Electronics Enclosure
Machine a two-piece snap-fit enclosure for electronics projects.
Project: Raspberry Pi enclosure with mounting posts and ventilation Time: ~45 minutes per half Difficulty: Advanced
meta:
part_name: "rpi-enclosure-bottom"
material: "abs-plastic"
units: mm
origin: {x:0, y:0, z:0}
tooling:
# Roughing tool
- id: roughing-6mm
type: endmill
diameter: 6.0
max_rpm: 12000
flutes: 2
# Finishing tool
- id: finishing-3mm
type: endmill
diameter: 3.0
max_rpm: 15000
flutes: 2
# Small detail tool
- id: detail-1.5mm
type: endmill
diameter: 1.5
max_rpm: 18000
flutes: 2
# Drills for mounting and ventilation
- id: drill-2.5mm
type: drill
diameter: 2.5
max_rpm: 10000
- id: drill-4mm
type: drill
diameter: 4.0
max_rpm: 8000
setup:
stock: {x:100, y:75, z:20}
safe_height: 8
program:
# Step 1: Face top surface
- op: face
tool: roughing-6mm
depth: 0.5
pass_depth: 0.5
feed: 1000
bounds: rect(0, 0, 100, 75)
# Step 2: Rough main cavity
- op: pocket
tool: roughing-6mm
bounds: rect(3, 3, 94, 69) # 3mm walls
depth: 12.0
pass_depth: 3.0
feed: 800
strategy: spiral
stepover: 0.6
# Step 3: Finish cavity walls
- op: contour
tool: finishing-3mm
depth: 12.0
pass_depth: 2.0
feed: 600
closed: true
path:
- {x:3, y:3, z:0}
- {x:97, y:3, z:0}
- {x:97, y:72, z:0}
- {x:3, y:72, z:0}
# Step 4: Create mounting post pockets (for heat-set inserts)
# Bottom-left post
- op: pocket
tool: detail-1.5mm
bounds: rect(8, 8, 6, 6)
depth: 8.0
pass_depth: 1.5
feed: 500
strategy: spiral
# Bottom-right post
- op: pocket
tool: detail-1.5mm
bounds: rect(86, 8, 6, 6)
depth: 8.0
pass_depth: 1.5
feed: 500
strategy: spiral
# Top-left post
- op: pocket
tool: detail-1.5mm
bounds: rect(8, 61, 6, 6)
depth: 8.0
pass_depth: 1.5
feed: 500
strategy: spiral
# Top-right post
- op: pocket
tool: detail-1.5mm
bounds: rect(86, 61, 6, 6)
depth: 8.0
pass_depth: 1.5
feed: 500
strategy: spiral
# Step 5: Drill center holes for heat-set inserts (M2.5)
- op: drill
tool: drill-2.5mm
depth: 10.0
feed: 200
peck_depth: 2.5
locations:
- {x:11, y:11, z:0}
- {x:89, y:11, z:0}
- {x:11, y:64, z:0}
- {x:89, y:64, z:0}
# Step 6: Ventilation holes (pattern)
- op: drill
tool: drill-4mm
depth: 13.0 # Through bottom
feed: 250
locations:
# Row 1
- {x:15, y:30, z:0}
- {x:25, y:30, z:0}
- {x:35, y:30, z:0}
- {x:45, y:30, z:0}
- {x:55, y:30, z:0}
- {x:65, y:30, z:0}
- {x:75, y:30, z:0}
- {x:85, y:30, z:0}
# Row 2
- {x:15, y:40, z:0}
- {x:25, y:40, z:0}
- {x:35, y:40, z:0}
- {x:45, y:40, z:0}
- {x:55, y:40, z:0}
- {x:65, y:40, z:0}
- {x:75, y:40, z:0}
- {x:85, y:40, z:0}
# Row 3
- {x:15, y:50, z:0}
- {x:25, y:50, z:0}
- {x:35, y:50, z:0}
- {x:45, y:50, z:0}
- {x:55, y:50, z:0}
- {x:65, y:50, z:0}
- {x:75, y:50, z:0}
- {x:85, y:50, z:0}
# Step 7: Create snap-fit ledge (for top half)
- op: contour
tool: finishing-3mm
depth: 2.0
pass_depth: 1.0
feed: 600
closed: true
path:
- {x:5, y:5, z:0}
- {x:95, y:5, z:0}
- {x:95, y:70, z:0}
- {x:5, y:70, z:0}
export:
backend: grbl
optimization: O1
post_process: trueEnclosure Features:
- 3mm wall thickness for strength
- Mounting posts for PCB with heat-set inserts (M2.5)
- Ventilation holes for cooling
- Snap-fit ledge for top half
- Fits Raspberry Pi 4 (85mm x 56mm)
Material Notes (ABS Plastic):
- Lower speeds than aluminum (avoid melting)
- Sharp tools essential
- Chip evacuation important
- Can also use: Acrylic, PETG, Nylon, Delrin
For the top half: Create similar program with:
- Shallow pocket (5mm deep)
- Matching snap-fit tabs
- Optional display cutout
- Access holes for ports
Laser-Engraved Wood Sign
Create a raised-letter wooden sign with engraved background.
Project: Hanging house number sign Time: ~35 minutes Difficulty: Intermediate
meta:
part_name: "house-number-sign-123"
material: "hardwood-maple"
units: mm
origin: {x:0, y:0, z:0}
tooling:
# V-bit for engraving
- id: vbit-60deg
type: endmill
diameter: 1.0 # Tip diameter
max_rpm: 15000
# Flat endmill for clearing
- id: endmill-3mm
type: endmill
diameter: 3.0
max_rpm: 18000
flutes: 2
# Drill for hanging holes
- id: drill-5mm
type: drill
diameter: 5.0
max_rpm: 8000
setup:
stock: {x:300, y:120, z:18}
safe_height: 8
program:
# Step 1: Face surface for clean finish
- op: face
tool: endmill-3mm
depth: 0.5
pass_depth: 0.5
feed: 1200
bounds: rect(0, 0, 300, 120)
stepover: 0.6
# Step 2: Pocket around numbers (leaving numbers raised)
# This is the "background" - everything except the numbers
# Left side pocket
- op: pocket
tool: endmill-3mm
bounds: rect(10, 10, 50, 100)
depth: 3.0
pass_depth: 1.0
feed: 900
strategy: climb
# Between "1" and "2"
- op: pocket
tool: endmill-3mm
bounds: rect(90, 10, 30, 100)
depth: 3.0
pass_depth: 1.0
feed: 900
strategy: climb
# Between "2" and "3"
- op: pocket
tool: endmill-3mm
bounds: rect(150, 10, 30, 100)
depth: 3.0
pass_depth: 1.0
feed: 900
strategy: climb
# Right side pocket
- op: pocket
tool: endmill-3mm
bounds: rect(210, 10, 80, 100)
depth: 3.0
pass_depth: 1.0
feed: 900
strategy: climb
# Top pocket
- op: pocket
tool: endmill-3mm
bounds: rect(60, 10, 150, 25)
depth: 3.0
pass_depth: 1.0
feed: 900
strategy: climb
# Bottom pocket
- op: pocket
tool: endmill-3mm
bounds: rect(60, 85, 150, 25)
depth: 3.0
pass_depth: 1.0
feed: 900
strategy: climb
# Step 3: V-carve decorative border
- op: contour
tool: vbit-60deg
depth: 2.0
pass_depth: 1.0
feed: 600
closed: true
path:
- {x:5, y:5, z:0}
- {x:295, y:5, z:0}
- {x:295, y:115, z:0}
- {x:5, y:115, z:0}
- op: contour
tool: vbit-60deg
depth: 2.0
pass_depth: 1.0
feed: 600
closed: true
path:
- {x:8, y:8, z:0}
- {x:292, y:8, z:0}
- {x:292, y:112, z:0}
- {x:8, y:112, z:0}
# Step 4: Drill hanging holes
- op: drill
tool: drill-5mm
depth: 16.0 # Most of the way through
feed: 250
peck_depth: 4.0
locations:
- {x:30, y:60, z:0} # Left hole
- {x:270, y:60, z:0} # Right hole
# Step 5: (Optional) Create keyhole hangers
# Mill slots from drill holes
- op: contour
tool: endmill-3mm
depth: 16.0
pass_depth: 4.0
feed: 400
path:
- {x:30, y:60, z:0}
- {x:30, y:50, z:0}
- op: contour
tool: endmill-3mm
depth: 16.0
pass_depth: 4.0
feed: 400
path:
- {x:270, y:60, z:0}
- {x:270, y:50, z:0}
export:
backend: grbl
optimization: O1
post_process: trueSign-Making Notes:
- Raised letters: Background is pocketed, letters stay at original height
- V-carving: Creates crisp, clean lines
- Wood choice: Hardwoods (maple, oak, walnut) machine better
- Finishing: Sand, stain/paint letters, seal with polyurethane
- Alternative: Instead of pockets, use V-bit to trace letter outlines
Typical Process:
- Generate letter paths from design software (Inkscape, Illustrator)
- Convert to GScript contour operations
- Create raised effect with background pocket
- V-carve decorative elements
- Finish with sandpaper, stain, seal
Tips:
- Use sharp tools (wood dulls cutters)
- Lower feed for hardwoods
- Climb milling prevents tearout
- Shallow passes (1-2mm) for clean edges
CNC Fixture Plate with T-Slots
Professional-grade fixture plate for work holding.
Project: Modular fixture plate with T-slot grid Time: ~90 minutes Difficulty: Advanced
meta:
part_name: "fixture-plate-200x200-tslot"
material: "aluminum-6061-t6"
units: mm
origin: {x:0, y:0, z:0}
# Machinist notes:
# - Face both sides for flatness
# - Check square before starting
# - Verify T-slot cutter depth
tooling:
# Face mill for large surfaces
- id: face-mill-20mm
type: face_mill
diameter: 20.0
max_rpm: 6000
flutes: 4
# Endmill for slots
- id: endmill-12mm
type: endmill
diameter: 12.0
max_rpm: 8000
flutes: 3
# T-slot cutter (12mm shank, 16mm head)
- id: tslot-cutter
type: endmill
diameter: 16.0
max_rpm: 4000
flutes: 2
# Drill for mounting holes
- id: drill-10mm
type: drill
diameter: 10.0
max_rpm: 3000
# Tap drill for M8 threads
- id: drill-6.8mm
type: drill
diameter: 6.8
max_rpm: 3000
setup:
stock: {x:210, y:210, z:25}
safe_height: 10
program:
# Step 1: Face top surface
- op: face
tool: face-mill-20mm
depth: 1.0
pass_depth: 0.5
feed: 800
bounds: rect(0, 0, 200, 200)
stepover: 0.8
# Step 2: Mill slots for T-tracks
# Horizontal slots (5 rows, 40mm apart)
- op: contour
tool: endmill-12mm
depth: 12.0
pass_depth: 3.0
feed: 600
path:
- {x:10, y:40, z:0}
- {x:190, y:40, z:0}
- op: contour
tool: endmill-12mm
depth: 12.0
pass_depth: 3.0
feed: 600
path:
- {x:10, y:80, z:0}
- {x:190, y:80, z:0}
- op: contour
tool: endmill-12mm
depth: 12.0
pass_depth: 3.0
feed: 600
path:
- {x:10, y:120, z:0}
- {x:190, y:120, z:0}
- op: contour
tool: endmill-12mm
depth: 12.0
pass_depth: 3.0
feed: 600
path:
- {x:10, y:160, z:0}
- {x:190, y:160, z:0}
# Vertical slots (5 columns, 40mm apart)
- op: contour
tool: endmill-12mm
depth: 12.0
pass_depth: 3.0
feed: 600
path:
- {x:40, y:10, z:0}
- {x:40, y:190, z:0}
- op: contour
tool: endmill-12mm
depth: 12.0
pass_depth: 3.0
feed: 600
path:
- {x:80, y:10, z:0}
- {x:80, y:190, z:0}
- op: contour
tool: endmill-12mm
depth: 12.0
pass_depth: 3.0
feed: 600
path:
- {x:120, y:10, z:0}
- {x:120, y:190, z:0}
- op: contour
tool: endmill-12mm
depth: 12.0
pass_depth: 3.0
feed: 600
path:
- {x:160, y:10, z:0}
- {x:160, y:190, z:0}
# Step 3: Create T-slot undercuts
# Note: T-slot cutter creates the "T" profile
# Run at depth of slot bottom (12mm)
# Horizontal T-slots
- op: contour
tool: tslot-cutter
depth: 12.0
pass_depth: 12.0
feed: 200 # Slow for T-slot cutter
path:
- {x:10, y:40, z:0}
- {x:190, y:40, z:0}
- op: contour
tool: tslot-cutter
depth: 12.0
pass_depth: 12.0
feed: 200
path:
- {x:10, y:80, z:0}
- {x:190, y:80, z:0}
- op: contour
tool: tslot-cutter
depth: 12.0
pass_depth: 12.0
feed: 200
path:
- {x:10, y:120, z:0}
- {x:190, y:120, z:0}
- op: contour
tool: tslot-cutter
depth: 12.0
pass_depth: 12.0
feed: 200
path:
- {x:10, y:160, z:0}
- {x:190, y:160, z:0}
# Vertical T-slots
- op: contour
tool: tslot-cutter
depth: 12.0
pass_depth: 12.0
feed: 200
path:
- {x:40, y:10, z:0}
- {x:40, y:190, z:0}
- op: contour
tool: tslot-cutter
depth: 12.0
pass_depth: 12.0
feed: 200
path:
- {x:80, y:10, z:0}
- {x:80, y:190, z:0}
- op: contour
tool: tslot-cutter
depth: 12.0
pass_depth: 12.0
feed: 200
path:
- {x:120, y:10, z:0}
- {x:120, y:190, z:0}
- op: contour
tool: tslot-cutter
depth: 12.0
pass_depth: 12.0
feed: 200
path:
- {x:160, y:10, z:0}
- {x:160, y:190, z:0}
# Step 4: Drill corner mounting holes
- op: drill
tool: drill-10mm
depth: 22.0 # Through-holes
feed: 150
peck_depth: 5.0
locations:
- {x:10, y:10, z:0}
- {x:190, y:10, z:0}
- {x:10, y:190, z:0}
- {x:190, y:190, z:0}
# Step 5: Drill/tap grid holes for clamping
# These holes get tapped M8 after machining
- op: drill
tool: drill-6.8mm
depth: 18.0
feed: 120
peck_depth: 4.0
locations:
# Center grid (9 holes, 40mm spacing)
- {x:60, y:60, z:0}
- {x:100, y:60, z:0}
- {x:140, y:60, z:0}
- {x:60, y:100, z:0}
- {x:100, y:100, z:0}
- {x:140, y:100, z:0}
- {x:60, y:140, z:0}
- {x:100, y:140, z:0}
- {x:140, y:140, z:0}
export:
backend: linuxcnc # Industrial machine
optimization: O1
post_process: trueFixture Plate Features:
- 200mm x 200mm working area
- T-slot grid (40mm spacing)
- M8 threaded holes for clamps
- Precision-faced for flatness
- Modular work holding system
Post-Machining:
- Tap all holes to M8 x 1.25
- Deburr all edges
- Optional: Anodize for corrosion protection
- Check flatness with precision straightedge
Usage:
- Accepts standard T-nuts and clamps
- Modular setups for different parts
- Repeatable positioning
- Professional work holding
Comparing G-code Output
See the difference GScript makes. Here's the simple-drill example:
GScript (10 lines)
meta:
part_name: "drill-pattern"
tooling:
- id: drill1
diameter: 5.0
setup:
stock: {x:50, y:50, z:10}
program:
- op: drill
tool: drill1
locations:
- {x:10, y:10}
- {x:40, y:10}
- {x:10, y:40}
- {x:40, y:40}
depth: 5
feed: 300Generated G-code (40+ lines)
; Part: drill-pattern
; Generated by GScript
G21 G90 G17
M6 T1
S5000 M3
G0 Z5.0
G0 X10 Y10
G1 Z-5.0 F300
G0 Z5.0
G0 X40 Y10
G1 Z-5.0 F300
G0 Z5.0
G0 X10 Y40
G1 Z-5.0 F300
G0 Z5.0
G0 X40 Y40
G1 Z-5.0 F300
G0 Z5.0
M5
G0 Z5.0
M3090% less code, infinitely more readable, and generates perfect G-code.
Tips for Real Projects
Project Planning
- Sketch first - Draw your part, mark dimensions
- Break into operations - Face, rough, finish, drill, cutout
- Tool selection - Choose appropriate sizes and types
- Material prep - Square stock, establish zero points
- Test programs - Run simulation first
Common Workflows
Pattern 1: Enclosures
- Face → Rough pocket → Finish walls → Drill holes → Cutout
Pattern 2: Plates
- Face → Pockets/features → Drill mounting holes
Pattern 3: Signs
- Face → Background pocket → Detail V-carve → Drill hangers
Pattern 4: PCBs
- Isolation routing → Drill holes → Board outline
Production Checklist
- [ ] Stock properly squared and clamped
- [ ] Zero points established (X, Y, Z)
- [ ] Tools loaded in correct positions
- [ ] Feeds and speeds appropriate for material
- [ ] Program simulated and validated
- [ ] Safety check (soft limits, estop)
- [ ] First-article inspection after first run
Download & Try
All examples available in the repository:
cd gscript-core/examples
# Compile any example
gscriptc compile <example>.gscript --target grbl -o output.gcodeShare Your Projects!
Built something cool with GScript?
- Share in GitHub Discussions
- Submit examples via pull request
- Tag #gscript on social media
Next Steps
- Basic Examples - Start here if these are complex
- Advanced Examples - More programming patterns
- CLI Commands - Master the toolchain
- Language Reference - Complete syntax guide