CNC Box (Finger) Joint Box


I was able to produce the JSON file for the design above however, there was a message on the console that said:

UI-ERROR: Current top level object is not a 2D object.

Is this something to ignore?

Your instruction then say to run a LuaLaTeX file. Not sure how you do that. I went to the LuaLaTeX website and see that I can download some code. Can you elaborate?

The rest looks pretty clear… so far.

1 Like

Since we’re not using the STL, it’s not a big deal, but it is something I’ll want to fix.

I haven’t posted the lualatex file — it’s kind of a mess, and I’m hoping to refactor the code — if you’ll send me the JSON file once you’ve saved your design as a preset, I’ll run it and make a PDF of the box you’ve designed and post it to this thread if that’s okay.

Thinking on it a bit, some aspects of the lids need to be revisited — probably need to make a fixture / jig to allow drilling holes for hinges where necessary.

No problem, I’ll wait till you’re ready to post. I wanted to see if the process worked and I was just thinking that I was missing something.

Another consideration is I may try a totally different tool — one thing I’ve considered is a LiveCode or Python front-end which would allow better calculation of the settings, and which could then generate the appropriate .c2d file — if OpenSCAD were Applescriptable, I’d probably use that on the Mac side of the house and then port that to LiveCode for the PC implementation.

I really don’t understand why it’s so difficult to program things on modern systems. Really wish that it were as easy as on Oberon, or even on NeXTstep when one could use Display PostScript for this sort of thing.


I figured if I am going to participate in the Kickstarter, I might as well get my toes wet in OpenSCAD, so I went and downloaded it (for Windows10, that complained about a “dangerously unknown” exe file…sigh)

Side note: the defaut proposed version to download is 2015.03, which did not sound like a good sign. Indeed it does not have the Customizer. So I downloaded the latest experimental version, 2019.01-RC4. What happened during March 2015 an Jan 2019 ?.. no releases during 4 years ?

I opened the fingerjoint box, and love the interactive view (what’s more geeky than doing 3D modeling in code ! :slight_smile: )

But I then I tried saving the JSON file after creating a preset ("+" button), when I click “save preset”…nothing happens (at all, no log, no window, nothing). No json file saved anywhere that I could find.

Any idea what I missed ? which version of OpenSCAD are you using so that I try the exact same ?

That’s great! I’m going to be working on some documentation for this over the weekend. OpenSCAD seems to be in on-going development — I think there’s been some discussion of why no release recently in the discussion list/forum, but I haven’t tracked that.

I used a development snapshot:

and downloaded the 64-bit version with an installer:

The JSON file should be saved in the same directory that the .scad file cncboxfingerjoint.scad is in.

1 Like

allright, my bad, the JSON file actually was generated, I had downloaded the .scad file into an obscure subdirectory, and searched for the wrong name. So all is good, thanks.

I’m game for trying to install the Lua/Tex/METAPOST thingy if you need a beta tester.

1 Like

Okay, thanks! I’ll put those files up this evening in the course of documenting things — in the meanwhile, download and install MikTeX:

Probably the best way to do that is the all-in-one installer from

Here’s the .tex file — unzip and place it and the JSON.lua file (code for importing .json files into Lua) in the same directory as the .scad and .json file, the typeset it — that will make a .pdf which you can import into the drawing tool of your choice (I use Inkscape) and then resave as an SVG. (20.9 KB)

I’m just stepping in here, but my understanding (followed up by a cursory reading of the .tex file) is that the output (in this case, a PDF) is generated by the .tex file solely from the parameters in the JSON data, correct? I should be able to write myself a bit of python to load the JSON data and generate an SVG directly, which could also avail itself to being a direct Inkscape import extension (since Inkscape import extensions in python are nothing more complicated than python scripts that take a filename and optional parameters as input, “do stuff”, and output an SVG to stdout).

I’d like to play around a bit, but since I’m currently just starting up the Zbrush+drawing tablet learning curve for a potentially personally pivotal project, I don’t really want to start installing OpenSCAD, MikTeX, et al (as that would certainly end up in an extended digression… sounds like way too much fun). Might I be able to get a zip of an example JSON file and corresponding generated PDF so I can skip the main parts and play around with some python processing?

1 Like

@ClayJar: this was on the tip of my tongue, but I self-censored myself to not commit to yet another rabbit hole :slight_smile: Very cool if you step in on this one, let’s see what Will thinks.

So I installed MikTex, unpacked the lua & tex files, launched “TeXworks” UI (is that the right way to execute the tex file ?) then launched execution/rendering and got this error about LuaTeX not being found (even though the MikTex console / packages section shows that I do have Luatex85/Luatexbase installed ?):

This is pdfTeX, Version 3.14159265-2.6-1.40.20 (MiKTeX 2.9.7000 64-bit)
entering extended mode
LaTeX2e <2018-12-01>

starting package maintenance...
installation directory: "C:\Program Files\MiKTeX 2.9"
package repository:
visiting repository
repository type: remote package repository
loading package repository manifest...
0.19 MB, 0.29 Mbit/s
package repository digest: fe01a3e779a07ee6db226628bc13c979
going to download 176793 bytes
going to install 5 file(s) (1 package(s))
0.18 MB, 9.69 Mbit/s
extracting files from luatex85.tar.lzma...
("C:\Program Files\MiKTeX 2.9\tex/generic/luatex85\luatex85.sty")
("C:\Program Files\MiKTeX 2.9\tex/latex/base\article.cls"
Document Class: article 2018/09/03 v1.4i Standard LaTeX document class
("C:\Program Files\MiKTeX 2.9\tex/latex/base\size10.clo"))
starting package maintenance...
installation directory: "C:\Program Files\MiKTeX 2.9"
package repository:
package repository digest: fe01a3e779a07ee6db226628bc13c979
going to download 425322 bytes
going to install 6 file(s) (1 package(s))
0.43 MB, 14.18 Mbit/s
extracting files from luacode.tar.lzma...

("C:\Program Files\MiKTeX 2.9\tex/lualatex/luacode\luacode.sty"
("C:\Program Files\MiKTeX 2.9\tex/generic/oberdiek\ifluatex.sty")

! Package luacode Error: LuaTeX is required for this package. Aborting..

See the luacode package documentation for explanation.
Type  H <return>  for immediate help.
l.51     to prevent additional errors.}

EDIT: which configuration should be used in the drop-down menu ? It was initially set to “pdfLatex+MakeIndex+BibTeX”, I tried changing to LuaLaTeX+MakeIndex+BibTeX, which got me other kind of errors, see screenshot, but I have no idea what I am doing with this so enlighten me please :slight_smile:

@ClayJar Correct, the LuaLaTeX/METAPOST stuff looks at the JSON file and creates a page based on that — METAPOST can go straight to SVG as well, but there’s no reason one couldn’t use pretty much any tool for this. I’ve been looking at using TPL (Tool Path Language) from: which is based on JavaScript.

Here: (8.7 KB)

I need to work out some things there — in particular, the current placement of the lines for the joinery (discussed previously in this thread) is only suited for very thin stock.

Other tools which were considered were LiveCode and Nodebox and Processing.

@Julien My apologies — should have mentioned just using plain LuaLaTeX — there’s no need for any index or other processing — hopefully once you make that change it’ll run to completion. For production I would probably put all the referenced files into one .zip archive so that it could run in the background.

Selecting “LuaLaTeX” and rerunning got me this: any idea what I am still doing wrong ?

This is LuaTeX, Version 1.10.0 (MiKTeX 2.9.7000 64-bit) 
 restricted system commands enabled.
LaTeX2e <2018-12-01>

luaotfload | main : initialization completed in 1.050 seconds
("C:/Program Files/MiKTeX 2.9/tex/generic/luatex85/luatex85.sty")
("C:/Program Files/MiKTeX 2.9/tex/latex/base/article.cls"
Document Class: article 2018/09/03 v1.4i Standard LaTeX document class
("C:/Program Files/MiKTeX 2.9/tex/latex/base/size10.clo"))
("C:/Program Files/MiKTeX 2.9/tex/lualatex/luacode/luacode.sty"
("C:/Program Files/MiKTeX 2.9/tex/generic/oberdiek/ifluatex.sty")
("C:/Program Files/MiKTeX 2.9/tex/luatex/luatexbase/luatexbase.sty"
("C:/Program Files/MiKTeX 2.9/tex/luatex/ctablestack/ctablestack.sty")))
("C:/Program Files/MiKTeX 2.9/tex/luatex/luamplib/luamplib.sty")
("C:/Program Files/MiKTeX 2.9/tex/latex/tools/calc.sty")
("C:/Program Files/MiKTeX 2.9/tex/latex/xcolor/xcolor.sty"
("C:/Program Files/MiKTeX 2.9/tex/latex/graphics-cfg/color.cfg")
("C:/Program Files/MiKTeX 2.9/tex/latex/graphics-def/luatex.def"))
("C:/Program Files/MiKTeX 2.9/tex/latex/forloop/forloop.sty"
("C:/Program Files/MiKTeX 2.9/tex/latex/base/ifthen.sty"))[\directlua]:9: attem
pt to index a nil value (field 'Sample')
stack traceback:
	[\directlua]:9: in main chunk.
\luacode@dbg@exec ...code@maybe@printdbg {#1} #1 }
l.185 \end{luacode}

Oh yes, there’s one other thing.

I disabled the \typein of querying for which Saved Preset would be used:

%\typein[\boxspecification]{What preset is to be used?}

and instead, hard-coded it to:


You’ll need to either name your pre-set “Sample”, or change that line in the .tex file to match your name — please avoid using underscores or special characters.

Another reason to use METAPOST (besides the fact that I want to learn it so I can leverage that to learn METAFONT so as to do a typeface design I’ve been working on for decades) is that it allows analysis of paths and intersection, which some of the boxes require:

Renamed my preset to “Sample”, and success:

So to sum up what I did for other members, the workflow is easy enough:

  1. install OpenSCAD (2019 RC4, not the latest stable 2015 version)
  2. open the .scad file, modify the parameters in the Customizer, then create a “Sample” preset with the “+” button, hit “Save Preset” to get the JSON file.
  3. install MikTeX, launch TexWorks, open the .tex file, select “LuaLaTeX” in the drop-down menu, hit the “play” button, and voilà, the PDF.

Not having to open Inkscape to get from the PDF to an SVG would be a good improvment to the workflow.

1 Like

METAPOST will directly create an SVG — I just need to structure the files to allow for that.

1 Like

Hey, Will, will one be able to make the finger cuts a bit deeper - and before they come out of the fixture use a 90 deg Vbit to put a chamfer on the ends of the fingers so they will be proud, and finished, when assembled?

I’m still not sure how you’re doing this as once it stated that all four pieces should be milled at the same time and then it was two. Have you done a video - or do one when this is all completed?

Thanks for the work. Don’t know where your kick-starter is located, but I’ll kick in a few bucks if it is still open. Location??


Working on a video and set of photos now.

The Kickstarter is at:

Leaving the fingers proud and chamfering is an interesting idea — it’d make assembly easier if nothing else — I’ll see if I can work that in as an option.

Hit Kickstarter. Thanks for the link.

1 Like