Generating Laser Cut Boxes In C

[Mike] is a laser cutting newbie and has never had the opportunity to create a file and send it off to a laser for cutting. He knew he didn’t want to squint at a CAD package, nudging lines by tenths of a millimeter, only to screw something up and have to do it all over again. His solution, like so many other automation tasks, was to create a program that would generate a box of any size in .SVG format.

[Mike]’s program runs in C, and only requires a few variables set in the program to create a box of any size. There’s no argc or argv for the program – the one thing that would turn this into a command line utility that simply creates SVG boxes. Perhaps another time.

The rest of [Mike]’s hackerspace, Fab Lab xChc, was impressed the program worked the first time. With this small bit of C code, [Mike] has an easy, simple tool to generate laser cut boxes. The only remotely complicated bit of C this program uses is printf(), so even an Arduino can spit out the SVG for a laser cut box.

31 thoughts on “Generating Laser Cut Boxes In C

  1. Author should slap a proper license on it and throw it up on github. “…you are more than welcome to use this to generate your basic box.” doesn’t count as a proper license, really.

      1. Actually, without a license default copyright law applies and in most countries that means you are not allowed to do much with it.
        (Yes, it’s annoying, and the people that hammer on stuff like this like crazy open source acolytes are annoying. But there is a bases for why they do it)

        1. Unless the author sues you for copyright infringement, nothing will happen when you make a copy. Copyright law is typically a civil law, not a criminal law. And the statement “you are more than welcome to use this” will be interpreted by the court as if the work has been put in public domain, so you have nothing to worry about.

      2. Nope. Nor does every piece of code have to be commented or neatly written, but it’s a good habit to get into. A license is pretty much a couple of clicks if you’re putting stuff on GitHub.

        I do particularly recommend sticking it on GitHub, though, since it’s awesome for collaboration.

    1. :-) This is ‘HACK’aday after all.

      There is a couple of non-obvious features that make it uglier than it should be. For example, the panels are perfectly symmetrical as everything uses integer math and any leftovers are placed in the center finger. if I used floats and rounded or used integer i*n/m to locate the panels could be off by 0.2mm depending on the parameters used.

      Unlike any others i have seen (although i haven’t looked either) it has an allowance for the cut width, giving the fingers a really snug fit. The cut is about 0.16 mom wide, and so the fingers end up being 0.04mm wider than the gaps they go into.

      When you include these, there isn’t really thay many sins in there for an hour while half watching TV. Sure I could pull out some repeating code into a function, but it would actually make it more complex. But if you want to show me how to do it properly then send me and email – I am actually keen to do it better!

      1. I have started working on it in between a few other bits, it is a bit of a struggle with trying to work out what to do.

        Also, yes, i understand what it is and love the “i wanted to solve a problem so I whacked this together” attitude :D

      2. 0.16mm wide? That is a very good laser you are using. Most machines I have come across have a kerf width of 0.3 (laserpro spririt GX/GXL, to 0.4 (epilog mini35). Glass tube lasers might even have a wider kerf.

        1. 0.16mm sounds about right, even the cheap 40W lasers with glass tubes do that.

          I’ve got three (hey, you need a couple of spares) and I usually allow for 0.2mm kerf. Bigger or smaller depending on how tight I want the fit. Kerf depends on material and focal length as well.

      3. Allowing for the laser kerf and making the fingers slightly tapered makes it quite nifty and ensures a good fit. Tip of the hat for that!
        What I usually see (I work in a fablab) is no allowance for the laser process at all, which leads to boxes that need glue or fasteners to stay together. And non-fitting parts because of errors, as designing in 2D makes that easy.

Leave a Reply to JelleCancel reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.