2017-02-11

OpenSCAD with some heart, and balls!

There are a lot of tools for making 3D models, and if you have a 3D printer it is useful to have some of these. One of the most useful tools I have found is OpenSCAD. There are many types of tools, some more artistic, some scanning, but OpenSCAD is an engineering drawing programatic tool that lets you create 3D objects using code.

There is a a Secret Heart on Thingiverse which is really excellent and creates a complete object that then twists between a heart and lozenge shape, locking the compartments that only open when in the heart shape. I was always impressed with it and it "just works" on the Makerbot replicator 2. I tried it on my new TAZ 6 and it did not quite work, which is unsurprising. They publish the OpenSCAD file and I tinkered and did not get far, so in the end I decided it would be a really good learning exercise to make one from scratch.

There are a lot of small details in the final model, so I won't bore you with those, just some of the basics.

How to make a heart shape?

Well, let's start with a few basic constants :-

But how to use these to make a heart, well, a start is the basic "lozenge" shape. How about two spheres?

That does not look that good.

OK, let's use a hull function...

Better but not there yet... That is more a sort of medicine capsule!

How about slicing the top and bottom off...

Closer...

Now, let's cut it in half...

Better...

Now things are looking good... Let's try the other half...

That looks like a heart!

But I want a hollow section of a heart, so let's make the module that creates each half have an "offset" and we can subtract if from the solid.

As you can see, making the outside transparent, the inner makes a nice hollow.

But this was not enough. I needed the hollow to have chamfered edges, else the thin wall would mean the slicer had trouble bridging the top, so how to do that?

Well, make it have an offset for horizontal and vertical...

Here I have shown the two versions with offsets overlapped. Not quite chamfered edge yet.

Let's make a hull and subtract that...

As you can see, with outside transparent, the inside has a chamfered corners as intended.

That is just the basic shape of the heart sorted, hollow, chamfered edges on inside. There was a lot more detail to add, to make joints and hinges and so on, but that should give you some idea of how OpenSCAD works for now.

The end result...

And yes, the moral of the story is that a Valentine's heart starts with a pair of balls...

P.S. I am used to coding, and usually with code there is a reasonably clear end point when it all works - apart from finding and fixing bugs. But this is more art than code in many ways, so I have spent a couple of days fine tuning the design and doing test prints - you really do not know when to stop with things like this - there is always some tiny tweak to improve it either technically or aesthetically, and there is always a way to test the limits of the printer.

1 comment:

OpenSCAD is the ideal tool for me - all right, I have experience with PoVray and I've been doing design with CSG for something like a quarter of a century at this point, but it's always seemed like the most sensible way to go about things.

Everything I write here is just my honest opinion and not a statement by my employer, etc, you get the idea. If you find any words or pictures menacing or offensive, or likely to impair your computer, or alarming or distressing, stop reading now and don't come back (and don't forget to block me on social media too). Nothing here is legal advice. Everything on this blog is without prejudice, just in case. Comments are moderated to weed out obvious spam, so do not appear instantly. You take responsibility for any comments you post. Always bookmark www.me.uk as I may change the URL blogger sees.

And please, if you don't like what I post, say so - comment - discuss...