# paste_stencil.tcl — FlatCAM beta 8.995 # Automates B.Paste Gerber -> G-code for stencil milling # Tool: 0.5mm flat end mill (corn bit) # # Usage (headless): # python flatcam.py --shellfile=paste_stencil.tcl --headless=1 # ─── USER CONFIGURATION ─────────────────────────────────────────────────────── set GERBER "gerbers/myboard-B_Paste.gbp" ;# path to your B.Paste Gerber set OUTPUT "gcode/stencil.nc" ;# output G-code file # Tool set TOOL_DIA 0.5 ;# mm — 0.5mm corn bit # Stencil material depth # Brass shim 0.15mm → use -0.18, polyimide 0.1mm → use -0.13 set CUT_Z -0.2 ;# mm — cutting depth (negative) set TRAVEL_Z 2.0 ;# mm — safe travel height # Feeds & speeds set FEEDRATE 300 ;# mm/min set SPINDLE 24000 ;# RPM # NCC (copper_clear) settings # overlap is in PERCENT (0–100), not fraction — 8.995 change from classic set OVERLAP 60 ;# % — 60% overlap for clean clearing with 0.5mm tool set MARGIN 0.0 ;# mm — 0 = clear exactly to aperture edge # Multidepth — set dpp to 0 to disable (single pass) set DPP 0.0 ;# mm per pass; 0 = single full-depth pass # ─── DERIVED NAMES ──────────────────────────────────────────────────────────── set GBR_NAME "paste_gerber" set NCC_GEO "paste_paint_geo" set CNC_JOB "paste_cnc" # ─── SCRIPT ─────────────────────────────────────────────────────────────────── # 1. Fresh project new # 2. Load B.Paste Gerber open_gerber $GERBER -outname $GBR_NAME # 3. Paint (pocket) each aperture opening # -all processes every polygon in the object # method lines is most reliable for small SMD apertures paint $GBR_NAME \ -tooldia $TOOL_DIA \ -overlap $OVERLAP \ -offset $MARGIN \ -method lines \ -connect 1 \ -contour 1 \ -all \ -outname $NCC_GEO # 4. Generate CNC job # -dpp 0 means single pass (multidepth disabled) # -pp default uses the standard grbl-compatible preprocessor cncjob $NCC_GEO \ -dia $TOOL_DIA \ -z_cut $CUT_Z \ -z_move $TRAVEL_Z \ -feedrate $FEEDRATE \ -spindlespeed $SPINDLE \ -pp GRBL_11 \ -outname $CNC_JOB # 5. Write G-code to file write_gcode $CNC_JOB $OUTPUT puts "Done: $OUTPUT" # Clear project so FlatCAM doesn't prompt to save on exit new quit_app