Hello everyone,
I am trying to replicate a model I have created in Rhino + Grasshopper in
OpenSCAD (see image below).
http://forum.openscad.org/file/t2488/Twisted_ripple.png
The model has a few features I can control by changing a parameter.
These include:
In Grasshopper I constructed the model by creating an array of alternating
bigger and smaller cross-sectional squares and creating a loft surface
through each of them.
When I want to change one of the mentioned features I do the following:
I used the same approach in OpenSCAD, quickly discovering that lofting is
not as easy as it seems. Needless to say, I didn't get very far and this is
my current result:
http://forum.openscad.org/file/t2488/Twisted_ripple_OpenSCAD.png
I feel like OpenSCAD has a pretty steep learning curve so I am turning to
this forum looking for some tips on how to proceed.
I welcome all advice.
ASchout
--
Sent from: http://forum.openscad.org/
Certainly, it is feasible.
If I understood well you image, to make the loft I would place a sphere (or
ellipsoid, or cube, or octahedron) at each corner and hull() them two by
two for each square edge.
To twist, rotate() followed by a translate() should be enough. The spacing
would be controlled by the amount of the translations.
Here's a quick stab at it. It's hard to tell exactly what you want. It looks
like you might want straight-sided areas between the rounded parts, so
that's what I used.
I used the BOSL library, available at https://github.com/revarbat/BOSL
https://github.com/revarbat/BOSL
use<bosl/shapes.scad>
for (a =[0:15])
rotate([0,0,a3])
translate([0,0,a4.5])
tier();
module tier() {
union () {
cube([46,46,2],center=true);
translate([0,0, 2.999])
cuboid([50,50,4], fillet=1.999, $fn=30);
}
}
Takes about 1.5 minutes to render on my PC.
--
Sent from: http://forum.openscad.org/
Hi lar3ry,
Thanks for giving me some example code. I can tell you have made an object
tier which is a union of a cube and a cuboid. Even though I have added the
BOSL library to my libraries I can not get it to render. For some reason I
just get a stack of cubes and the cuboids seem to be missing (see image
below)
http://forum.openscad.org/file/t2488/Twisted_ripple_lar3ry.png
For some clarification, here is a gif I made from my Rhino+Grasshopper
model:
https://media.giphy.com/media/fBPIo9SyemqLZiKbDr/giphy.gif
https://media.giphy.com/media/fBPIo9SyemqLZiKbDr/giphy.gif
I am not trying to exactly replicate it but I would like the ripple in the
side faces to approximate a sinusoid.
--
Sent from: http://forum.openscad.org/
If this project is your entrance to OpenSCAD you have chosen a very ambitious
problem that can't be tackled with the usual means of OpenSCAD.
linear_extrude() is not equipped for extruding objects with varying
diameter. It can do twist and a scale but the latter is a linear function it
calculates on its own. You want to specify a scale function.
Of course, your problem has a solution in OpenSCAD if you draw on an
advanced techique (and library) that lets you do almost every thing you want
The following code is fairly simple and does everything you need. You can
reimplement the shape function to have rounded corners and so on. I omitted
this to keep the example simple. The gen() function creates the polygon
sequence in a linear-extrusion fashion and is called twice to generate the
outer and the inner wall in the same fashion, but with opposite diameter
modulation. sweep() does the coating. You can find the lib by following the
Thingiverse link. I have updated the file right now to get rid of some nasty
RC3 warnings. The lib is quite rich and to find out what it else offers you
can call its help function help_Naca_sweep() and of course have a look into
the code and the thingiverse projects connected with it. Note that the
parameter closed=true tells sweep() to extrude a ring. You set it to false
if you extrude to a monolith only.
http://forum.openscad.org/file/t887/costower.png
use <Naca_sweep.scad> // https://www.thingiverse.com/thing:1208001
N=50;
R=100;
r=8;
h=100;
f=3;
twist=20;
edges=4;
sweep(concat(gen(N, R), gen(N, R-3*r, false)), close = true);
function gen(N=100, R=R, outer=true) =
[for(i=outer?[0:N]:[N:-1:0])
let(s=outer?-1:1) // sign
let(a=360f/Ni) // angle
let(r=R+srcos(a)) // diameter
let(tz=h/Ni) // z-height
let(rz = twist/Ni) // twist
Rz(rz, shape(r, tz))]; // create polygon and rotate
function shape(r=100, z=0, N=edges) =
[for(i=[0:N])let(w=360/Ni) [rsin(w), r*cos(w)
--
Sent from: http://forum.openscad.org/
Hmm, the code got snipped. Here in full.
use <Naca_sweep.scad> // https://www.thingiverse.com/thing:1208001
N=50;
R=100;
r=8;
h=200;
f=5;
twist=20;
edges=4;
sweep(concat(gen(N, R), gen(N, R-3*r, false)), close = true);
function gen(N=100, R=R, outer=true) =
[for(i=outer?[0:N]:[N:-1:0])
let(s=outer?-1:1) // sign
let(a=360f/Ni) // angle
let(r=R+srcos(a)) // diameter
let(tz=h/Ni) // z-height
let(rz = twist/Ni) // twist
Rz(rz, shape(r, tz))]; // create polygon and rotate
function shape(r=100, z=0, N=edges) =
[for(i=[0:N])let(w=360/Ni) [rsin(w), r*cos(w), z]];
--
Sent from: http://forum.openscad.org/
On 12/03/2019 15:45, ASchout wrote:
I used the same approach in OpenSCAD, quickly discovering that lofting is
not as easy as it seems.
This is true, but it's not impossible.
I use functions to generate polygons as lists of points, then use list comprehensions to create all the coordinates for a solid shape, and then use a skin() function to "wrap" the shape in polygons.
Here is a rounded prism library that I recently created that uses these techniques.
https://www.thingiverse.com/thing:3452536
My (incomplete) fireflash takes things further by using splines to create objects from my control points, and also "probing" the points of the object to attach other objects. None of this is easy, and it could be argued that the CSG side of OpenSCAD is being ignored or shunned, but I do then use a lot of binary ops to chop up the object for 3D printing.
https://www.thingiverse.com/thing:2362589
Oh, and this funny "plectrum" shape might also be of interest.
https://www.thingiverse.com/thing:3445308
Hope this helps.
ASchout wrote
Hi lar3ry,
Thanks for giving me some example code. I can tell you have made an object
tier which is a union of a cube and a cuboid. Even though I have added the
BOSL library to my libraries I can not get it to render. For some reason I
just get a stack of cubes and the cuboids seem to be missing (see image
below)
Are there messages about being unable to find the library file? Most likely
you have not placed the library where OpenSCAD can find it, or used the
right path in the "use" statement. The simplest thing (to just get it
working) is to put the library in the directory with your code and make sure
that your use statement leads to a file that exists.
The method here will not give you a sinusoidal ripple but rather circular
arcs, so it sort of approximates what you want, but to really get it right
you need to use the more sophisticated sweep approach Parkinbot posted.
--
Sent from: http://forum.openscad.org/
Hi Parkinbot,
Thanks for putting your modeling approach in such clear writing. I agree
that my first project might be somewhat ambitious but that makes it more
interesting right? :)
Your library and example certainly is of great help. I will play around with
it a little bit while getting to know the openSCAD way-of-thinking and
syntax.
I know this is off topic and if this belongs in a different thread please
say so but I have have some problems loading in the libraries. I get the
following error.
ERROR: Parser error in line 94: syntax error
WARNING: Failed to compile library
'C:\Users\myName\Documents\OpenSCAD\libraries\nSpline/Naca_sweep.scad'.
Module cache size: 1 modules
Compiling design (CSG Tree generation)...
WARNING: Ignoring unknown module 'sweep'.
It seems weird that it fails to compile the library even though it is
pointing to its exact location.
I have tried the following things to get it to work:
All of these attempts were based off of other forum posts but none of them
lead to anything.
Any ideas?
--
Sent from: http://forum.openscad.org/
Thanks for your feedback, which tells me that you are using an older version
of OpenSCAD. Which version are you using? Please try with the newest RC3
snapshot from http://www.openscad.org/downloads.html#snapshots . My library
is updated to use it.
Background: They have changed OpenSCAD a lot with the last release
candidates. You get thousands of warnings on code that worked with older
versions, and to get rid of these warnings you have to use new functions
that break older versions. I look forward to the day they bring out a new
stable version.
--
Sent from: http://forum.openscad.org/