For a while now, I’ve been working on using METAPOST for a fancy box project, but in the course of that, I realized that I could pretty easily take any file, set it to view in cm, and then copy the coordinates out of it and multiply them times an input value in mm and get a file which could be rendered at any desired size:

Anyway, you’d install TeX, save the above in a file (or a pair of files — one would be parameters.txt and have the single line which declares the desired jaw size for the wrench), typeset it using lualatex (which include the library version of METAPOST mplib), and one would then get a .pdf suitable for importing into any vector drawing program (verifying the size) and then saving to an SVG and importing to Carbide Create and doing CAM — apparently I should get out more, it seems as if METAPOST will directly create an SVG — will have to investigate that.

Or of course, one could just calculate the scaling factor to apply to a pre-drawn SVG:

(This definitely would’ve been way cooler if I had the math chops to calculate the hexagons, rounded corners, &c. — some time over a beer ask me about the fabulous school I attended for 3rd and 4th grade which my father pulled me out of, and ultimately the Mississippi State Supreme Court adjudged illegal since it granted exceptional advantages to intelligent and disciplined children, while magnifying the inadequacies of other students or some such)

(I got the dimensions by converting the SVG to PostScript and knocking together a quick Perl script to extract the moveto/lineto/curveto commands and convert from PS points to MM, then adding the big half-circle; the rest of the curves are left as an exercise for the reader…)

Yeah, lack of Bezier creation or import is a serious limitation in OpenSCAD. The best workaround I’ve found for importing complex curves is to design them in Inkscape, convert the SVG into a font using FontForge, then render it at any scale with:

use <mycurves.ttf>;
text(text="A", size=100, font = "mycurves");

FontForge is scriptable, so you don’t even have to learn its GUI; I automated the process with a little Python script.

(all of which kind of circles back to where METAPOST originally came from…)

In practice, the error isn’t necessarily a big deal. I used the Inkscape->font->OpenSCAD trick to render this pipe rest, and it came out pretty smooth, with any minor triangulation pretty much covered by the 10% stepover on the ballnose bit:

Hmm, I got it running on my Mac just now without any trouble, and then remembered why I’d deleted it last time and used OpenSCAD instead: not enough functionality. The internal modeling precision and actual variable-handling are appealing, but the language is missing a lot of what makes OpenSCAD useful.

Now, if they added SVG import and extended the pack() function to include rotation, then it would be an easy way to fit multiple objects onto a sheet for optimized cutting…

Well, since METAPOST can directly output an SVG, I’m going to do some hopefully serious work with it here in the near future — asked on the other forum if it’d be okay to put my notes on a page on the wiki: