Is there an easy way to split models in OpenSCAD?

4

I'm wondering if I can take one OpenSCAD object, and cut/splice/split it into two different objects that can then be manipulated independently?

One approach is to duplicate the object, difference it along the cut border with a 3rd object, and then difference the result with itself. This seems overly complex and I suspect I'm missing something

PS - the point of this is that I have a nicely designed part where I need to create an interlock. I want to first cut the part in half, and then create some interlock mechanism

Hamy

Posted 2019-06-23T16:59:33.190

Reputation: 223

Answers

4

Rather than differencing a copy of the object from itself, which is subject to numerical instability, choose a box ("cube" in OpenSCAD terminology), and intersect it with one copy of the object, then difference it from the other copy of the object. This is all easy if you use modules to encapsulate your parts, and it also works with imported STL files.

Specifically, it should look something like this:

module mycut() {
    translate([x,y,z]) cube([w,l,h]);
}

difference() {
    myobject();
    mycut();
}

translate([u,v,w])
intersection() {
    myobject();
    mycut();
}

R.. GitHub STOP HELPING ICE

Posted 2019-06-23T16:59:33.190

Reputation: 5 311