[ANN] pyopenscad spline-surface generator

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[ANN] pyopenscad spline-surface generator

lkcl
hi, apologies this is not exactly in standard software libre release format, it's an extremely unusual use-case so i am not spending time unnecessarily, but am simply making people aware of this in case it proves useful to one or more people:

http://hands.com/~lkcl/eoma/kde_tablet/3dcase/spline.py
http://hands.com/~lkcl/eoma/kde_tablet/3dcase/polysurface.py
http://hands.com/~lkcl/eoma/kde_tablet/3dcase/pyopenscad.py
http://hands.com/~lkcl/eoma/kde_tablet/3dcase/pyopenscadobj.py
http://hands.com/~lkcl/eoma/kde_tablet/3dcase/pyscadutil.py

a quick demonstration of what this can do is here:

http://hands.com/~lkcl/eoma/kde_tablet/3dcase/morph.py
http://hands.com/~lkcl/eoma/kde_tablet/3dcase/morph_example.png

polysurface.py basically takes a list of lists of 3D points, a thickness (as a scalar - this used to be a vector), and creates a 3D "surface" of the specified thickness.  the improvements made yesterday are that for each and every single point defined on the surface an orthogonal vector is calculated.  the previous version a fixed vector was simply... added: this proved completely unsatisfactory.

additional improvements are that the surface-generating function takes parameters to "close" (loop) the surface in either X or Y.

the "morph" example starts from a circle and progressively goes through a series of rectangles.  the general idea is to create a 3D printer fan nozzle which has laminar flow characteristics, by guaranteeing that the area of the shape is always the same at each height.

it's by no means perfect: the better way to do this morphing example would be to have one spline per "quadrant" and to re-join each list-of-lists after spline post-processing.

it's also worthwhile noting that the spline function is an *optional* step.  if you happen to have an arbitrary list of lists of 3D points you can call the polysurface function *without* needing to pass it through the spliner.

the general applications of polyspline are to be able to easily create complex smooth-surfaced hollow objects with a uniform thickness.  openscad, because it is in effect a shim on top of (only) the capabilities of CSG, is... completely lacking in such features, which makes it very difficult to do decent 3D-printed shapes that do not have artefacts at angled corners, requiring that the user go to extraordinarily lengths to add cylinders to all objects at absolutely every single corner.

this practice of adding cylinders at each and every single corner gets extremely tiresome and becomes extremely cumbersome beyond a certain point, and is near-impossible to contemplate in 3-dimensions (truncating and stretching of spheres at each corner?? making sure that they're overlapping of *six* other primitive shapes by 0.001?? and that's just for a rectangular box which implicitcad can do with a single "radius" parameter to union()!) hence the need for this function, which can be used as the basis for creating curved hollow boxes, shape-morphing objects and much more.

however... it's written in python (which is the correct place to do such complex programming given that python is a modern NP-complete OO language) and this requires a mind-shift *away* from thinking in terms of writing in actual openscad (which is a macro system not really a language), using openscad for (non-human-readable) machine-code / assembler-level output and a 3D "viewer" only.  hence the reason why i am not packaging this software up as i have not yet encountered anyone else actually using pyopenscad!  regardless i am making people aware of it, in the hope that it is useful to at least one other person.