Loading

Poor man's openscad screw library

by aubenc, published

Poor man's openscad screw library by aubenc May 25, 2011

Featured Thing!

Description

Update:
Due to some bugs in the initial version, a revision of the OpenSCAD library has been uploaded, please use "polyScrewThread_r1.scad". Thanks a lot to mechadense for reporting the bugs!

This is my humble take on a screw library to be used in your OpenSCAD scripts.

If you are serious, please be, you'll better use thingiverse.com/thing:8793 syvwlch.

Anyway, I had this thing for months in the lost projects folder suffering from some serious issues, well some of them remain (it doesn't render) and once the dust has been shaken it compiles quite nice and printable things.

Instead of functions, this thing uses loops.
Instead of rotate polyhedrons, this thing draws the polyhedron in a new set of points.

Just a couple of comments to help using this thing:

- I've found that a resolution of something like 1.5mm (PI/2 is what I use the most) works very well for threads that will be used with nuts made with a resolution of 0.5mm.

- I've printed the threads with a very low infill (0.2) but for the nuts, setting up this value (I've used 0.45) helped a lot with the overhang issue.

More pics @ aubenc.imgur.com/screws_threads_an_other_polyhedron_games

Recent Comments

view all
Yes, the parameters are explained.... somewhere.........
Tip: take a look to the 3rd line of the text in the instructions tab ;-)
is there an explination of what each of your variables mean? or better yet, attach parameter input to stl output letting me screw (HA!) around with it myself?
Mmmmm... no, there's not. Sorry for that, this is just a very simple library to make basic shaped threads.
You may have better luck (?) with the library by syvwlch which is mentioned in the description...

More from Engineering

view more

Liked By

view all

License

Public Domain
Poor man's openscad screw library by aubenc is licensed under the Public Domain license.

Give a Shout Out

If you print this Thing and display it in public proudly give attribution by printing and displaying this tag. Print Thing Tag

Instructions

Do not use "polyScrewThread.scad", in contains some bugs! Instead...

Drop "polyScrewThread_r1.scad" into your OpenSCAD library folder or the folder where you are writing your OpenSCAD script.

Use polytests.scad (*) as a user's guide, refference, whatever.

(* - Depending on how old/new is your OpenSCAD you may need to change the line where the library is included, replace "include" by "use")

Because this thing is made without much science, you'll need to tweak a little bit, sorry...

First print a nut (high res, see comments above), tweak the infill and/or the degrees for the shape of the thread.

Once your nut prints fine, print a short threaded rod, try to change the resolution of the thread, infill,... use your imagination.

I printed the provided examples and they all work fine without any cleaning, that's the reason why they look so ugly in the pictures.

Design bolted things.

Print bolted things.

Bolt things.

Keep on bolting!
is there an explination of what each of your variables mean? or better yet, attach parameter input to stl output letting me screw (HA!) around with it myself?
Yes, the parameters are explained.... somewhere.........
Tip: take a look to the 3rd line of the text in the instructions tab ;-)
Is there any way to make a conical screw? Something I can use to drill sand.
Mmmmm... no, there's not. Sorry for that, this is just a very simple library to make basic shaped threads.
You may have better luck (?) with the library by syvwlch which is mentioned in the description...
how i can make 5/8"-11 hex screw? im not understand :(
Unfortunately you can't. Sorry for that.
You could do it by writing your own OpenSCAD script and using this thing as a library to help (?) with the threads. It is not a straight forward process wich is roughly described down in the comments.
Thanx, I used it to create a small M3 bolt. Didn't run very smooth but the thread is just enough to get a metal nut over it.
Thanks to you for using it!
M3 is quite a challenging size to be printed. Did you just use the OpenSCAD "as is" or as a library? I mean, this script is not meant to produce ISO thread profiles (there's a turnaround somewhere down in the comments).
Nice small M3 screw, thanks for uploading the pic!!
Hi,
I tried to create a standard photography equipment screw (1/4'' UNC).
By comparing the output to an actual screw I found that I have to input 30° to actually get 60° flanks opening angles.
But anything below 31° crashes OpenSCAD. Wonder what's happening here.
Here are the parameters I tried:
hex_screw(25.4*1/4,25.4/20, 30 ,6,0.5,2,25.4*7/16-0.15,4,3, -1);
There is indeed a (few) bug(s) in the original library, please use the "_r1" version, it works fine for me with your code.

Together with the bug fix, I have changed the way the head of the screw is done, check it out! (it is still possible to use the "old shape" using "hex_screw_0(... )" module).

Nice screw btw!!

I have done a full cycle test: it renders, it compiles, it slices, it prints and it fits the screw mount in my cameras without issues! I can wait to see it uploaded so I will be able to click the "made one" and post the photo.

Thanks again
Wow that was quick.
It works Gr8 now :)
I was a bit afraid it wouldn't print because of the rather brutal overhangs, but I guess for a small diameter 1/4'' screw the small circle inward pulling forces counteracts that problem a bit.

I too did some mods on the screwhead I also chipped away a bit from the vertical edges. Sorry for letting you do the same work by not telling. Heres what I did: (i did cut away a little too less i think)

module hex_head(hg,df) // modified
{
intersection()
{
cylinder(h=hg, r=df/2/sin(60), $fn=6, center=false);
cylinder(h=hg, r=df/2/sin(60)*0.97, $fn=60, center=false);
cylinder(h=2*hg, r1=df/2/sin(60)*0.9+hg, r2=df/2/sin(60)*0.9-hg, $fn=60, center=false);
translate([0,0,hg]) scale([1,1,-1])
cylinder(h=2*hg, r1=df/2/sin(60)*0.9+hg, r2=df/2/sin(60)*0.9-hg, $fn=60, center=false);
}
}
Nice! Smoothing sharp edges is always good.

However :))) for hex bolt-heads/nuts I like to let them sharp because tools have better grip, just my personal taste.

I tried your changes and they where not working, I just used hex_head(8,13). The reason was one of the computed values going into the negative realm... (6,13) worked like a charm.

I will not change the code again, if you like, you may take this other approach for the smoothing:

module hex_head(hg,df)
{
rd0=df/2/sin(60);
rd1=rd0-0.25;

x0=0; x1=df/2; x2=rd1;

y0=0; y1=rd0-(df/2); y2=hg-y1; y3=hg;

intersection()
{
cylinder(h=hg, r=rd0, $fn=6, center=false);

rotate_extrude(convexity=10, $fn=6*round(df*PI/6/0.5))
polygon([ [x0,y0],[x1,y0],[x2,y1],[x2,y2],[x1,y3],[x0,y3] ]);
}
}

...just decrease/increase the 0.25 in rd1 to decr/incr the smoothing
Jep, I recognized that <0 problem right after posting - stupid me :)
Well, I'm afraid I did the same: too quick! :( :)

My changes as in the "_r1" version should work but may have unwanted results if the thickness of the hex block is too small :(
...and...
the code in the comment above will just fail in the same circumstances (thin hex block).

Anyway, this is an old thing asking for some changes, it was done when a 45 degs overhang was possible but not so easy and "fine res" was about 0.35mm for the layer height.

I may come soon with a customizer friendly new thing (from end to end)
Wow that was quick.
It works now :)
I was a bit afraid it wouldn't print because of the rather brutal overhangs, but I guess for a small diameter 1/4'' screw the small circle inward pulling forces counteracts that problem a bit.

I too did some mods on the screwhead - I also chipped away a bit from the edges. Sorry for letting you do the same work by not telling. Heres what I did:

module hex_head(hg,df) // modified
{
intersection()
{
cylinder(h=hg, r=df/2/sin(60), $fn=6, center=false);
cylinder(h=hg, r=df/2/sin(60)*0.97, $fn=60, center=false);
cylinder(h=2*hg, r1=df/2/sin(60)*0.9+hg, r2=df/2/sin(60)*0.9-hg, $fn=60, center=false);
translate([0,0,hg]) scale([1,1,-1])
cylinder(h=2*hg, r1=df/2/sin(60)*0.9+hg, r2=df/2/sin(60)*0.9-hg,$fn=60, center=false);
}
}
hmmmmm... curious... I tried myself and got the same results, aaaargh!!
I'll take a look see what happens here.
Sorry for the trouble and thank you very much to report this!
mayb i'm not getting somthing - the model does not compile

do you have a example parameters for how to call the functions.

just to get it started?
polytests.scad contains some examples. It's true that this thing doesn't render (or not nicely) and may take some time to compile but when you get used to it, it works quite good :-D
Neat, I'll give that a try. I haven't had a chance to try the 0.75 pitch (that might be too aggressive), but I did print a 1.27mm pitch from your libarry with SLS, and that part actually turned out great.
You might want to take a look at these modules for creating ISO-standard threads: dkprojects.net/openscad-threads

If they work well enough perhaps they could be combined with your modules.
I couldn't seem to get your english_thread_tap to work...
The examples would be more meaningful if you modeled standard threads per specifications... like an ISO metric thread...
Right, however... the profile of the trheads I'm using is not meeting the ISO standard and to do it properly, I should have add even more parameters :-(

Most of the parameters of this thing are there to make the threads printable using almost any printer (like my very low res bot1334) not to make bolts and nuts that meet any standards.

I'll try to give a little bit more of light to the parameters bellow but it's a long answer so feel free to skip
it ;-)

... long answer, sorry...

I did this thing to be able to print using a CupcakeCNC with a home made hot-end and the stock MK4 DC geared filament feeder, hard to get layer height under 0.35mm. Impossible to print a M3, M5 or even a working M8.

To print something close to the standards (met
ric or, I guess that it should also work with imperial) you just need to care about few of the parameters, for example, there are 2 ISO sizes for a M8, M8x1.0 and M8x1.25, just set the diameter parameter to 8 (*) and the (I think I call it) step to 1 or 1.25.

(*) You'll need to let a gap between nu
t and bolt, I use to set the bolt to the std size, in this case 8, and add the gap to the nut, i.e. 8.5. You are free to do the opposite, i.e. bolt:7.5
&
amp; nut:8 or distribute the gap evenly or not between both, i.e bolt:7.7
&
amp; nut 8.2.

For the hex head of the bolts or dimensions for the nut... well, again is only a cople of parameters, distance between flats, usually 13mm (for the M8 example) and thickness (I think I call it height) which if I'm not wrong, the std is something like 5.6.

Here I used the distance between flats (i
nstead of the diameter or distance between opposite edges) just because is the size used for the tools. Be aware that it's too easy to break them when using tools.

... alternatives ...

At the time this thing was uploaded there was already another screw library closer (in shape) to the ISO std: th
http://ingiverse.com/thing:8793 syvwlch.

At the time I'm writting this answer there's a new thing that promises ISO standars (I have not checked myself so I cannot tell): thingiverse.com/thing:27183 by TrevM
TL;DR

Just kidding. Explanations are good.

I'm going by the Wikipedia explanation of the metric specifications:

en.wikipedia.org/wiki/ISO_metric_screw_thread

According to that doc, for a hypothetical M22x0.75 thread, I would want:

Nominal Diameter: 22mm
Pitch: 0.75

screw_thread(22 + (cos(
30) * 0.75 / 8), 0.75, 60, whatever, whatever, whatever)

Not sure if their notion of the "degrees" is the same for your model and theirs, hence my questions.

That, I'm assuming, is the basic metric thread shape, with the exception of the flats, which seemingly would be a union and a difference ope
ration. I.e. for a rod, it's a difference between the screw and a tube of inner diameter 22-(cos(30)*0.75 * 1/8), and a union with a cylinder of outer diameter 22-(cos(30)*0.75*3/4).

It would seem that this could just be a function or a switch which "makes it metric", and it only takes the same t
wo parameters as screw itself.

If I knew more about Openscad I'd do it myself... but then again, if I did, I wouldn't need to be looking at someone else's libraries ;)
That Wikipedia page is what made me do it the way I did it.

One of the reasons was the overhang, in that time more than 45 degrees of overhang was quite impossible without support.

For the external edge I would use Intersection (instead of diff) and I would be careful with the faceting of the cylinders used for the boolean operations (to match the resolu
tion of the thread).

I'm not sure if a pitch of 0.75 will print fine, do post a picture if you try it pleaaaseeeee!! (no mather if it's success or fail :-) ). I may be wrong but, from my point of view, to get a reliable ISO profile you need to fit at least 8 layers of material into the pitch value
and that's a layer height under the 0.1mm !!

Also worth to be mentioned, this library is already using a lot of boolean operations (and not so well done) and now we'll ask OpenSCAD to perform another couple of booleans (over the previous ones)... hope you have the patience or something else to do w
hile waiting for OpenSCAD to compile the result :-D

Here is how I would try a ISO profile with this library...

use
&
lt;polyScrewThread.scad
&
gt;

Ms=22; // Metric Size
Pt=0.75; // Pitch

ln=10*Pt; // Length, 10 times the Pitch in this example
rs=1.5; // Resolution
// (aprox. one face every "value"mm of the perimeter)

Od=Ms+2*Pt*tan(30)/8; // Outer diameter to use in the
// library module

ICr=Ms/2; // Intersection Cylinder d
iameter
UCr=Od/2-5*Pt*tan(30)/4; // Union Cylinder diameter

fno=Od*PI/rs; // Number of faces to use for the
// boolean cylinders

module ISO_like_thread();
{
intersection()
{
cylinder(h=ln, r=ICr, $fn=fno, center=false);

union()
{
screw_thread( Od, // Outer diameter of the thre
ad
Pt, // Step
30, // Degrees
ln, // Length (Z) of the tread
rs, // Resolution
1); // Top end countersunk

cylinder(h=ln, r=UCr, $fn=fno, center=false);
}
}
}
I just printed it and I couldn't feet the nut and under preasure the bolt broke. :(
aubenc - in reply to meirm
I'm sorry to hear that :(

This thing can indeed be a little bit tricky to print and may require "special tunning" of the settings or, another alternative is to use the scad and change the gap between nut and bolt.

I've not experience with PLA (which seems to be what you are using looking at your made things) but, for what I have read, PLA may make this thing even more difficult.

A high infill will make the bolt stronger but may reduce the gap. If they don't fit loose enough the screw/bolt may break too easily, so it's better to tweak scad parameters or print settings but it's too difficult to tell you what to change in the print profile (take a look at the photo with the red background above).

If you still like to try :) I suggest to take a look to
<
a href="http://www.thingiverse.com/thing:9095"
>
thing 9095
<
/a
>
It looks like many people have had better luck there ;)

BTW, thanks a lot for trying and let us know how it went!
i love this, thank you!
aubenc - in reply to caru
Glad you like it! Thanks
caru - in reply to caru
This is especially good for building electro-magnetic motors, as they don't disturb the fields... above hundreds of other practical or decorative things of course ;)
that looks like an amazing print, well done! :)
Thank you!

To be honest, if bot1334 did it, any other cupcake can do it. Believe it or not, mine is far to be fine tuned and we are soooo happy printing things :-D
Thanks!
Great minds and all that...
Top