Revolve2 OpenSCAD library module
di DarioPellegrini
File stampabili (1)
-
stlrevolve2_demo.stl
3.2 Mo · 1 794 download
Descrizione
Better stability, clarity and added functionalities.
If you liked Revolve, you will love Revolve2!
IntroductionThis OpenSCAD module allows for rotational extrusion of generic user-defined profiles,
introducing a pitch in the longitudinal direction, the most common application being
the creation of screws.
The solid is built as a single polyhedron by transforming the 2D points found in the
profile vector. No boolean operation is necessary, aiming at obtaining the ultimate
performance by producing the simplest possible object for the desired level of detail.
revolve(profile = [[]], length, nthreads=1, scale=1, preserve_thread_depth=false, preserve_thread_shape=false, $fn=$fn, force_alternate_construction=false)profilevector of 2D points defined as: [[z_1, f(z_1)], [z_2, f(z_2)] ... [z_n,f(z_n)]].
f(z) is defined over a closed interval (including the extremes) representing one period of the thread; it describes the shape of the thread with no fundamental restriction, that means that a square profile can be defined exactly, with points sharing the same $z$. Dovetail-like profiles are also possible.
The shape of the profile can be made finer by adding more points. Thelinspacehelper function might be used to create the profile from a mathematical function (see example below).lengthhow far to go in the longitudinal direction, note that the mesh size increases linearly with this parameter.nthreadsallows the creation of screws with multiple threads, it should be an integer. Negative values are also accepted, generating left threads.nthreads=0results in no pitch, similar torotate_extrude.scaleenable scaling in the longitudinal direction: the top faces will be scale-times larger than the bottom one. Similar to scale in linear_extrude, however this only accepts a scalar value in the interval ]0, +inf[.preserve_thread_depthallows preserving the depth of the thread which otherwise may be "flattened". Only useful ifscale!=1.preserve_thread_shapeallows preserving the shape of the thread. Whentrue, it overridespreserve_thread_depth. Only useful ifscale!=1.$fn: the number of subdivisions in the angular direction, similar to$fnfor a cylinder. In the longitudinal direction the number of subdivisions is controlled directly by the number of points in the profile. Note that if this parameter is too small, it might be necessary to cut the thread faces, this will be accomplished by triggering the alternate construction.force_alternate_constructionThe alternate construction allows for properly cutting the top and bottom faces when these intercept the thread. This is typically needed when the number of angular steps is small and/or the number of threads is large and/or depending on the thread profile. The switch to the alternate construction is handled automatically (an info message is echoed when this happens). If you know that your design will need the alternate construction, you may force it here making the code slightly faster.
// The simplest possible example:revolve(profile=[[0,5],[1,6],[2,5]], length=10, nthreads=1, $fn=8);// Now going a bit wilder// Define a sinusoidal profile function...period = 3;function prof_sin(z) = [z, 10+sin(z*360/period)];// ...which becomes a profile vector with the help of linspacesin_prof = [for (z=linspace(start=0, stop=period, n=15)) prof_sin(z)];translate([30,0,0])revolve( sin_prof, length=20, nthreads=-5, $fn=30);// Using the scale functionality// A square profile defined manuallysqr_prof = [[0,11],[2,11],[2,9],[4,9],[4,11]];intersection() { translate([-20,10,-10]) cube([20,100,50]); union () { color("red") translate([0,30]) revolve( sqr_prof, length=30, scale=0.2, nthreads=-1, $fn=30); color("blue") translate([0,60]) revolve( sqr_prof, length=30, scale=0.2, preserve_thread_depth=true, nthreads=-1, $fn=30); color("green") translate([0,90]) revolve( sqr_prof, length=30, scale=0.2, preserve_thread_shape=true, nthreads=-1, $fn=30); }}// To reproduce the sample STL:// revolve_demo_scene();LicenceThis OpenSCAD module was written by Dario Pellegrinipellegrini dot dario at gmail dot com
It is released under the Creative Commons Attribution (CC BY) licence v4.0 or later.
https://creativecommons.org/licenses/by/4.0/
2018/11/14 Released v2.0 - code almost entirely rewritten, for better clarity, stability, performance and added functionalities.
2018/11/09 Released v1.0