[OpenSCAD] New forum member, extruding along path

gasstationwithoutpumps karplus at soe.ucsc.edu
Mon Jul 29 20:24:46 EDT 2019


Hi, I'm new to the OpenSCAD forum, but I've been using OpenSCAD for about a
year (you can see a few of my rather simple designs at 
https://www.thingiverse.com/gasstationwithoutpumps/things
<https://www.thingiverse.com/gasstationwithoutpumps/things>  ), with more
discussion of them and some unreleased design on my blog at 
https://gasstationwithoutpumps.wordpress.com
<https://gasstationwithoutpumps.wordpress.com>  ).I came to this forum
looking for information on how to do something that I see as one of the
biggest holes in OpenSCAD: extruding along an arbitrary path.  I found out
about sweep.scad in the  list comprehension demos
<https://github.com/openscad/list-comprehension-demos>  , which provides a
somewhat klugey workaround—I have to have a polygon and a polygonal path
expressed as arrays of points (perhaps with an additional array of
orientation vectors), but what I wanted to start with was an SVG file with a
cross-section and an SVG file of the paths.Unfortunately, OpenSCAD can
convert arrays to geometry, but then provides no way to extract the arrays
again from the geometry.  So I can import SVG into OpenSCAD, but not use the
resulting imported objects as either the cross-sectional profile or as the
path.  One of the biggest things on my wish list is a way to get arrays of
points from objects.I found another link to an inkscape plug-in, 
https://www.thingiverse.com/thing:2805184
<https://www.thingiverse.com/thing:2805184>  , that converts SVG files to
arrays of Bézier curves, which almost completes the task.After playing
around with both, I found some minor bugs:The definition of "cap" in
sweep_polyhedron relied on a test of len(caps), which is not acceptable to
the 2019-05 release.  I changed it to 
cap     =  (closed || caps==[]) ? [false,false]:                   
(caps==true || caps==false)?      [caps,caps] :                  
(len(caps)==1) ?         [caps[0], caps[0]] :                    inv ?                   
[caps[1], caps[0]] :                                             [caps[0],
caps[1]]
removing the error message.  There are several other places in the list
comprehension demo code where similar tests relying on len(non_list) being
legal and returning undef are used, but that "feature" seems to have been
deprecated.For the inkscape plugin, I ran into two problems:  
 One was that a group scaling in my SVG file got applied twice so that the
cross-sectional profile was 96/25.4 times larger that it should have been. 
Luckily this could be compensated for by scaling the output arrray, and
OpenScad makes multiplying an array by a constant easy.
A bigger annoyance was that the output created a polygon for each path in
the SVG file, when many of the paths were open paths.  I had to edit the
output code to make functions that returned the bezier_coordinates for each
array of points, rather than making a union of the bezier_polygons in a
module.  Then I could use the points (with to_3d() and
referenced_path_transforms()) to do a sweep.I'd like for the Inkscape plugin 
to create those functions for me, so I can just "use" the output .scad file
without having to edit it.
I managed to get everything sort of working, but I still have some minor
problems:
If the number of steps in bezier_coordinates() is too high, then the tangent
computations at the end of the path end up producing "undef", and an ugly
artifact is created at the end of the path.  I think that this may be
related to OpenSCAD rounding to a coarse grid, so that multiple points in a
row are identical and the tangent is indeed undefined.  I fixed this problem
by keeping the number of steps small (6 was ok, 10 was too many for the
curves I was using).
The CGAL interpretation failed, probably because the tubes produced by the
sweep were not capped, and I had not buried the ends of all of them in other
geometry.  I can probably fix this by more careful placement of the end
points.
I would like to thank the creators of the list comprehension demos and the
Inkscape plugin, because I certainly would not have had the patience to
create them myself.  I hope that sometime soon extruding along a path
becomes a built-in to OpenSCAD, and that the language is extended so that
paths can be turned into arrays of points.



-----
gasstationwithoutpumps.wordpress.com 
www.thingiverse.com/gasstationwithoutpumps/things 
--
Sent from: http://forum.openscad.org/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscad.org/pipermail/discuss_lists.openscad.org/attachments/20190729/78277b41/attachment.html>


More information about the Discuss mailing list