discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

Re: [OpenSCAD] how to make the groove more width?

P
Parkinbot
Wed, Jan 18, 2017 3:29 PM

I guess you want the groove to keep its shape independently of the twist
angle. This is not so easy to do, because need a /proper/ helix object for
difference. There is some threading code out there (e.g. Thingiverse) to do
this.
With some limitation it can also be created by linear_extrude(), but it
needs an ellipse that exactly compensates the angle introduced by the twist.
The following code introduces an operator doing this and rewrites your code
partly for proper application

$fn= 30;
h = 60;
OR = 12;
r = .5;
g = OR;
tw = 720;  // use negative value for CCW
N=4;

slot();
module slot(groove = true){
difference()
{
cylinder(h,r=OR,center=true);
if(groove){
for(w=[0:N-1])
linear_extrude(height=h+.1, center=true, convexity=2, twist=tw)
rotate([0, 0, w*360/N])
translate([g, 0, 0])
groove_shape(h, tw, OR, r) circle(r=r);
}
}
}

module groove_shape(h=1, twist=0, R, r) // operator module
{
U = R2PI;
x = U/360*twist;
a = atan(x/h);
f = a==0?1:tan(a)/sin(a);
scale([1, f])
children();
}

--
View this message in context: http://forum.openscad.org/how-to-make-the-groove-more-width-tp20154p20158.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

I guess you want the groove to keep its shape independently of the twist angle. This is not so easy to do, because need a /proper/ helix object for difference. There is some threading code out there (e.g. Thingiverse) to do this. With some limitation it can also be created by linear_extrude(), but it needs an ellipse that exactly compensates the angle introduced by the twist. The following code introduces an operator doing this and rewrites your code partly for proper application > $fn= 30; > h = 60; > OR = 12; > r = .5; > g = OR; > tw = 720; // use negative value for CCW > N=4; > > slot(); > module slot(groove = true){ > difference() > { > cylinder(h,r=OR,center=true); > if(groove){ > for(w=[0:N-1]) > linear_extrude(height=h+.1, center=true, convexity=2, twist=tw) > rotate([0, 0, w*360/N]) > translate([g, 0, 0]) > groove_shape(h, tw, OR, r) circle(r=r); > } > } > } > > module groove_shape(h=1, twist=0, R, r) // operator module > { > U = R*2*PI; > x = U/360*twist; > a = atan(x/h); > f = a==0?1:tan(a)/sin(a); > scale([1, f]) > children(); > } -- View this message in context: http://forum.openscad.org/how-to-make-the-groove-more-width-tp20154p20158.html Sent from the OpenSCAD mailing list archive at Nabble.com.
E
eexpss
Thu, Jan 19, 2017 7:26 AM

I catch it. the most import is scale(), so I modify my code simply like this:

if(groove){
for(g=[[OR,0],[0,OR],[-OR,0],[0,-OR]])
linear_extrude(height=h, center=true, convexity=1,
twist=720)translate(g)scale(g[0]==0?[3, 1]:[1,3])circle(r = 0.5);
}

http://forum.openscad.org/file/n20164/2017-01-19_15-24-12%E5%B1%8F%E5%B9%95%E6%88%AA%E5%9B%BE.png

thanks. those trigonometric make me dizzy, so i just add an simple
judgement. lol

--
View this message in context: http://forum.openscad.org/how-to-make-the-groove-more-width-tp20154p20164.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

I catch it. the most import is scale(), so I modify my code simply like this: if(groove){ for(g=[[OR,0],[0,OR],[-OR,0],[0,-OR]]) linear_extrude(height=h, center=true, convexity=1, twist=720)translate(g)scale(g[0]==0?[3, 1]:[1,3])circle(r = 0.5); } <http://forum.openscad.org/file/n20164/2017-01-19_15-24-12%E5%B1%8F%E5%B9%95%E6%88%AA%E5%9B%BE.png> thanks. those trigonometric make me dizzy, so i just add an simple judgement. lol -- View this message in context: http://forum.openscad.org/how-to-make-the-groove-more-width-tp20154p20164.html Sent from the OpenSCAD mailing list archive at Nabble.com.
E
eexpss
Thu, Jan 19, 2017 3:36 PM

Now I find does not need change scale parameter.

for(g=[0,45,90,-45,-90,135,-135,180])//rotate
	for(tw=[720,-720])
linear_extrude(height=h, center=true,

twist=tw)rotate([0,0,g])*scale([1,5])*translate([OR,0])circle(r = 0.5);

http://forum.openscad.org/file/n20168/2017-01-19_23-35-47%E5%B1%8F%E5%B9%95%E6%88%AA%E5%9B%BE.png

--
View this message in context: http://forum.openscad.org/how-to-make-the-groove-more-width-tp20154p20168.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

Now I find does not need change scale parameter. for(g=[0,45,90,-45,-90,135,-135,180])//rotate for(tw=[720,-720]) linear_extrude(height=h, center=true, twist=tw)rotate([0,0,g])*scale([1,5])*translate([OR,0])circle(r = 0.5); <http://forum.openscad.org/file/n20168/2017-01-19_23-35-47%E5%B1%8F%E5%B9%95%E6%88%AA%E5%9B%BE.png> -- View this message in context: http://forum.openscad.org/how-to-make-the-groove-more-width-tp20154p20168.html Sent from the OpenSCAD mailing list archive at Nabble.com.