Design into 3D: Basics, subroutines, and variables

Starting in on this again, trying to develop some code/concepts which can be used for everything — if this doesn’t work out, I guess I’ll have to bail on OpenSCAD, METAPOST, Toolpath Language, &c., and try FreeCAD.

Start by launching https://www.blockscad3d.com/editor/# and working up some variables (which ultimately will probably be internal):

We’ll begin by modeling a 1-2-3 block

1 Like

Initial modeling in OpenSCAD is quite simple:

next up is drawing this in METAPOST and Toolpath Language (and possibly adjusting the OpenSCAD code with a transform).

METAPOST seems pretty straight-forward:

outputtemplate := "%j-%c.svg";
prologues := 3;
outputformat := "svg";

stockZthickness = 1;
stockXwidth = 2;
stockYdepth = 3;

beginfig(0); 

draw(0,0)--(stockXwidth,0)--(stockXwidth,stockYdepth)--(0,stockYdepth)--cycle;

endfig;

end

which previews well:

One consideration for the METAPOST file is that it doesn’t take endmill diameter into account — I’ve tried doing that in OpenSCAD, and it tends to result in a complex file which is slow to calculate unfortunately.

Ideally one would load the tooling information from somewhere, as opposed to hard-coding it in a file — while the CSV files used by Carbide Create are quite convenient, they are different from the JSON files already being loaded, so will need additional code to load and parse.