Designing in OpenSCAD for laser cutting

Hi folks. My design chops are mostly honed by making things for 3D printing, and in preparation for the eventual arrival of my Glowforge I’ve been trying to to adapt some of my skills for 2D. One of my favorite tools for 3D design is OpenSCAD. If you haven’t heard of it, that’s a CAD program that produces precise 3D models by combining 3D shapes generated by a sort of programming language.

I’ve used the program to make various brackets and other doodads, so I’m pretty familiar with it (though not what you’d call an expert). One of the reasons I like it so much is, if designed correctly, you can make your designs parametric. Drop in a few new measurements and it’ll reconfigure the result to match the new size.

After buying a huge package of AAA batteries I started to think about how one might design a parametric battery dispenser that would adapt to different size batteries. Here’s what I came up with:

After some finagling, I got OpenSCAD to give me a DXF file, then loaded it into Inkscape and got this:

Now, I’ve never designed for 2D before, so I had no idea if this would work at all… So I printed it out and taped it to the box that the batteries came in, with the material settings set to match the thickness of the cardboard. Then I pulled out the exacto knife:

So it worked, though I didn’t put any thought into stuff like kerf thickness so heaven knows how it will work on a real laser and made from something more sturdy than cardboard.

Long story short, I guess I’m wondering if anybody has put any thought into OpenSCAD as a tool for Glowforge design? My file isn’t exactly clean or well commented, but if anyone wants to see the OpenSCAD code that created this (or the resulting DXF or SVG file), I can probably make them presentable enough to post.

8 Likes

First off welcome to the forums!

This is an awesome project and a really good starting point. Personally I don’t use OpenSCAD but it has been widely discussed here in the threads. Give is a search to see all the wonderful things people are doing with it. I have a ton of AA kicking around so I could see this being useful. Cool concept and just a thought here but imagine what you could make combining lasers and 3D printing!

Cool project.

I just started playing with OpenSCAD this past weekend. There’s a small learning curve, but if you know anything about programming, it’s not too bad. I wanted to start incorporating mazes in my designs. So I wrote a quick program to generate circular mazes. With about 50 lines of code, I was able to generate something like this:

It’s a very powerful tool. I need to learn more about it.

6 Likes

Neat! I should have done the search first. The AA holder (I didn’t take a picture of the AAA holder) works pretty well. The only iffy part (aside from my knife skills) is the battery stop at the front. A bit flimsy for cardboard, but it might be fine in a stiffer material.

Nice idea there!
Some while back there was a long discussion about making a holder for matches that looks like a very similar concept.

Also check out some of the posts on dice towers if you are looking for more good ideas.

1 Like

That looks great. I am not very familiar with OpenSCAD yet. Did you design the cut outs / connection parts by hand, or was that part of the programming? And, I am sure it will work with the GF, since it will just cut along those lines for the design.

I think you could also do something like doubling up the end stop, or having sides on the ramp that would hold it up.

Thats a really cool design that you could etch on something, even if you are not wanting an maze. I really like the idea of programmatically designing things like that. I will definitely have to check it out.

What I really like about it, is that I can now change the dimensions of everything just by changing a few variables at the top. I have variables for the diameter of the circle, how many rings in the circle, how wide is the path and how wide are the walls, and where each wall and gap is located in each circle.

By changing just a few numbers, I can get something that fits what I want immediately. I just changed a few variables now, to see what I get:

It’s not perfect, (I’d have to fine tune it where each wall and hole is placed.)

Right now the placement of the walls and holes are predetermined and stored in variables. I’d like to come up with a method where they are random (but it still makes a usable maze).

1 Like

Yeah, the connection points are just little “cubes” joined to the edge, and those cubes are “differenced” from the mating pieces.

That’s a good plan for the support for the battery stop. I also think I can afford to decrease the angle a little to get the batteries to not smash into it so hard.

Very nice project. Also good to have the OpenSCAD resource here. I just downloaded it Sunday but haven’t had time to play much with it. I’ve noticed that the community resources are extensive. Always nice to have examples to learn from.

I’ve been a user of OpenSCAD for a while too, also for 3D printing.

I’m glad they added the export options for 2D drawings, but I really wish it was a bit more configurable. If we could set colors and stroke size for the SVG output we could bypass having to do editing in Inkscape after the render in OpenSCAD.

I’m sure they’ll get there sometime, just a question of when. I know it’s not high on their priority list. Maybe one of these days I’ll see if I can add it in to the code and send 'em a pull request. =P

This is awesome use case for parametric cad design. I’ve 3d printed some AA & AAA battery boxes like these but laser cut would be so much more efficient! I’d love to see it adaptable to coke and soup cans as well.

1 Like

Did not make heavy use of OpenSCAD so far, but as I recall it is rather akin to C++. So here is a maze generator. You can find examples of maze generator code pretty easily, it is a typical early practice problem for students learning to code.

Of course, making mazes comes in myriad degrees of competence. You can code to only have one path for solution, you can code to have false paths of certain lengths. You can also code to break “Wall hugging…”

If you want to go from complete scratch, then starting with a random walk with large step size to get your solution path, then selecting branch off points to random walk false leads and fill the remaining space tends to be a pretty quick approach.

2 Likes

Openscad has a lot of nice stuff for making modules, so for example once you have a joint outline you like you can position it anywhere. And the more recent versions have offsets, which are perfect for dialing in the post-cut dimensions of pieces that have to mate or otherwise meet precise dimensions. (Last summer I sat next to a guy who was trying to cut puzzle pieces using CorelDraw, and the result was just not as nice as it might have been because of the cut thicknesses.)

Thanks for the link to the Maze Generator. I’ve actually written one when I was at University (years ago now). I’m having to refresh my memory on how they work, and apply them to a circular maze rather than a rectangular maze.

I would not really compare OpenSCAD to C++. I’ve only spent about an hour with it, so I’m not an expert in any way. But to me it feels more like a scripting language than an interpreted language. Although there are some odd things happening with the scope of variables that is tripping me up a bit.

I have to experiment a bit more with it. But I think there is a lot of power there. Especially when it comes to making designs that we can customize to different sizes and material thicknesses. That is my one complaint about SketchUp. It’s difficult to make changes to a design once it is completed. I can easily resize the entire design, but I cannot just change the material thickness without changing all the other dimensions.

The other thing I forgot to mention is that I can see some value in using OpenSCAD’s ability to introduce randomness into designs. SketchUp does not have any way of making things a random size.

I can envision making some designs that have random patterns on the front. I think that would be interesting.

Yeah, the way it handles scope is weird. Things like a = a + 1 aren’t possible. It could stand to be a lot more robust, but I’m still a big fan. I’ve actually gone so far to do more complex stuff in python in order to generate the code for openscad to render. (Which I’ll admit is a bit ridiculous, but there comes a point when you get sick of trying to figure out the right way to do something and just choose the wrong way that works.)

1 Like

LOL. I was just thinking this morning of using Tcl (like Python) to create some code for openscad to run. Great minds think alike.

Just curious as to how you’re doing this. I have a considerable amount of experience with python but 0 with OpenSCAD. I think ill eventually learn it.

Nothing fancy. When I was doing some complex calculation of offsets, I wrote a python program to take the input and calculate the final numbers, then I output a text file with a “.scad” extension that was filled with generated strings of the format:

length1 = 11.235;
offsetX1 = 23;

translate([offsetX1,offsetY1,offsetZ1])cube([length1,width1,depth1]);

Things like that. It’s really a rather goofy way to do it, but frustration has odd effects on me.