Carving up a model to preview parts using OpenSCAD

If you’re working on a large 3D model, you know that they can take hours to print. But what if you want to preview part of the model without printing the whole thing? This post explains one way to do that using OpenSCAD and 3DMake. Using this technique, you can “cut off” a portion of the front, back, sides, top, or bottom of the model, leaving only the portion that’s in a particular bounding box you choose. You can then print these sub models

To use this technique, you’ll need an STL file you want to examine, OpenSCAD, and something that can measure an existing STL fil for you. 3DMake version 0.4.1 or later can do all of these things.

First, you’ll download this SCAD file template. Fill out the path to the STL file, and the model’s size and center. You can get the size and center from 3dm info on the STL file.

Then edit the bounds section of the file (the first line begins with left_bound). For example, let’s say you wanted to cut off the left 2 centimeters of the model, and the bottom 10 centimeters. You’d use bounds like this:

left_bound = mm_from_left(20);
right_bound = mm_from_right(0);
front_bound = mm_from_front(0);
back_bound = mm_from_back(0);
top_bound = mm_from_top(0);
bottom_bound = mm_from_bottom(100);

Notice that mm_from_SIDENAME(0) for a given side won’t cut anything off of that side. That will be your default value for each bound. It’s very important to use the function corresponding to the correct bound, or you’ll get weird results.

You can also use the percentage functions percent_from_SIDENAME() in place of mm_from_SIDENAME(). For example, if you wanted to cut off the right 30% of a model, and the top 10% of the model, you’d set bounds like this:

left_bound = mm_from_left(0);
right_bound = percent_from_right(30);
front_bound = mm_from_front(0);
back_bound = mm_from_back(0);
top_bound = percent_from_top(10);
bottom_bound = mm_from_bottom(0);

Once you’ve set this, simply render the model (or use 3dm build). By honing in on a particular area of the model that you’re working on, you can quickly iterate and print more copies. Since this is all in text, you can even save the bounds as different named files (e.g. “model_head.scad” or “facade.scad”), so you can go back to previewing that part of your model later.

Just be aware that some chunks of a print may have trouble. If you turn a bridge (an unsupported area of plastic between two walls) into an overhang (an unspported area sticking out from one side), you may have your print may sag or fall over. You may need to use supports when printing a chunk of a model even if the overall model didn’t require supports.

by Troy