8
$\begingroup$

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

$\endgroup$

1 Answer 1

8
$\begingroup$

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();
}
$\endgroup$
11
  • $\begingroup$ is there any way to create poligon joining splited objects? from first cut facet to second? $\endgroup$
    – eri
    Commented May 7, 2022 at 21:38
  • $\begingroup$ like hull, but using nearest points $\endgroup$
    – eri
    Commented May 7, 2022 at 21:41
  • $\begingroup$ @eri: You could do it by linear_extrude of a projection but that's very slow and subject to nasty numerical stability issues. $\endgroup$ Commented May 8, 2022 at 2:25
  • $\begingroup$ i need same dimentions in 3 stl files, so rotation to XY and back is not good. $\endgroup$
    – eri
    Commented May 8, 2022 at 10:16
  • $\begingroup$ @eri: Why would 90° rotations mess that up? $\endgroup$ Commented May 8, 2022 at 13:55

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .