Loading

OpenSCAD ISO metric thread library / functions

by TrevM, published

OpenSCAD ISO metric thread library / functions by TrevM Jul 21, 2012

Description

Allows creation of standard nuts and bolts or allow threads to be included in projects.
THIS IS OLD VERSION, please see thingiverse.com/thing:311031

Recent Comments

view all
Hi Crispin,Nothing automatic, it has full maths capability though, so you could do it with each part and add them up into a variable then use echo command to display result.
It worked like a char - many thanks for your help.Do you know if there is a way to have OpenSCAD calculate the volume of an object it constructs?
Many thanks for this - I've downloaded the update and will try your suggestions. I can see the problem with threading a 1mm wall thickness. I'll need to create an insert for the body tube and thread that so that I can screw in the entire rear section (the motor and fin assembly) which is what I am 3D printing. This is the first part of what will eventually be a glide-back rocket project I am building with the kids at my school.

More from 3D Printer Accessories

view more

Makes

Liked By

view all
frog eyes

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

top of file includes calls to make bolts: M10x16, M8x16, M6x12 nuts: M10, M8, M6. simply uncomment a line and build then print, or create your own sizes or include into your own project so you can have threads.
Photos should show black and white nuts and bolts in M6, M8 and M10 sizes, black versions are standard bought steel, white versions are ones I printed in white ABS.
I have a Reprap Metric Mendel Prusa with LM8UU bearings, fishbone wade extruder, own design hot-end, MKII hot bed. Only got it going yesterday, not yet calibrated awaiting micrometer from ebay.
This is my first design in OpenSCAD, maths in not my strong point, but I think these are as close to accurate ISO Metric as I can get.

Hot-end has 0.5mm extrusion hole, used 0.2mm layers, I had to go down to 5mm/s speed to get these printed, I have not yet tried smaller sizes.

OK, so that was a shock, knocked up the original file quickly for self-use, uploaded as an after thought, did not expect that much interest!
There have been some concerns with CGAL rendering times with bolts.
So, see new version IsoThread_20120823.scad.
I have moved positional calculations into variables to they are now calculated only one per thread part and I have now included quality tables.

Results:
CGAL Rendering times
DELL Vostro Desktop - Intel i5-2400 @ 3.10 GHz - 16GB RAM

Original 15/07/2012
Windows 7 Home Premium - OpenSCAD 2012.04.01 (git c869c6e):
M10 nut 7 secs
M8 nut 9 secs
M6 nut 4 secs
M10x16 5 mins 35 secs
M8x16 8 mins 43 secs
M6x12 7 mins 27 secs
Ubuntu 10.04 LTS - OpenSCAD 2012.02.28:
M10 nut 4 secs
M8 nut 4 secs
M6 nut 2 secs
M10x16 2 mins 52 secs
M8x16 4 mins 36 secs
M6x12 3 mins 45 secs

New 23/08/2012
Windows 7 Home Premium - OpenSCAD 2012.04.01 (git c869c6e):
M10 nut 9 secs
M8 nut 10 secs
M6 nut 3 secs
M10x16 2 mins 16 secs
M8x16 2 mins 7 secs
M6x12 1 mins 4 secs

I may re-visit again later, I have an idea that 'may' work that could make it faster.
HiI am looking for a way to create a cylinder (internal diameter 54mm, wall thickness 1mm - so it will need to be a fine thread) with a thread on the inside (this is for several parts of a model rocket). This is by far the easiest scad thread library to understand (I am an scad neophyte), but I am having difficulty in seeing how to do this by modifying your library. Any hints would be most appreciated!Tks
Hi Crispin,Duh, I'm going nuts....To put a thread on the inside (as you actually said), use this line instead:
translate([0,0,45]) thread_in_pitch(54,5,0.5);The translate moves up to 5 mm before top of cylinder.
It creates a thread of 54 mm (inside diameter) that is 5 mm long (high) with pitch of 0.5.
Hi Crispin,Please don't use this old version, click on Remixes and go to the updated version. This version was the very first thing I created in OpenSCAD, updated version is much cleaner and easier:
http://www.thingiverse.com/thing:311031You need to put my file either in the library directory or same directory as your file.
Then, to use the library, put this line at the top of your file:
use <isothread.scad>To create a cylinder with sizes you gave, you will need something like:difference()
{
cylinder(r=56/2,h=50);
translate([0,0,-0.1]) cylinder(r=54/2,h=50.2);
}This creates a cylinder with diameter 56 mm then subtracts a cylinder of diameter 54 from it.Then you need to add the thread like this:
translate([0,0,45]) thread_out_pitch(56.5,5,0.5);The translate moves up to 5 mm before top of cylinder.
It creates a thread of 56.5 mm (56 mm inside diameter + 0.5 inch thread size) that is 5 mm long (high) with pitch of 0.5.
I think you may find printing to be a challenge.
Cylinder wall thickness of 1 mm will be hard.
Thread of pitch 0.5 will be very hard.
You may need to re-think.You could also see my other thing Big Tube:
http://www.thingiverse.com/thing:27181I think this may be close to what you need as a starting point.
It worked like a char - many thanks for your help.Do you know if there is a way to have OpenSCAD calculate the volume of an object it constructs?
Hi Crispin,Nothing automatic, it has full maths capability though, so you could do it with each part and add them up into a variable then use echo command to display result.
Many thanks for this - I've downloaded the update and will try your suggestions. I can see the problem with threading a 1mm wall thickness. I'll need to create an insert for the body tube and thread that so that I can screw in the entire rear section (the motor and fin assembly) which is what I am 3D printing. This is the first part of what will eventually be a glide-back rocket project I am building with the kids at my school.
I need to use this to make a nut and bolt that are thread size 13 with the nut's internal diameter 19mm (to fit shower head). What do I input for this?
TrevM - in reply to gwfami
Um, your problem does not compute!
hex_nut(13);
will give you a standard ISO 13 mm thread
hex_bolt(13,20);
will give you a standard ISO 13 mm bolt that is 20 mm long
All threads have a coarseness index, that is how deep the grooves are, which also relates to pitch (length between 1 ridge and the next).
Most ISO threads are either fine or coarse, at 13 mm you are usually saying thread is 0.75 mm or 1 mm respectively.
But normally the threaded part of a 13 mm bolt has outside diameter of 13 mm + coarse (13.75 or 14 mm) and inside diameter of a 13 mm nut is 13 mm - coarse (12.25 mm or 12 mm ).
So 13 mm thread with an inside diameter of 19 mm is not possible.
Ok, my fault, I suppose that I should restate the issue. Using a thread gauge that I have with my tap and die set, I was able to determine that the thread size is 13 (13 threads/inch). I need to make a nut that is 13 threads/inch with the nut having internal diameter of 19 mm so that it will fit onto the shower head.

Sorry for the confusion.
hex_nut(19);

Is what I think you need.
With metric threads you basically need thread metric diameter and pitch (distance between threads).
You have diameter, you measured that as 19 mm.
Problem is pitch, you measured 13 threads per inch, = 13 threads in 25.4 mm = pitch of 1.95 mm.

Look in my .scad file, you will see:
// function for thread pitch
function get_coarse_pitch(dia) = lookup(dia, [
[1,0.25],[1.2,0.25],[1.4,0.3],[1.6,0.35],[1.8,0.35],[2,0.4],[2.5,0.45],[3,0.5],[3.5,0.6],[4,0.7],[5,0.8],[6,1],[7,1],[8,1.25],[10,1.5],[12,1.75],[14,2],[16,2],[18,2.5],[20,2.5],[22,2.5],[24,3],[27,3],[30,3.5],[33,3.5],[36,4],[39,4],[42,4.5],[45,4.5],[48,5],[52,5],[56,5.5],[60,5.5],[64,6],[78,5]]);

See in the middle: [18,2.5],[20,2.5]

ISO threads do not normally support 19 mm and standard pitch would be 2.5 mm.
But, just add [19,1.95] and it should work.
One way I found to speed this library up is to generate shorter lengths (just a couple of turns of the threads), then duplicate this shape and translate and rotate it a bit so it forms the next part of the thread. Keep doing this a few times and you end up with a longer thread which renders quite quickly. Each generated section is cached then reused, so it is much quicker. One quick calculation I did showed that a render I was attempting would have taken 3 years (as the time goes up geometrically). However, I got it down to a few minutes.
TrevM - in reply to Tafka
Nice one, thanks for sharing, will try that myself :-)
Just try and i got a problem for rendering bold (nuts are fine)... bold compile but do not render (rendering seems to enter an infinite loop), so i can't make a STL.

Using OpenSCAD 2012.7.14 for MacOS.
This sounds like complexity problem, threads on nuts are quite short, threads on bolts are usually longer. The threads are made out of lots of polygons, trianguar on ends, rectangular on sides. Either wait and it will render, or look for line in ISOThread.scad:

module thread_out(dia,hi,thr=32)

3rd parameter is complexity, 32 means 32 polygons for each turn of thread, reduce this to 15 and try again, you should see the effect on a normal compile.
I have printed the M8 hex nut. The thread work perfect! but the diameter and height are wrong. I have changed them according to :

fairburyfastener.com/xdims_metric_nuts.htm

and now the nuts are exactly as the metal ones :-) I have only tested the M8. The diameter and height I have changed in the openscad are:
* Diam: [8,14.60]
* Hi: [8,4.5]

Now they work perfectly wel with the hex key (#13)

Thank you very m
uch for your work! :-)
I know, standards are nice, but so many of them :-(

Threads were ok, Wikipedia shows the maths of ISO threads, but even there, the standards are not clear, coarse and fine, some sizes missing so added by France etc. I just put in all the coarse sizes.

Then I came to hex head sizes and I did actually find the fairbury fastener link and used it to create all the tables. Then I wanted to test, my son had a set of Rolson nuts and bolts M4 to M10 :-) The sizes of the Rolson nuts and bolts are different! So I modified the tables to reflect the Rolson sizes.

The photos show they now match, the black nuts and bolts are Rolson steel, the white are my printed white ABS versions.

But I specifically put all the important sizes in tables so they can be easily modified.

Have Fun :-)
It is amazing!!!! Thank you very much for sharing! :-)
I have just tested the M8 hex nut and it works great!!! Now we can use these nuts for the Prusa :-)

I have taken a video showing how well 2 Hex nuts are screwed on a threaded rod

youtube.com/watch?v=RMiHXQXbb64
Top