7

Is there anyway to go about importing STL files into OpenSCAD with the ability to modify them?

For instance, the following code demonstrates what I have tried thus far:

difference() {
    import("spherical_puzzle_base.stl");
    translate([0, 0, -RADIUS/2]) {
        cube([RADIUS*2, RADIUS*2, RADIUS], center=true);
    }
}

When I do this I can either hit F5 to render the STL file only which doesn't include the intersection. Or I can hit F6 to compile and render, but it creates a very messed up rendering, no where near manifold or even close to what I would expect for that matter. Is there a solution to this problem using OpenSCAD? Thanks!

(I am attempting to do it this way to save long rendering times, especially while I am testing various design possibilities)

Jeremy
  • 3,620
  • 9
  • 43
  • 75

2 Answers2

2

I was not sure, whether modifications of stl-models by boolean operations are possible. Boolean operations in openscad are part of csg-modelling. With csg only 'primitive solids' as 'cube', 'sphere', 'cylinder' or 'polyhedron' can be combined.

To verify in openscad 2014.01.29 i tried this:

translate([10,10,0]) polyhedron( points=[ [10,10,0],[10,-10,0],[-10,-10,0],[-10,10,0,[0,0,10]],
triangles=[ [0,1,4],[1,2,4],[2,3,4],[3,0,4],[1,0,3],[2,1,3]]
);

export as 'polyhedron.stl' and then:

difference() {
    import("polyhedron.stl"); 
    translate([5,5,0]) cube([10,10,10]); 
}

i got the correct result (with other, more complex stl too) and i could export them to valid stl-files. Only on screen in openscad some faces seemed to be transparent or damaged. So i think, openscad treats stl-files in boolean operations as 'polyhedron' and you can modify your stl in your way.

a_manthey_67
  • 4,046
  • 1
  • 17
  • 28
0

I agree with @a_manthey_67. I have done boolean operations successfully with the latest OpenSCAD and very complex STL files like Sappho's Head. Rendering takes a very long time, but I have broken a large STL file into numerous pieces with difference and manipulated the pieces with translations and other operations.

Scott Leslie
  • 1,147
  • 9
  • 11