TLDR; I've been trying to work with stl files, and am finding that openSCAD
just can not really do this. Is there something I can do to make it work
better, or an alternative to openSCAD that uses a similar approach, but
might work better?
What I find is that doing even simple boolean operations takes a very long
time. My workaround right now is to use MeshLab to simplify a mesh down to
<30,000 vertices (low enough to visibly diminish the quality of a 3d print).
Even then rendering takes 30+ minutes.
I just wanted to make a simple procedural way to split a model for 3D
printing, and add aligning pins (something like this
https://blog.prusaprinters.org/cut-stl-models-3d-printing-meshmixer/ ).
My solution works well, other than requiring me to reduce mesh quality and
taking forever. It is the 'cut' module in the following code. The stl file
just needs to be imported, centered by hand (because I can't figure out a
way to center it using openSCAD - seems like a bit of an oversight) and
oriented. Then the 'cut' module cuts the model in half, cuts out a pair of
alignment holes, and flips the bottom half up. I then make a couple of
pentagonal pins for aligning (these actually work well with 0 tolerance -
makes for a nice compression fit). I've tried this with a couple meshes (an
elephant and a giraffe from different sources). I had to reduce the vertex
count on both by a factor of 10-100 before the code would run in less than
an hour.
s = 0.05 // A small number
// Connector module
// r -> radius
// h -> height
// cutout = true -> makes a steeper cone on top to avoid an overhang when 3d
printing
// should be set to ture when using connector as a negative object
(i.e. a cutout)
// cutout = false -> makes a shallow cone on pin so it can slide in more
easily
// alignment pin should be generated with $fn=5 or 6
module connector(r, h, center=false, cutout=false){
translate([0,0,center?0:h/2])
hull(){
cylinder(r=r, h=h*.8, center=true);
cylinder(r1=s, r2=s, h=cutout?h/sin(40):h, center=true); // overhang
angle =40
}
}
module cut(t=100){
for (i=[0,1])
translate([it/2,0,0])
rotate([180i,0,0]) difference(){
children([0]);
translate([0,0,-t/2+ti]) cube([t,t,t], center=true); // Main cut
translate([connR2,0,0]) connector(connR,connH, true, true); // Pin
1 hole
translate([-connR*2,0,0]) connector(connR,connH, true, true); // pin
2 hole
}
}
// Make the cut
cut(200){
resize([100,0,0], true)
rotate([5,-15,0]) translate([55,-5,-120]) import("elephant.stl",5);
}
// Create pentagonal connectors
connRI = connR-tolerance;
for (i=[0,1])
translate([connR4i,50,connRI*cos(180/5)]) rotate([180,0,0])
rotate([90,90,0]) connector(connRI,connH-tolerance, true, false, $fn=5);
--
Sent from: http://forum.openscad.org/
On 2019-06-06 15:37, argentum2f wrote:
TLDR; I've been trying to work with stl files, and am finding that
openSCAD
just can not really do this. Is there something I can do to make it
work
better, or an alternative to openSCAD that uses a similar approach, but
might work better?
You can try AngelCAD, it is generally faster
https://arnholm.github.io/angelcad-docs/ . You cannot import STL files
directly, but the latest version contains a separate console program
'polyfix' that can heal and convert from STL to e.g. OBJ format, so you
can do this first:
polyfix yourmodel.stl -out=*.obj
This creates yourmodel.obj, which can be imported:
solid@ yourmodel = polyhedron("yourmodel.obj");
Then you can compute intersections or differences to cut it into parts
and export to new files, including STL.
Carsten Arnholm
Do you have a representative stl file you can share?
Pre & post Meshlab.
Admin - email* me if you need anything, or if I've done something stupid...
Unless specifically shown otherwise above, my contribution is in the Public Domain; to the extent possible under law, I have waived all copyright and related or neighbouring rights to this work. Obviously inclusion of works of previous authors is not included in the above.
Sent from: http://forum.openscad.org/