How to Convert Splines to Polylines in AutoCAD for CNC (AutoLISP Tutorial)
Program Description
S2P (SplineToPoly) is a focused AutoLISP utility built for one job: converting Spline entities into high-precision LWPolylines that downstream systems can actually use.
In design, Splines are flexible and clean. In manufacturing, they are a liability. Most CNC software, laser cutters, and older CAM systems either reject splines or interpret them poorly. That’s where this tool fits.
The routine converts splines using a controlled geometric tolerance, producing vertex-based polylines suitable for G-code generation, DXF export, and reliable machining.
From a shop perspective, this removes one of the most common failure points between CAD and CAM.
Download the script here.
Full AutoLISP Program (SplineToPoly.lsp)
(defun c:S2P ( / ss i ent obj tol oldcmdecho doc)
(vl-load-com)
(setq doc (vla-get-ActiveDocument (vlax-get-acad-object)))
;; Ask for tolerance or use default
(setq tol (getreal "\nEnter precision tolerance <0.001>: "))
(if (not tol) (setq tol 0.001))
(setq oldcmdecho (getvar "CMDECHO"))
(setvar "CMDECHO" 0)
(princ "\nSelect SPLINE objects to convert: ")
(setq ss (ssget '((0 . "SPLINE"))))
(if ss
(progn
(vla-StartUndoMark doc) ;; Start Undo Group
(setq i 0)
(repeat (sslength ss)
(setq ent (ssname ss i))
(setq obj (vlax-ename->vla-object ent))
(vl-catch-all-apply '(lambda () (vla-ConvertToPolyline obj tol)))
(setq i (1+ i))
)
(vla-EndUndoMark doc) ;; End Undo Group
(princ (strcat "\nConverted " (itoa (sslength ss)) " spline(s) successfully."))
)
(princ "\nNo splines selected.")
)
(setvar "CMDECHO" oldcmdecho)
(princ)
)
Step-by-Step Guide
Load the Script
Drag and drop SplineToPoly.lsp into AutoCAD, or run APPLOAD and load it manually. For regular use, add it to the Startup Suite.
Set Your Coordinate System (Critical)
Before running the command, ensure your UCS is set to World (WCS). Run:
UCS → World
This avoids conversion errors or unexpected geometry shifts during vla-ConvertToPolyline.
Initialize the Command
Type S2P and press Enter.
Define Precision
You’ll be prompted to enter a tolerance value:
- Press Enter → uses default 0.001
- Enter a value → overrides precision for this run
Select Objects
Select only Splines. The filter prevents accidental selection of other entities.
Confirm Conversion
Press Enter. The script converts all selected splines into polylines.
Because of the Undo grouping, the entire operation can be reverted with a single CTRL+Z.
Verify Results
Check output quickly:
- LIST → confirm entity type = LWPOLYLINE
- PEDIT → inspect vertices if needed
Export to DXF/DWG for your CAM workflow.
Why Geometric Tolerance Matters for CNC
Tolerance controls how accurately the spline is approximated.
This routine uses chordal deviation, which balances curve accuracy and vertex count.
What this affects in real terms:
- Too high tolerance (e.g. 0.01) → fewer points, faster processing, but visible faceting
- Too low tolerance (e.g. 0.0001) → smooth curves, but heavy files and slower machines
- Balanced tolerance (0.001) → typical CNC use case
Impact on production:
- Stable feed rate (no controller hesitation)
- Reduced file size
- Better surface finish
- No invalid entity errors in legacy CAM
Autodesk spline reference: https://help.autodesk.com/view/ACD/2024/ENU/?guid=GUID-0C2E8222-62A4-4E7F-B7E1-6D9B7F8C6A6D
Practical Tolerance Settings
Use case-driven values:
- 0.01 → rough cutting, signage, large parts
- 0.001 → standard CNC workflows
- 0.0001 → molds, precision machining
Shop rule: If your machine pauses during curves, your polyline is too dense.
Workflow Integration (Production Setup)
Typical pipeline:
- Design using Splines in AutoCAD
- Run S2P conversion
- Clean geometry:
- OVERKILL
- PEDIT JOIN
- Export as DXF (R12 if required)
- Import into CAM (Fusion 360, Mastercam, SheetCAM)
Fusion 360 reference: https://www.autodesk.com/products/fusion-360
Technical Highlights
- Command: S2P
- Compatibility: AutoCAD 2000 → latest
- Precision Input: User-defined at runtime
- Undo Support: Single-step rollback
- Entity Handling: In-place replacement
- Layer Integrity: Preserved
SEO Keywords: AutoCAD Spline to Polyline, LISP for CNC, DXF Spline Conversion, CAD CAM Geometry Optimization, AutoCAD to G-Code preparation
What This Tool Fixes
- CAM import failures due to Spline entities
- CNC slowdowns from excessive vertices
- Broken toolpaths
- Inconsistent curve machining
This is a standard prep step before exporting any file to production.
FAQ
Why not use SPLINEDIT?
It works, but it’s manual and inconsistent for batch jobs. S2P gives repeatable results with controlled tolerance.
Can I undo everything at once?
Yes. The routine uses an Undo group, so one CTRL+Z reverts the full operation.
Do I need to edit the LISP file to change tolerance?
No. The program prompts you at runtime.
Does it preserve layers?
Yes. All layer and object properties are retained.
Can I process multiple splines at once?
Yes. Select as many as needed.
Why do I get shifted geometry?
Most cases come from working outside WCS. Reset UCS to World before running.
Why are my curves faceted?
Tolerance is too high. Lower it.
Why is my file too heavy?
Tolerance is too low. Increase it slightly.
Does it support 3D splines?
No. For CNC workflows, assume 2D planar geometry only.
Is this compatible with DXF for CNC?
Yes. Works reliably with DXF R12, which many controllers still require.
Conclusion
If you’re sending geometry to a machine, Spline conversion is not optional. Clean polylines are the baseline for stable toolpaths and predictable results.
S2P handles that step quickly, with control over precision and proper undo behavior.
If you’re building a serious AutoCAD-to-CNC workflow, this should sit alongside other utilities: layer cleanup, arc fitting, DXF optimization, and toolpath validation.

