[OpenSCAD] 3D model for stamp fabrication
adrianv
avm4 at cornell.edu
Tue Jul 30 17:10:39 EDT 2019
I wrote an offset() function that operates on a list of coordinates. Using
this function you can compute the offset and place the offset points at a
different z, and then use polyhedron to link everything together. It's
sort of messy, though, because of all the internal holes in text. And you
have to have your data in OpenSCAD as a list of values, not as geometry.
It runs in 0s, so no time issues.
<http://forum.openscad.org/file/t2477/star1.png>
<http://forum.openscad.org/file/t2477/star2.png>
Here's a code example:
include<BOSL2/std.scad>
outside = reverse(star(d=10, id=5, n=7));
inside = offset(outside, delta=-1, closed=true);
shrink_outside = offset(outside, delta=-.4, closed=true, return_faces=true);
grow_inside = offset(inside, delta=0.4, closed=true, return_faces=true);
outside_pts = concat(path3d(outside,0),path3d(shrink_outside[0],1));
inside_pts = concat(path3d(inside,-.01), path3d(grow_inside[0],1.01));
outside_faces = concat(shrink_outside[1],
[reverse(list_range(len(outside)))],
[add_scalar(list_range(len(outside)),len(outside))]);
inside_faces = concat(grow_inside[1], [reverse(list_range(len(outside)))],
[add_scalar(list_range(len(outside)),len(outside))]);
difference(){
polyhedron(points = outside_pts, faces = outside_faces,convexity=10);
polyhedron(points = inside_pts, faces = inside_faces,convexity=10);
}
Hmmm. With minkowski() it's going to be hard (impossible?) to avoid
rounding over the source geometry. I took a stab at that, continuing my
example above.
$fn=32;
minkowski(){
linear_extrude(height=.01)
offset(delta=-.4)
difference(){
polygon(outside);
polygon(inside);
}
cylinder(r2=.2,r1=.5, h=1);
}
So that gives rounded edges and takes 16 seconds to run. Actually I had in
my head that I was trying to shrink the shape from the given shape, but
maybe I have it backwards and you want to grow the shape? I also don't
know if you want or don't want rounding. (The above solution can produce
rounding if you want it, but it needs to be reworked to grow the shape
rather than shrink it, or the rounding is on the inside.)
$fn=32;
minkowski(){
linear_extrude(height=.01)
difference(){
polygon(outside);
polygon(inside);
}
cylinder(r2=.2,r1=0, h=1);
}
<http://forum.openscad.org/file/t2477/star3.png>
That's faster, taking 8s.
--
Sent from: http://forum.openscad.org/
More information about the Discuss
mailing list