Parametric two-part mold generator for OpenSCAD

by jasonwebb, published

Parametric two-part mold generator for OpenSCAD by jasonwebb Nov 28, 2012

Featured Thing!

2 Share
Download All Files

Thing Apps Enabled

Order This Printed View All Apps


Design Tools


Use This Project

Give a Shout Out

If you print this Thing and display it in public proudly give attribution by printing and displaying this tag.

Print Thing Tag


Thing Statistics

206470Views 12509Downloads Found in Art Tools


A set of parametric OpenSCAD scripts that generate ready-to-print two-part molds from arbitrary STL models.

These scripts can be used to generate either square (with or without rounded corners) or circular two-part molds and are fully parameterized to make it easy to adapt for your application.

Refer to the instructions below for some general tips, as well ideas for casting.

I have successfully made casts from these molds using wax, Knox gelatin, Oogoo and chocolate. If you have success with other casting media, please leave a comment!

Many more pictures of molds and castings I made with these scripts: http://www.flickr.com/photos/zenwebb/collections/72157631531182783/

If you'd like to read about the development process for these scripts, and learn from some of the issues I came across, check out:

If you really want to bring your molds and castings to the next level you can even try the "lost ABS" (or lost PLA) process to turn it into metal!

I have also uploaded a parametric open-face mold generator to create positive and negative molds.

More from Art Tools

view more

All Apps

3D Print your file with 3D Hubs, the world’s largest online marketplace for 3D printing services.

App Info Launch App

Auto-magically prepare your 3D models for 3D printing. A cloud based 3D models Preparing and Healing solution for 3D Printing, MakePrintable provides features for model repairing, wall thickness...

App Info Launch App

Kiri:Moto is an integrated cloud-based slicer and tool-path generator for 3D Printing, CAM / CNC and Laser cutting. *** 3D printing mode provides model slicing and GCode output using built-in...

App Info Launch App
KiriMoto Thing App

With 3D Slash, you can edit 3d models like a stonecutter. A unique interface: as fun as a building game! The perfect tool for non-designers and children to create in 3D.

App Info Launch App

You can please make the code is exactly the same molds as the photo. I do not understand and have the procedure simply. I am interested in the holes on both halves and square shape. http://thingiverse-production-new.s3.amazonaws.com/renders/fc/b4/06/0b/36/8078356541_00267f2cde_o_preview_featured.jpg

Very cool! What program did you use to design the mold?

Very cool! What program did you use to design the mold?

can someone give the video instruction ?

i cant understand/interpret the words..

maybe video can help.

Comments deleted.

I can't wait to print my very own Admiral Snackbar.

I get an error showing "cant load file type"
I have a simple .stl file, I don't understand the issue.
Can you please make a video on how to use this script.

Thank you !

jasonwebb, can you add a setting that will center (able to move it up or down would be the best) the stl between the two halves. I love the idea, yet it seems real hard to get the two halves with the right amount of each side of stl centered in the two halves of the output mold. That would make this the greatest........!!

Thanks, Rick.

Apr 10, 2016 - Modified Apr 10, 2016

Works GREAT!!! Just make a folder called "Sample inputs" in the folder of which you downloaded and unzipped and run the scad program in. Now just drop your stl file in there and change the name to match your stl file name in the model_filename = "Sample inputs/YOUR_FILE_NAME.stl" and it should find your stl and import it.

VERY NICE, Thanks, Rick.

Whenever I follow all steps of this mold generator and get items positioned, I preview first, but after hitting F6 I keep getting same error, what can I do to fix this?

ERROR: CGAL error in CGAL_Nef_polyhedron3(): CGAL ERROR: assertion violation! Expr: e->incident_sface() != SFace_const_handle() File: /data/OpenSCAD/libraries-mingw64-master/mxe-w64/usr/x86_64-w64-mingw32.static/include/CGAL/Nef_S2/SM_const_decorator.h Line: 326
ERROR: CGAL error in CGAL_Nef_polyhedron3(): CGAL ERROR: assertion violation! Expr: e->incident_sface() != SFace_const_handle() File: /data/OpenSCAD/libraries-mingw64-master/mxe-w64/usr/x86_64-w64-mingw32.static/include/CGAL/Nef_S2/SM_const_decorator.h Line: 326

Getting the same errors on a different line

These errors happen when you try to use a non-manifold stl with the generator...You can use a combination of the free tools Netfab Basic and Meshlab to fix a number of these types of problems, but at the end of the day you may end up having to fix them by hand. OpenSCAD requires files to be 100% perfectly manifold or it won't work.

That's what it looks like. I got it to work with a simplified version. However meshlab had said there were no non-manifold edges or vertices on the original. Thanks for reply.

Hmm there's 4 things OpenSCAD hates..

It doesn't like internal structures, this isn't something MeshLab will fix but you can fix it with the "hollow" feature in MeshMixer.

It doesn't like non-manifold edges (meshlab)

It doesn't like non-manifold vertices (meshlab)

It doesn't like too many polys. The import used to only work with 20K faces or less, now it's a bit better but I really wouldn't push 40k or 50k polys.

Mar 9, 2016 - Modified Mar 9, 2016
rogertaylor - in reply to rocketboy

Here's a shot of what wasn't working. It's a swimbait fishing model. When I took the rings off and made the body smooth, it worked first time.


Got it down to 5000 faces

Hmm without the stl it's really hard to guess what the problem was...my guess is that the rings had internal bits where they met the body the rings were manifold the body was manifold but inside the body there were bits of ring...Meshlab would be a-okay with that but openscad wouldn't be...If that were the case you could have fixed it by loading your model in MeshMixer (free tool) and selected the "Make solid" tool (I can't remember what menu it's under off hand). It would be nice if openscad wasn't so picky about the internal structures bit, it does know how to deal with them internally when it creates them itself...

The "Make Solid" in meshmixer worked. Thanks!

Excellent :) Glad I could help, I've spent way way too much time fiddling with models to make them work with OpenSCAD..before meshmixer came out with that option often the only fix was to do it by hand, which took hours...

Probably, I'm a stupid, but I don't understand the instruction for add a STL file in your openscad.
Please, can you help me, with a tutorial step by step?
PS. the "sample-input" it's working perfectly, in the same folder

I'd like to make this object http://www.thingiverse.com/thing:40212/#files

Maker Faire Robot

Hey Printerapp3D,

That model has a bunch of problems with it that will prevent you from just pulling it into openscad and using it...I wrote a pretty extensive blog post about how to use a modified version of this script to make a mold here: https://blog.pinshape.com/how-to-generate-a-3d-printed-mold-for-an-object/

It mostly focuses on the cleanup you'll need to do with the model before you pull it into openscad.

Hope that helps,


hello. i've tried to make mold of a speaker gasket/seal :

but it seems that mold generator fails because it simply subtracts the model from cube, and then cuts the block in two :)
obviously with 'facemask' shape geometry this results in something far else than one would expect from a mold :)

i do have few ideas how to realise it manually in blender though it will be tedious process. perhaps anyone have ringing bell about how it should be coded properly in openscad? :)

16 inch speaker seal mold.

Hi! Has someone tried printing them in (non flexible) PLA? I would like to make some molds for my mom (she does homemade soap)

Sorry! I've got it! My model was always in the mold, so I had to put it to the top with

model_translate = [0,0,15]; (15 puts the model to the top)

Oct 14, 2014 - Modified Oct 14, 2014

I've got a problem:

When I use the "sample-input", all is okay and I get two parts and they're good. When I use my files (I tried a few objects), I always don't get a mold. I always get two parts, but there is no mold this are only two cubes, in one cube is an hole. The file is located in the folder with the right path, I don't get any error message, all is okay. What is wrong?

I tried some objects, like the number 4 as a 3d model.
I've tried to comment the lines out and my number is there, but when I start the script originally, I've got the same problem

Thank you very much!!

This worked great!!! Thank you!

Thanks!!! Now it doesnt make the stl file inside the mold, but if i write import(model_filename); it does show the stl file, any ideas???

Hi!!! Cant find the way to point inside de openscad script to the file i want to make the mold of.
This is how i point to the folder ´´C:\JORGE\PRUEBA.stl´´
and this is the error WARNING: Can't open import file '"C:JORGEPRUEBA.stl"'.
I dont know what i am doing wrong!!!

Change the backslashes to forward slashes.

Ok, I read through the comments to try and figure this out but that didn't help me. No matter if I am using my own STL or the sample one, when I run it through the script I just get blank boxes or cylinders with poor holes and keys but no mold. I get no errors, and in the grid only view mode I see nothing but the mentioned parts. I really want this to work and it's driving me a little crazy now. Any idea what I am messing up?

Check that you are using the most up to date version of OpenSCAD (2014.03). I just downloaded both of the SCAD files and the sample input STL from this Thing and tested the scripts out and they work perfect for me.
Make sure the filename indicated in the model_filename variable is actually pointing to the right file in the right location. If you download the scripts and change nothing, it will be looking for your file inside of a folder called "Sample inputs", which you may need to change if you don't use such a folder.

... doh... I never changed the sample inputs folder for the sample file, but still not sure why I can't get my files to work. I think it's not centered properly.

Did you solve it???
I have the same problem...

The two main causes for something like this is that either your STL isn't manifold or your model isn't the right scale, or centered on 0,0.

To verify that your model is manifold download meshlab (It's free and opensource). Under the Render menu option turn on 'Show boundary edges', 'Show non manif edges', & 'Show non-manif vertices'. They should all show up as 0.

If that all looks good it may be that your model is not centered or to the wrong scale. In Openscad in the BottomHalf function comment out:

    difference() {
        difference() {
                roundedBox([mold_width, mold_height, mold_depth], edge_radius, true);
                cube(size = [mold_width, mold_height, mold_depth], center = true);


        if (pour_hole) {
                    cylinder(h = mold_depth*2, r1 = mold_depth*2, r2 = mold_depth, center = true);

This should draw your model in positive on one side, you'll then be able to tweak things so your model is in the center and to the right scale for the current sized block.

So, I'm trying to use this script with this .STL
http://www.thingiverse.com/thing:167875http://www.thingiverse.com/thi... (getting a jump on next Halloween)

I've repositioned it in the script::
// Model parameters
model_filename = "Celtic_Skull_Fixed.stl";
model_rotate = [90,0,0];
model_translate = [0,42,-10];
model_scale = .45;

// Mold parameters
mold_diameter = 33;
mold_height = 35;

and when I Compile, I see the indentation of the skull in the mould just as expected.

But when I compile /and Render (GCAL)/ the mold appears to be empty, and, the first time only, I get this error:

Rendering Polygon Mesh using CGAL...
CGAL error in CGAL_Build_PolySet: CGAL ERROR: assertion violation!
Expr: check_protocoll == 0
File: /home/don/openscad_deps/mxe-w64/usr/lib/gcc/x86_64-w64-mingw32/4.7.2/../../../../x86_64-w64-mingw32/include/CGAL/Polyhedron_incremental_builder_3.h
Line: 199

I saved the STL file anyway, and it doesn't appear to have any impression of the skull in it when viewed in MeshLab or Cura.

Any idea what is going wrong there? Is the skull just too complex? I get the same error if I change the script to just import the skull without using the mold script, so it must be something with the skull stl file. Wish I knew how to fix it.

Celtic Skull (Hollow)
by 3DWP

Yep, you will need to work on your STL a bit. Most likely it is too complex for OpenSCAD. Under the Instructions section there is a note at the very top about how to use Meshlab to reduce the polygon count of your model for use with this script. This video may be helpful: https://www.youtube.com/watch?v=w_r-cT2jngkhttps://www.youtube.com/watch?...

Turns out there was an error in that STL file. The source of that file was fine, but the version that was "fixed" was actually broken! LOL. I also had to reduce the polygon count a bit as you documented (THANK YOU!) in order to get the compile to finish in a reasonable time.

Hi i'm planning on using my 3d printer to print a polyurethane wheel. Now my question is it easy to remove the mold? Also would polyurethane work? If anyone can give me a quick response that be great!

The most important factor with any mold is whether the part is designed well for the mold release process. Think about draft angles and feature thicknesses, as well as the tolerance of your casting medium (can it stand up to a little bit of bending or compression, etc.)

To release castings from your mold easily you will want to use a mold release agent. I was able to cast resin and silicone using my molds just fine using Universal Mold Release from Smooth-On, so I think I would recommend that for polyurethane. You can also try using Vaseline, if you're adventurous. Here are some notes about my experiences with resin and silicone: http://jason-webb.info/2012/12/resin-and-silicone-casting-with-3d-printed-molds/http://jason-webb.info/2012/12...

Alright thank you for the quick response. I've decided to be a courageous and make a mold out of this. I will post a pictures of the product once I finish the prin. Thank you so much.

I'm trying to make this and everything looks correct when I compile. However, when I actually Compile and Render the blocks are gone and all that remains is the STL file. So when I export to STL, it's the same STL I already have and won't serve as a mold. I'm not sure what I'm doing wrong as this is the first time I've ever used OpenSCAD but I got the positioning setup properly.

The script assumes an STL model that is prepared as if you were going to 3D print it. In other words, centered around the the origin on the X and Y axes and sitting atop the origin on the Z axis. Open your model in ReplicatorG and hit "Move > Center" and it will take care of that for you. Inside of the OpenSCAD script you can use the model_rotate and model_transform vectors to move the model around however you need, but you must know how your model is oriented to begin with.

Also make sure that the model is correctly sized (not too big or too small). Again, opening it in RepG should give you some sense of if it is too big or too small to be visible.

If OpenSCAD is new to you, I recommend looking at some other scripts and understanding what is going on. I wouldn't classify this script as beginner-friendly, but you can learn a lot from it. Start by making a new script and typing in import("yourmodelname.stl"); and compiling that. You can then use the rotate, transform and scale functions to tweak the model. Try making a cube that encloses your model perfectly. This should help you understand how this script works.

This is very cool. I have experience in silicone molding. i think these techniques to make the mother mold, vents etc, and then being able to pour in silicone blanket mold will be very interesting.

Great job! It is awesome and work perfectly! Thanks a lot for your contribution.

thats fantastic, amazing, astonishing. wow super

Many thanks for sharing. excellent

Thanks, this worked great when we did some candle wax castings with my son. I blogged a bit about this in http://random3d.wordpress.com/2013/04/02/candle-castings-with-3d-printed-molds/http://random3d.wordpress.com/...

That's really awesome! Thanks for sharing!

When I try it with your example STL file, it works fine, but when I try it with my STL files, it never works. Any hints about how to position the STL file with respect to the mold? Is there any way to see where my STL file is in relationship to the mold (in case it is inside, or way outside of the mold)?

Make sure that the physical dimensions of your STL object aren't too much bigger or smaller than the dimensions of the mold. Also, the script assumes that your object is centered on the X and Y axes, and sitting atop the Z plane, just like it would be in ReplicatorG.

After using "Compile and Render", switch to View > CGAL Grid Only and see if your mold has any alterations inside it.

If you still can't find it, add an extra import(model_filename); in different parts of the modules within the script. If you want to just have it show up on its own, it must not be inside of any difference() blocks. You'll probably need to apply the model_translate and _rotate vectors, because that is how the import function is used everywhere in the script.

You can use the model_rotate and model_translate vectors to position your STL after you've located it.

Can this be combined with the new customizer feature of Thingiverse? THat would be so cool.

You know as much as I do! Never heard about this customizer thing until yesterday, and I still don't know what the heck it is. If I could just upload a special OpenSCAD script and tell Thingiverse which parameters to break out, I'd do it in a heartbeat. But right now, it looks like I'd have to spend a few weeks at least figuring out the API and developing a program from scratch. No thanks :P

No need to make an app with the API. However, Customizer can't (yet) import external STL files. Goto http://www.thingiverse.com/apps/customizer/runhttp://www.thingiverse.com/app... and click the Learn More link on it's home page for more info on getting openscad scripts optimized for Customizer.

Well Customizer 2.0 better import .stl files. THat would just open up so many possibilities....

Yes. Yes it would. :)

Aha, that does seem much more friendly than the full-blown API stuff I was looking at :P I'd be extremely excited to see the ability to import/upload external STL and DXF files as input, that is something I use a lot in my work :) Thanks!

Hello Jason!

Thanks for sharing this with us.. I just having a noob problen :/

When you say;

"2. Update the parameters in the script to point to your model, as well as transform it to be suitable for printing."

On this printscreen (link) it shows where I put my location, but is not working. ;/


And should I install the Openscad in any special place?

Alsto when I load the "square-two-part-mold-generator.scad" and press F6, it says that was impossible to load "Sample inputs/sample-input.stl""

Sorry for this amatuer question, I really don't understand codes :P

Thanks anyway :)

If you didn't get any errors during compiling, your object may be there without you seeing it. Use View > CGAL Grid Only to see a wireframe representation of the mold. Maybe your object is inside the mold block, and you just can't see it.

Also, I find that its easiest to have the SCAD file in the same directory as the STL file, just so I don't have to write out the whole path.

You will get an error if you try to run my code, unless you have your own STL named sample-input.stl in a folder named Sample inputs. Just change the filename to point to your own model, and you'll be fine.

OpenSCAD is not a very easy program to start with, so I would try learning the basics of OpenSCAD User Manual (http://en.wikibooks.org/wiki/OpenSCAD_User_Manual)http://en.wikibooks.org/wiki/O... and the included examples before attempting to do more advanced stuff.

Great thing!  On the topic of a release agent, the experimental vehicle team I am on uses a spray form of PVA that is purple and works really well for epoxy resin release. I can't remember it's name but I am sure it's easily googled. Keep up the good work!

Have you ever tried casting resin in one of these?  I'm wondering if it would fuse to the ABS.

I do have some casting resin that I was planning to try when I get a chance. It would be very important to use a good release agent with resin to prevent fusing. I've heard of using cooking spray, as well as Universal Release Agent from Smooth-On. However, if worse comes to worse, you can still drop the mold in a jar of acetone and dissolve the mold, leaving the resin casting behind (maybe) :)

Did you ever try the resin casting? I want to cast some urethane without making a silicone mold. I'm sure it depends heavily on the type of resin and the type of release agent. Perhaps a wax followed by a release spray?

Yep! I had success with both resin and silicone, but you will want to use a release agent for sure. I used wax just to fill in cracks and major overhangs, then sprayed Smooth-On's Universal Mold Release spray, which worked great. I used Amazing Casting Resin, which turned out to be very rigid and plastic-feeling, almost identical to the silicone I used. Here are some photos:

Yep! I had success with both resin and silicone, but you will want to use a release agent for sure. I used wax just to fill in cracks and major overhangs, then sprayed Smooth-On's Universal Mold Release spray, which worked great. I used Amazing Casting Resin, which turned out to be very rigid and plastic-feeling, almost identical to the silicone I used. Here are some photos:

"It is concluded that PLA is safe and 'Generally Recognized As Safe' for its intended uses as a polymer for fabricating articles that will hold and/or package food."

Just don't use ABS!

Great post!

Unfortunately, food safety is just not a cut-and-dry topic. The link you provided doesn't work for me, but there are several sources on both sides of the issue. Food safety involves not just the molecular structure of the material, but also its application and handling. In short, no material is 'food safe' if its handled incorrectly. The real question is, how does one handle ABS safely?

The Thingiverse blog has some good info on the topic here: http://blog.thingiverse.com/2009/09/13/for-foodies-out-there/http://blog.thingiverse.com/20...

Also check out this discussion at the RepRap forums: http://forums.reprap.org/read.php?1,164077http://forums.reprap.org/read....

My recommendation is to use whatever you are comfortable with, but take personal responsibility for your own safety.

I used spray butter as a release agent when casting with gelatin and chocolate. I consumed the results and didn't die. Is it categorically 100% safe? Who knows? There are still people who say that the fumes put off by ABS/PLA during the printing process are harmful, so you really have to make your own judgement.

how did you manage to get that general akbar trough openscad?
i cant even compile data with half the detail.. crushes all the time.

i want make molds from my devilhead stl.
i even reduced its polygon amount and its just 1.5 mb now.
this is a part i printed a few times and i got no problems slicing it.

i intend to fill the mold with silicone so the small overhangs shouldnt be a problem.

Devilhead 2.0
by yzorg

OpenSCAD has some pretty severe limitations when it comes to loading external files, among other issues :S I took the model and ran it through Meshlab's Quadric edge collapse several times. I basically would run it once, save it and try it in OpenSCAD, then repeat until it loaded. The resulting size of the Ackbar model was about 400kb, and only has about 9000 faces.

You'd be surprised at how few faces you can get away with and still have a perfectly good-looking model! Especially when you consider that the more you scale down your object / mold, the less detail you'll actually see anyway.

 ok. then i have to make the molds with cinema4d.
because for a cast i would want to have maximum resolution.

Go for it! Just boolean subtract your STL from the inside of a cube, then split the cube and add keys so it fits together right after printing. Cinema4D is pretty finnicky for me when it comes to 3D printing, so be sure to run your STLs through netfabb's cloud service to get it nice and manifold :) Good luck!

That's an excellent suggestion, I didn't think of doing a Boolean subtract until you mentioned it in this thread, I will do this to some complex models in 3dsmax. I would love to play with molds of 3d models printed out.

Really nice job on this, thanks for all the detail :)

Hey there - nice work! I am the one that did the lost PLA that ABS casting links to (and apparently was what inspired him).

Note that for lost PLA/ABS casting you actually want a mold positive, not a mold negative.

That said, you could use a mold negative to create wax copies that could be used with the traditional lost wax process. The nice thing about that is it is much faster to create a wax copy from a mold then it is to print a new one out of PLA/ABS.

Thanks! Great work, I really enjoyed your writeup on lost PLA.

I would say it really depends on what the intended use of the mold is. I didn't do sand casting, just investment casting, and it seemed to me that it could handle positives or negatives just fine. I happened to have more than a few test molds from this script laying around, so I gated one up just to see if it burned out in the kiln well. 

I'd say there are advantages to casting a mold negative in metal. For example, with aluminum you may be able to achieve consistent food-safe results, and be able to clean it more easily. 

I also did lost ABS on some objects that were not molds and cast in bronze - but I'm still working on finishing them. Lots of photos here http://www.flickr.com/photos/zenwebb/collections/72157632009788454/http://www.flickr.com/photos/z... :)

Thank you, glad to hear it and to see your work! Oops - I didn't realize until after I wrote that you were the same person that did the lost ABS page. Looks great!

Yeah, I agree with you there is sometimes a need for a cast negative mold, but more often than not casting is used for final cast parts.

By the way, not sure if you know this, but you can use water cooled aluminum molds to cast higher temperature metal parts such as bronze, copper and steel. It would be sweet to add water cooling channels option in your SCAD library.

Before someone lectures me, yes I know water and molten metal is explosive, but the water never comes in contact with the liquid metal unless there is a mold failure (eg not enough water).

Cool! I've actually not done any mold-making or casting before about 3 months ago (I'm exploring this as part of a grad course this semester), so there is much I don't know about it all.

The idea of water-cooling aluminum molds is amazing, I wonder if its possible at the DIY level! Someone needs to make a derivative ASAP ;)

This is extremely awesome! Thanks for the detailed post!