discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

Cutting a Cylindrical shell

A
adrianv
Sat, Apr 24, 2021 2:13 PM

The cutting shape produced by that code has a sharp corner, which means it
looks OK for the very thin shell in the demo, but doesn't work so well if
the shell is thicker.  This is a result of trying to construct the
non-planar "face" defined by the cutting curve, so the approach may work for
some curves but not so well for others.  It's as if the cutting bit has
turned at a very extreme angle instead of remaining perpendicular to the
cylinder.  The path_sweep example keeps the cutting bit perpendicular and
will work for any curve whose slope stays finite (the normal has a nonzero
component in the z direction).

Note that my example requires <include<BOSL2/std.scad> which I forgot to
include in my post.

This is what the cutting shape looks like from the skin example:

http://forum.openscad.org/file/t2477/cutshape.png

Ronaldo wrote

An alternative approach is to use BOSL2 skin() to make a polyhedron to cut
away the cylinder unneeded part. Oskar Lange's skin() possibly would work
too.

include <BOSL2/std.scad>

r = 10;
h = 20;
module cyl_shell(r,h) {
difference() {
cylinder(r=r,h=h,center=true);
cylinder(r=r-0.1,h=h+.1,center=true);
}
}

n = 50;
a = 3;
cyl_curve = [for(i=[0:n-1]) [rcos(i360/n), rsin(i360/n),
acos(3i*360/n)] ];

cyl_curve_up = [for(p=cyl_curve) p + [0,0,100] ];

//trace_path(cyl_curve, size=.5, closed=true);
intersection() {
cyl_shell(r,h);
skin(1.01*[cyl_curve, cyl_curve_up],slices=1);
}

Em sáb., 24 de abr. de 2021 às 13:23, adrianv <

avm4@

> escreveu:

This approach will work, but it will be very slow.  I think the right
approach is to use a sweep to create the cutting polyhedron.  As you say,
it's hard to construct a polyhedron from the ground up, which is why you
should instead use helper functions to do it.  Many libraries provide a
sweep function such as dotSCAD, Parkinbot's naca sweep, and BOSL2.
Using BOSL2:


OpenSCAD mailing list
To unsubscribe send an email to

discuss-leave@.openscad

The cutting shape produced by that code has a sharp corner, which means it looks OK for the very thin shell in the demo, but doesn't work so well if the shell is thicker. This is a result of trying to construct the non-planar "face" defined by the cutting curve, so the approach may work for some curves but not so well for others. It's as if the cutting bit has turned at a very extreme angle instead of remaining perpendicular to the cylinder. The path_sweep example keeps the cutting bit perpendicular and will work for any curve whose slope stays finite (the normal has a nonzero component in the z direction). Note that my example requires <include&lt;BOSL2/std.scad> which I forgot to include in my post. This is what the cutting shape looks like from the skin example: <http://forum.openscad.org/file/t2477/cutshape.png> Ronaldo wrote > An alternative approach is to use BOSL2 skin() to make a polyhedron to cut > away the cylinder unneeded part. Oskar Lange's skin() possibly would work > too. > > include &lt;BOSL2/std.scad&gt; > > r = 10; > h = 20; > module cyl_shell(r,h) { > difference() { > cylinder(r=r,h=h,center=true); > cylinder(r=r-0.1,h=h+.1,center=true); > } > } > > n = 50; > a = 3; > cyl_curve = [for(i=[0:n-1]) [r*cos(i*360/n), r*sin(i*360/n), > a*cos(3*i*360/n)] ]; > > cyl_curve_up = [for(p=cyl_curve) p + [0,0,100] ]; > > //trace_path(cyl_curve, size=.5, closed=true); > intersection() { > cyl_shell(r,h); > skin(1.01*[cyl_curve, cyl_curve_up],slices=1); > } > > Em sáb., 24 de abr. de 2021 às 13:23, adrianv &lt; > avm4@ > &gt; escreveu: > >> This approach will work, but it will be very slow. I think the right >> approach is to use a sweep to create the cutting polyhedron. As you say, >> it's hard to construct a polyhedron from the ground up, which is why you >> should instead use helper functions to do it. Many libraries provide a >> sweep function such as dotSCAD, Parkinbot's naca sweep, and BOSL2. >> Using BOSL2: >> >> > > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to > discuss-leave@.openscad -- Sent from: http://forum.openscad.org/
RP
Ronaldo Persiano
Sat, Apr 24, 2021 4:19 PM

Theg bit perpendicular and will work for any curve whose slope stays
finite (the normal has a nonzero component in the z direction).

The inclusion of one more section to skin should solve the thickness issue:

include <BOSL2/std.scad>

$fn=90;
r=8;
thickness=1;
h = 20;

module cyl_shell(r,h) {
difference() {
cylinder(r=r,h=h,center=true);
cylinder(r=r-thickness,h=h+.1,center=true);
}
}

n = 50;
a = 3;
cyl_curve  = [for(i=[0:n-1]) [rcos(i360/n), rsin(i360/n),
acos(3i*360/n)] ];

out_cyl_curve = [for(p=cyl_curve) [1.1p[0], 1.1p[1], p[2]]] ;
in_cyl_curve  = [for(p=cyl_curve) [(0.9*(r-thickness)/r)p[0],
(0.9
(r-thickness)/r)*p[1], p[2]]] ;

out_cyl_curve_up = [for(p=out_cyl_curve) p + [0,0,h] ];

//trace_path(cyl_curve, size=.5, closed=true);
intersection(convexity=10) {
cyl_shell(r,h);
skin([in_cyl_curve, out_cyl_curve, out_cyl_curve_up],slices=1);
}

> Theg bit perpendicular and will work for any curve whose slope stays > finite (the normal has a nonzero component in the z direction). The inclusion of one more section to skin should solve the thickness issue: include <BOSL2/std.scad> $fn=90; r=8; thickness=1; h = 20; module cyl_shell(r,h) { difference() { cylinder(r=r,h=h,center=true); cylinder(r=r-thickness,h=h+.1,center=true); } } n = 50; a = 3; cyl_curve = [for(i=[0:n-1]) [r*cos(i*360/n), r*sin(i*360/n), a*cos(3*i*360/n)] ]; out_cyl_curve = [for(p=cyl_curve) [1.1*p[0], 1.1*p[1], p[2]]] ; in_cyl_curve = [for(p=cyl_curve) [(0.9*(r-thickness)/r)*p[0], (0.9*(r-thickness)/r)*p[1], p[2]]] ; out_cyl_curve_up = [for(p=out_cyl_curve) p + [0,0,h] ]; //trace_path(cyl_curve, size=.5, closed=true); intersection(convexity=10) { cyl_shell(r,h); skin([in_cyl_curve, out_cyl_curve, out_cyl_curve_up],slices=1); } >
A
adrianv
Sat, Apr 24, 2021 6:46 PM

That solution does appear OK, though it seems better to just use a circle for
the top instead of the curved profile.  However, having gone that far, why
not just make the entire shape with skin().  Note that this approach only
makes one half of the shape the original poster seemed to be requesting.
This could also be constructed using vnf_vertex_array instead of skin.

include<BOSL2/std.scad>

$fn=90;
r=8;
thickness=1;
len=21;
n=4;
outer_curve = [for(theta=[360:-4:1])
[rcos(theta), rsin(theta), 10+sin(n*theta)]];
inner_curve = [for(theta=[360:-4:1])
[(r-thickness)*cos(theta), (r-thickness)sin(theta),
10+sin(n
theta)]];
skin([inner_curve, outer_curve, path3d(circle(r),len),
path3d(circle(r-thickness), len)], slices=0, closed=true);

Ronaldo wrote

Theg bit perpendicular and will work for any curve whose slope stays
finite (the normal has a nonzero component in the z direction).

The inclusion of one more section to skin should solve the thickness
issue:

include <BOSL2/std.scad>

$fn=90;
r=8;
thickness=1;
h = 20;

module cyl_shell(r,h) {
difference() {
cylinder(r=r,h=h,center=true);
cylinder(r=r-thickness,h=h+.1,center=true);
}
}

n = 50;
a = 3;
cyl_curve  = [for(i=[0:n-1]) [rcos(i360/n), rsin(i360/n),
acos(3i*360/n)] ];

out_cyl_curve = [for(p=cyl_curve) [1.1p[0], 1.1p[1], p[2]]] ;
in_cyl_curve  = [for(p=cyl_curve) [(0.9*(r-thickness)/r)p[0],
(0.9
(r-thickness)/r)*p[1], p[2]]] ;

out_cyl_curve_up = [for(p=out_cyl_curve) p + [0,0,h] ];

//trace_path(cyl_curve, size=.5, closed=true);
intersection(convexity=10) {
cyl_shell(r,h);
skin([in_cyl_curve, out_cyl_curve, out_cyl_curve_up],slices=1);
}


OpenSCAD mailing list
To unsubscribe send an email to

discuss-leave@.openscad

That solution does appear OK, though it seems better to just use a circle for the top instead of the curved profile. However, having gone that far, why not just make the entire shape with skin(). Note that this approach only makes one half of the shape the original poster seemed to be requesting. This could also be constructed using vnf_vertex_array instead of skin. include<BOSL2/std.scad> $fn=90; r=8; thickness=1; len=21; n=4; outer_curve = [for(theta=[360:-4:1]) [r*cos(theta), r*sin(theta), 10+sin(n*theta)]]; inner_curve = [for(theta=[360:-4:1]) [(r-thickness)*cos(theta), (r-thickness)*sin(theta), 10+sin(n*theta)]]; skin([inner_curve, outer_curve, path3d(circle(r),len), path3d(circle(r-thickness), len)], slices=0, closed=true); Ronaldo wrote >> Theg bit perpendicular and will work for any curve whose slope stays >> finite (the normal has a nonzero component in the z direction). > > > The inclusion of one more section to skin should solve the thickness > issue: > > include &lt;BOSL2/std.scad&gt; > > $fn=90; > r=8; > thickness=1; > h = 20; > > module cyl_shell(r,h) { > difference() { > cylinder(r=r,h=h,center=true); > cylinder(r=r-thickness,h=h+.1,center=true); > } > } > > n = 50; > a = 3; > cyl_curve = [for(i=[0:n-1]) [r*cos(i*360/n), r*sin(i*360/n), > a*cos(3*i*360/n)] ]; > > > out_cyl_curve = [for(p=cyl_curve) [1.1*p[0], 1.1*p[1], p[2]]] ; > in_cyl_curve = [for(p=cyl_curve) [(0.9*(r-thickness)/r)*p[0], > (0.9*(r-thickness)/r)*p[1], p[2]]] ; > > out_cyl_curve_up = [for(p=out_cyl_curve) p + [0,0,h] ]; > > //trace_path(cyl_curve, size=.5, closed=true); > intersection(convexity=10) { > cyl_shell(r,h); > skin([in_cyl_curve, out_cyl_curve, out_cyl_curve_up],slices=1); > } > > > >> > > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to > discuss-leave@.openscad -- Sent from: http://forum.openscad.org/