discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

Library for modeling subtractively like to G-code (and making G-code for CAM on CNC routers)

WF
William F. Adams
Mon, Oct 31, 2022 12:33 AM

Been working on this for a while now.

Still (and probably always will be) clunky, but I think it's at a point where it might be useful to other folks.

On GitHub:

https://github.com/WillAdams/gcodepreview

and I've been writing about it a bit at:

https://forum.makerforums.info/

Basically you work up a file:

include <C:/Users/willa/OneDrive/Documents/RapCAD/Libraries/gcodepreview.scad>

stocklength = 125;

stockwidth = 75;

stockthickness = 6.35;

toolradius = 1.5875;

zeroheight = "Bottom"; // [Top, Bottom]

stockorigin = "Center"; // [Lower-Left, Center-Left, Top-Left, Center]

generategcode = false;

retractheight = 3;

feedrate = 850;

plungerate = 425;

//add stockthickness if zeroheight = Bottom

safetyheight = retractheight; // + stockthickness;

difference() {

setupcut(stocklength, stockwidth, stockthickness, zeroheight, stockorigin);

toolchange(102);

startspindle (17000);

writecomment("PREPOSITION FOR RAPID PLUNGE");

rapid(0,0,safetyheight * 2,0,0,safetyheight);

plungegcutretract(0, 0, 0, 0, 0, -stockthickness, 102, retractheight, plungerate, feedrate);

}

closecut();

which previews as expected (see images on the forum link)

Once a design is done it can be transferred into RapCAD, or just processed in that on the command line:

C:\Progra~1\RapCAD\rapcad.exe  gcode.rcad -o null -r rcadgcode.nc

to get a G-code file:

(STOCK/BLOCK,  125 ,  75 ,  6.35 ,  62.5 ,  37.5 , 0.00)
G90
G21
(Move to safe Z to avoid workholding)
G53G0Z-5.000
M05
(TOOL/MILL,3.17, 0.00, 0.00, 0.00)
M6T102
M03S17000
( PREPOSITION FOR RAPID PLUNGE )
G0 X 0  Y 0 Z 3
G0 X 0  Y 0 Z 3
G1 X 0  Y 0 Z 0 F 425
G1 X 0  Y 0 Z -6.35 F 850
G0 X 0  Y 0 Z 3
M02

which will make the specified cuts on a CNC machine.

Next up is doing some interesting joinery which actually justifies all this.

At some point I'd like to get this into OpenSCAD Graph Editor or some similar tool, ideally w/ support for the Customizer.

If someone doing one of the other interact/node/graph interfaces could make use of it, I'd be gratified and interested.

William

Been working on this for a while now. Still (and probably always will be) clunky, but I think it's at a point where it might be useful to other folks. On GitHub: https://github.com/WillAdams/gcodepreview and I've been writing about it a bit at: https://forum.makerforums.info/ Basically you work up a file: include <C:/Users/willa/OneDrive/Documents/RapCAD/Libraries/gcodepreview.scad> stocklength = 125; stockwidth = 75; stockthickness = 6.35; toolradius = 1.5875; zeroheight = "Bottom"; // [Top, Bottom] stockorigin = "Center"; // [Lower-Left, Center-Left, Top-Left, Center] generategcode = false; retractheight = 3; feedrate = 850; plungerate = 425; //add stockthickness if zeroheight = Bottom safetyheight = retractheight; // + stockthickness; difference() { setupcut(stocklength, stockwidth, stockthickness, zeroheight, stockorigin); toolchange(102); startspindle (17000); writecomment("PREPOSITION FOR RAPID PLUNGE"); rapid(0,0,safetyheight * 2,0,0,safetyheight); plungegcutretract(0, 0, 0, 0, 0, -stockthickness, 102, retractheight, plungerate, feedrate); } closecut(); which previews as expected (see images on the forum link) Once a design is done it can be transferred into RapCAD, or just processed in that on the command line: C:\Progra~1\RapCAD\rapcad.exe  gcode.rcad -o null -r rcadgcode.nc to get a G-code file: (STOCK/BLOCK,  125 ,  75 ,  6.35 ,  62.5 ,  37.5 , 0.00) G90 G21 (Move to safe Z to avoid workholding) G53G0Z-5.000 M05 (TOOL/MILL,3.17, 0.00, 0.00, 0.00) M6T102 M03S17000 ( PREPOSITION FOR RAPID PLUNGE ) G0 X 0  Y 0 Z 3 G0 X 0  Y 0 Z 3 G1 X 0  Y 0 Z 0 F 425 G1 X 0  Y 0 Z -6.35 F 850 G0 X 0  Y 0 Z 3 M02 which will make the specified cuts on a CNC machine. Next up is doing some interesting joinery which actually justifies all this. At some point I'd like to get this into OpenSCAD Graph Editor or some similar tool, ideally w/ support for the Customizer. If someone doing one of the other interact/node/graph interfaces could make use of it, I'd be gratified and interested. William