OpenSCAD Metric Nut, Bolt & Threads Library

Remix of Trevor Moseley's "OpenSCAD ISO metric thread library / functions (updated)", tweaked to work on Ultimaker 2 with Cura.


Creative Commons Public Domain Dedication

All rights to this work are waived and you can use it however you please.

Learn more or download attribution tags


This is just a remix of Trevor Moseley's "OpenSCAD ISO metric thread library / functions (updated)", found here:

I just tweaked it to work on Ultimaker 2 and Cura, as Trevor's version seemed to create spaces between model segments and the results would not print correctly. Also, Trevor's version did not seem to match actual steel nuts and bolts.

I calibrated my testing against an M6 nut and several M6 bolts, plus M6 threaded rod. I did not test other sizes. YMMV.

All credit goes to Trevor for his excellent library. It may or may not be exactly metric standard but it (now) is compatible with steel threading and the only OpenSCAD metric library that actually works for me. :)

I have also kept the same licence as it is almost all his code anyway.

(Nuts and bolt ThreadTest example, with an extra cylinder for a smooth shaft provided courtesy of DonMilne (

Materials and methods

- OpenSCAD (2015.03 works, earlier versions might too but are untested.)
- A steel nut and bolt for testing (Optional). :)
- Optimized for Ulitmaker 2 and Cura (2015.02.1), but should also work for other printers and slicers.
- Printed on Cura's Normal quick profile. (0.1mm layers, 0.8mm shells, 0.6mm top/bottom, 20% infill, <50mm/s effectively.)



Issues are used to track todos, bugs or requests. To get started, you could create an issue.


8845e3fc7f47d42c4b0ddcd13819bed2?default=blank&size=40GrGin added this to the Tools collection ago
B1e2346fc59b842ed56ff9f3ffbfae2e?default=blank&size=40roussebarbosa added this to the armas collection ago
9e6bc89b1430af68ed2352d9fcc68bb3?default=blank&size=40NebulaM78 added this to the Tools collection ago
B0240d44b8fa2fd82f90409cb04e9e8b?default=blank&size=40Moggelot added this to the NUTSnBOLTS collection ago
475d777c5fc55fa46ecaf9e9bacd7607?default=blank&size=40Marc a Carole Bemtgen added this to the Marc collection ago
4dd9fb56d3830c94de5d0877792ca600?default=blank&size=40doctorkb added this to the Things to make collection ago
688c0e017ed3a9c5f37f95d931a30d52?default=blank&size=40ShaddowX added this to the Sonic Screwdriver collection ago
Dce8d2f4c4f5c55ce4807e7e43a9df60?default=blank&size=40my.kosz added this to the Warsztat collection ago
A799c134d9622c7d8243cb81ed5983bf?default=blank&size=40yastreb added this to the Инструмент collection ago
E39857811b1059c29c06cb3a2ba6ee50?default=blank&size=40Magnetic added this to the Mécanique collection ago
75e8c2bcc8dc996ae339210da87ce8c3?default=blank&size=40Craig Hoffman added this to the Stuff to make collection ago
34a8c5072eb2cb2df22e98963018e7af?default=blank&size=40fzellini added this to the viti collection ago
1298314713b1b08983f3d3b1531a3b0b?default=blank&size=40Mario Sebastian Rodriguez added this to the parametricos collection ago
47d16c453ecfc55c1b9ca86c11e1ddca?default=blank&size=40Brad Duffy added this to the tools collection ago
Fcafea5cb8ee316ad865c4bb52905848?default=blank&size=40Deathsentenz43 added this to the Functional collection ago
3cf5525404256dbb6caeb02ae16149ff?default=blank&size=40breacasu added this to the Technical collection ago
23bb3aac8a43428bc09d012eaa43509b?default=blank&size=40theromangeneral added this to the Jon collection ago
Da4e2341af5513ce35a2110e0f87f325?default=blank&size=40BarronEric added this to the good stuff collection ago
6b37f02501e9afd50661d17546dd7c6f?default=blank&size=40Emplar added this to the Common Useful collection ago
Db8de2bac751bd8a45a2e2d5b7785d2f?default=blank&size=40yee379 added this to the cogs collection ago
16a995b6b4387d788b6ff21a8f2ff423?default=blank&size=40filipskott added this to the Tools/ Tool organization collection ago
0592e92f50010d5abf34a408bf416747?default=blank&size=40redpaul6t8 added this to the Things to Make collection ago
F3389e9cb15bea24359265a4fb8d0caf?default=blank&size=40Christopher Pribitzer added this to the TW collection ago
615866aed0f6b6d503ec4d498c540986?default=blank&size=40Jason Ramberg added this to the Things to Print collection ago
7667ed3f9e90ed7e584269da8cfa62b5?default=blank&size=40Kim Watson added this to the Things to make collection ago
Mini img 20171107 125652Jorge Barata added this to the tools collection ago
37b69f8139a9e34cfee9ae931a0e8c78?default=blank&size=40Daniel Estévez added this to the Utilidades collection ago
4ab74beb2099cbdae2c5d3613beeb968?default=blank&size=40Conner Oaks added this to the Things collection ago
Df8067572b61f4b1b8e292b718b1ff1e?default=blank&size=40imoraj added this to the Tools collection ago
87b9b6c42b9eb2a316f901a0c10bcb33?default=blank&size=40Ryan Bessette added this to the replacement part collection ago
0bbfd21c8b352f016d8956bc716c1e37?default=blank&size=40Alireza Rahimzadeh added this to the Later collection ago
341f7994af6c2efc882ddf264402e61b?default=blank&size=40Caleb Holt added this to the Random collection ago
090a2ff2fe881c5f6ccd6b0adb489c74?default=blank&size=40khertzog added this to the threads collection ago
8858499f8a1337b5ceb45533ac45563f?default=blank&size=40aqsy10 added this to the KZ440 collection ago
020a492efa659eaa7f0739b362716855?default=blank&size=40GDiehl added this to the Bolts collection ago
F9d70846f9719fb61452fe3de183e6d0?default=blank&size=40Khimera added this to the All collection ago
Eeb10fc3215f8ec1b1914f5ac77d1fb0?default=blank&size=40terpene33 commented ago

Nice but Black is not the better way to see, and code is necessary for my use.

1961daf042b15bbac9ad2117fefbcb2c?default=blank&size=40Anonymouse added this to the Tests collection ago
Dfd63ddaac6cfab93f8de2fb875a2aa7?default=blank&size=40agering added this to the Meins collection ago
20c316402925257c2555aac972f462a4?default=blank&size=40RaphBeaup added this to the Nuts bolts Screws collection ago
E2a399fc7c19a53cb1f286aabb62f17d?default=blank&size=40Jean-Pierre Hermans added this to the To print collection ago
E2a399fc7c19a53cb1f286aabb62f17d?default=blank&size=40Jean-Pierre Hermans added this to the Nuts collection ago
87bf8ebf42753b77da12f70e9d1e5671?default=blank&size=40Aethenelle added this to the Tools collection ago
85b74706e925e5a7bc53376b9843ea06?default=blank&size=40Lorenzo6595 added this to the To Print collection ago
Ca3af33e50c7d13995728772175c67ae?default=blank&size=40Huy Lê Quốc commented ago

Nice library, great thanks JustKrys.

1f32e00de3121b20aa8b2ee354a2f515?default=blank&size=40David Vidal added this to the Piezas mecánicas collection ago
85bf302d355db86f4d7a03873df5ff2c?default=blank&size=40jnbr added this to the A voir collection ago
78d5079018ba02ebc8cd0ce1a6f3716c?default=blank&size=40tinkerer added this to the Misc collection ago
501258aedfeddbe4d1a2372846f2cd10?default=blank&size=40nuehm.anno0 added this to the ToDo collection ago
Mini monkey businessNex added this to the Tau collection ago
5463a5afd4ecd22816453ea3abfd9218?default=blank&size=40ScaRRvonZA added this to the Fasteners collection ago
3c6c2817ce13f0e9a900dff9f76a7a5a?default=blank&size=40BrewNinja added this to the Things to make collection ago
Eafd1346688a49adf34de05a9e815aa3?default=blank&size=40Ertan Korhan KARASU added this to the 1 collection ago
Baf1a716b0e8c780f7abf7881a4c05cc?default=blank&size=40fbarros12 added this to the Ferramentas collection ago
Mini hd 1280x1024 abstract 3d medaltations 13580José Ramón Tezanos added this to the Organizar collection ago
D4f6ec3eb1dcb8bdee58d0ec2a68bb59?default=blank& added this to the To print collection ago
D8ef056dc3ccc73148d2c068a8c31148?default=blank&size=40zets added this to the To make collection ago
96db76a2ef8b46335bb82f2fb6601f68?default=blank&size=40drewfish added this to the tools collection ago
5791c2366af716d910878e02b1b6b487?default=blank&size=40Erikas added this to the to do collection ago
F8500ded009dc9b67ad6511aedd59278?default=blank&size=40josep alacid added this to the Tools collection ago
Mini img 20160616 214649728ltmhenrique added this to the Tecno collection ago
5ecd4ebbd6c5bbd870d7b2ef24aa55c3?default=blank&size=40ashish81in added this to the MayDo collection ago
Mini bvd avatarbvd1940 added this to the #1 collection ago
B18d21a03261cf67fb2826cd4c95651b?default=blank&size=40Jblisch added this to the Handy collection ago
Mini big cheesy creeper grin   paintingShane Paul added this to the Tools: Mech Parts collection ago
Fa580e3fc8d1871d32799ae9192e3304?default=blank&size=40qdsace added this to the Engineering collection ago
5840ce71345dd0029206371858f94ad2?default=blank&size=40dwayneatwood added this to the Parts collection ago
9ef739d4d6527d3d8c186425fecfe13a?default=blank&size=40Pegase_Sk added this to the A voir... collection ago
233aadb02022628d2479007c694dc2b2?default=blank&size=40RiComikka added this to the hardware collection ago
Da90b05e5c69a9fa5501972852b95635?default=blank&size=40Raymond De Cock added this to the a voir collection ago
26646b2fcc50b8871fb338de85c86356?default=blank&size=40Aedryan13 added this to the Make it collection ago
Da7cd7fdc5462a58ba8e38335fc471ad?default=blank&size=40Martin Heath added this to the to print collection ago
01fc29fff0d1ccf0501dad94dba732fb?default=blank&size=40Okay added this to the wanna print collection ago
65f8b12857405648dda939c5cb88b10d?default=blank&size=40Emrah Çelik added this to the nuts collection ago
0132effc4f0f7fde2460468593cce7d0?default=blank&size=40benkeller3 added this to the to make collection ago
918f1592725f8e10dc431fb9b01859d7?default=blank&size=40FredsGW added this to the 3D Cura collection ago
Fe652372f80f6344f663c87913d8d86a?default=blank&size=40Powerpaco added this to the Workshop Tools collection ago
Ad9d02dba80c1faf377b4fb64fec6ff5?default=blank&size=40pemo added this to the per collection ago
110b5832413fd4da70db35b255a202ff?default=blank&size=40kadito added this to the utiles collection ago
F253ab2d712136fa18b547dadb27cf1e?default=blank&size=40Scott Frock added this to the Nuts&Bolts collection ago
8fe024dda9e45eaf8862ef54c0001721?default=blank&size=40ThisChildsLife added this to the Stuff collection ago
Cefd29ec5608da6b0c5e3d434dd914fc?default=blank&size=40Rofel51 added this to the Tools collection ago
73b090bbb30b82ff3598f118b45181b8?default=blank&size=40Zepco added this to the Narzędzia collection ago
5c073bbd00f850a42498f364d73b6a2d?default=blank&size=40Anton Belov commented ago


Removed error in thread_in_ring function (thinknes dont work)

module thread_in_ring(dia,hi,thk)




cylinder(r = (dia/2)+thk,h = hi);

translate([0,0,-1]) cylinder(r = (dia/2)+0.1, h = hi+thk);



And add champfer on thread equal 20% of pitch.

module thread_in_pitch(dia,hi,p,thr=$fn)

// make an inside thread (as used on a nut)

// dia = diameter, 6=M6 etc

// hi = height, 10=make a 10mm long thread

// p=pitch

// thr = thread quality, 10=make a thread with 10 segments per turn



Rmin=(dia/2)-(5*h); // as wiki Dmin

s=360/thr; // length of segment in degrees

t1=(hi-p)/p; // number of full turns

r=t1%1.0; // length remaining (not full turn)

t=t1-r; // integer number of turns

n=r/(p/thr); // number of segments for remainder

translate([0,0,tn*p]) th_in_turn(dia,p,thr);
cylinder ( d=dia-p*0.8, h=hi);
} // make champfer on thread = 0.8*thread pitch // Anton Belov 18.05.2017


and make champfer on nut bottom



union() {

thread_in_ring(30,6,3); // make a ring to enclose an M8 x 10 ISO thread with thickness 2 mm

thread_in_pitch(30,6,1.5); // make an M8 x 10 thread with 1mm pitch


cylinder ( d1=33, d2=28.5,h=3); // make champfer on nut


Mini  sushi chops trans more centeredSushi Desires added this to the Mechanisms collection ago
Mini  sushi chops trans more centeredSushi Desires added this to the Gears, Threads, Bearings, Pulleys, & Other Interfaces collection ago
Mini  sushi chops trans more centeredSushi Desires added this to the Workshop collection ago
B21da4db0cf3410d41103e3338b481fd?default=blank&size=40ProjectCentral added this to the UTILITY collection ago
D79c33ce898647deef4b56bbc6962020?default=blank&size=40Alican Barkan added this to the Tools collection ago
8868941f6a32bdf2206f476aa360642b?default=blank&size=40eric777 added this to the Tools collection ago
8868941f6a32bdf2206f476aa360642b?default=blank&size=40eric777 added this to the Hardware collection ago
Mini ocieicon101 squareOcie Ward added this to the household collection ago
Mini ocieicon101 squareOcie Ward added this to the tools collection ago
14e28028249e2878d860e91d889ee3bc?default=blank&size=40Mentros added this to the Varios collection ago
9ca3d819e1448dfcd7edeef0fb36c2e7?default=blank&size=40David G. added this to the Eines collection ago
Mini imageRflynn added this to the Mechanical things collection ago
A53194e1827aecdaecbf40c72a125fdd?default=blank&size=40moonshizle added this to the Marshalls Stuff collection ago
02c0e4a45277fae90fd149455014b3d2?default=blank&size=40Saqhara added this to the Tools collection ago
4fd08744d56e30ddcec28e96d5719412?default=blank&size=40ask4help added this to the General collection ago
F409bcf45b7ffd69e0beba45f9aea8f7?default=blank&size=40Melog added this to the For review collection ago
0ba58ecfc226ffb4bd74ff4d9719c7fd?default=blank&size=40Kramer Cosmo added this to the Things to print collection ago
C56bb8a7a01df4e38fc1e58135de6d23?default=blank&size=40JustKrys commented ago

Small note: For ABS (and maybe PLA too), scale nuts up by about 2% else they are quite tight.

Mini um1Joerg Torhoff added this to the things to make collection ago
2341055c4728c8b0f8480e8b1551618a?default=blank&size=40Kevin Justice added this to the ToPrint collection ago
68c0e016ce3c4bbf00d47a64a94a6359?default=blank&size=40chmax added this to the MyPrintPlan-chmax collection ago
Aedd24c23ddc2e0651228adf2e7aa623?default=blank&size=40tinkerology added this to the OpenSCAD collection ago
Mini sp logo grain 400x390Stamos added this to the tools collection ago
Mini lisca mangaLisca added this to the coisinhas collection ago
Mini lisca mangaLisca added this to the Gears collection ago
Cb534ebea51ea51e10522c17823c5964?default=blank&size=40cds099 added this to the things to print collection ago
69adc8990515124deee8340415ccfaac?default=blank&size=40Matt LaRussa added this to the Tools collection ago
2da9a88a6449e23b580bad4b42a84f54?default=blank&size=40Abcopp added this to the Parts collection ago
F6255ee0dadfb1bb858c901e855bd9d5?default=blank&size=40Zoran Vila added this to the To be made collection ago
9be3cf826dbb4a308a34fc1dfe13f7f8?default=blank&size=40wwilson83 added this to the New collection ago
3f07db8af071677da6f74f86b02c7dc9?default=blank&size=40arkcle added this to the outils collection ago
Mini twitter mattarlauckas 400x400marlauckas added this to the To Make collection ago
4d3fab1519e6cafb99720c9a9e6f48b1?default=blank&size=40ymcc3d added this to the Gears etc collection ago
92a30e952f99219f35d41acc5c58c9a5?default=blank&size=40Crossfire 0mega added this to the Nuts & Bolts collection ago
7b80cb1f51216ed66fa299979307185a?default=blank&size=40loic19871 added this to the Things to make collection ago
439130abc394994d73efaa17a8ea12d5?default=blank&size=40filch20049 added this to the Technik collection ago
Mini aimeeprofileavatarAimeethyst added this to the Components collection ago
82a953778ff40733df2c54f663b8029a?default=blank&size=40solbot added this to the Tools collection ago
E63ea23cd8fccb2567797bae37b39c58?default=blank&size=40chapelmagine added this to the mine collection ago
2656324c206c773aa86d324c73e68d95?default=blank&size=40Robert Gibson added this to the Tools collection ago
2058db33b3521265973bc268281bc800?default=blank&size=40Tateums added this to the Stuff to Make collection ago
Mini elfen lied 11 thumb large 1 Da6oN added this to the Tool collection ago
7132a5b72a1be56000406b297b99106c?default=blank&size=40Dizzee Jones added this to the 3D Printer collection ago
Dbb743597ca91e38558532c3c38a4d04?default=blank&size=40Stuart Miles added this to the Stuff collection ago
Bbacbac9163544771dc7f31358185c9c?default=blank&size=40MarkusArning added this to the remember collection ago
396e53047db5fedbd8c27c2ef7509f97?default=blank&size=40drofnas added this to the Parts collection ago
C56bb8a7a01df4e38fc1e58135de6d23?default=blank&size=40JustKrys published this design ago