Unfortunately, this is not directly possible, though there are a number of tools which examine this space:
- Preview gcode in OpenSCAD - Software / Firmware - V1 Engineering Forum
- OpenSCAD - OpenSCAD carving feature for CNC milling machine
The problem is OpenSCAD does not have the facility for processing text, so can’t directly use G-Code as is, so it will be necessary to have two outputs in parallel:
- G-Code
- OpenSCAD code where each command matches a G-Code command
This will require a tool which exports the two different files, or a tool which converts G-Code into this OpenSCAD format.
The OpenSCAD end will be made up of:
- code for previewing Endmills
- code for making each sort of movement:
- straight-line moves
- arcs