Parametric two-part mold generator for OpenSCAD

by jasonwebb, published

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

Featured Thing!


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:
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:

Recent Comments

view all

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)

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!

More from Art Tools

view more


Liked By

view all

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


Prepare a model to create a mold from
To create a two-part mold using these scripts, you first need to prepare an STL model of your choice. OpenSCAD has some performance limitations when it comes to loading external STL files, so keep your polygon counts as low as you can. I like to use Meshlab's "Quadric Edge Collapse Decimation" filter (under the "Remeshing, Simplification and Reconstruction" section) to reduce the number of faces in more complex models to get them to load in OpenSCAD.
Avoid undercuts and overhangs in your model, as this mold-making process doesn't really allow for that.
Using the scripts

  1. Download one of the .scad files and open it in OpenSCAD.
  2. Update the parameters in the script to point to your model, as well as transform it to be suitable for printing.
  3. Compile and Render (F6) the script with your updated parameters.
  4. Grab an STL using the "Design > Export as STL" tool.
    Guide to parameters
    • Model parameters - external STL model to build mold around. Use the rotation, translation and scale parameters to orient your model relative to the mold.
    • Mold parameters - attributes of the mold itself. Make it any size you want, and turn on or off rounded corners to help with printability.
    • Key parameters - attributes of the registration marks to get the halves to fit together well.
    • Pour hole parameters - attributes, translation and rotation of the pour hole so you can get material into the mold. This can be tricky, so take your time to experiment.
      Slicing your mold
      In my experience, the resulting OpenSCAD models are very tolerant of a wide range of slicing settings. I like to keep the infill down around 20%, and opt for only 1 shell, if any. A layer height of around 0.15mm works well for me. Larger layer heights can result in gaps in the inner mold form which can make it more difficult to cast.
      Printing your mold
  5. Be sure to seal your bot against drafts if using ABS. I faced a lot of layer separation issues in the beginning.
  6. Make sure your build platform is level! If its not, you may see bowing or warping in your mold.
  7. Accurately measure the diameter of your filament and update it your slicing engine. I experienced some pretty severe delamination / layer separation issues on the outer walls of my early molds before I did this.
    Finishing your mold
    Depending on slicing settings, you may end up with a mold that is not completely watertight. I had small gaps in some of my molds that let water seep into the mold form and made it hard to cast anything. A quick spray or brushing of polyurethane fixed that right up for me, but obviously this makes any kind of food casting a bad idea.
    Using your mold
    After applying a release agent, use wood clamps or strong rubber bands to hold the two mold halves together. If needed, apply modeling clay to the seam just to be sure that nothing leaks out.
    Casting tips
    I have had very good success with using Knox gelatin to create flexible casts from my molds, but that is by no means the extent of what can be used. Here is a short list of ideas to try:
    • Knox / Jell-O gelatin
    • Ice
    • Hard candy
    • Chocolate
    • RTV silicone (try Oogoo)
    • Plaster
      Try holding a small popsicle stick right in the middle of the pour hole during casting to create fun lollipops and chocolate treats!
      Don't try to consume any of the castings you produce from these molds! The food safety of ABS / PLA is not really clear, so please just try to use these molds for experimentation, rather than food production.

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:

http://www.ncbi.nlm.nih.gov/pubmed/7737601http://www.ncbi.nlm.nih.gov/pu... "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. http://www.thingiverse.com/thing:12061http://www.thingiverse.com/thi... 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!