adrianschlatter / threadlib

thread library for OpenSCAD
BSD 3-Clause "New" or "Revised" License
351 stars 34 forks source link
16-un 20-un 28-un 32-un 4-un 6-un 8-un bolt bsp library metric openscad pco-1810 pco-1881 rms screw thread unc unef unf

.. image:: imgs/logo.png :alt: bolt-in-nut logo

threadlib is a library of standard threads for OpenSCAD <https://www.openscad.org>. It is based on Helges excellent threadprofile.scad <https://github.com/MisterHW/IoP-satellite/tree/master/OpenSCAD%20bottle%20threads> to create nice threads with lead-in / lead-out tapers. Check out his article on generating nice threads <https://hackaday.io/page/5252-generating-nice-threads-in-openscad>__ on Hackaday.

In contrast to other thread libraries such as openscad-threads <http://dkprojects.net/openscad-threads/>, yet another thread library <https://www.thingiverse.com/thing:2277141>, threads for screws and nuts V1 <https://www.thingiverse.com/thing:3131126>, and threading.scad <https://www.thingiverse.com/thing:1659079>, threadlib does not make you look up diameters and pitches and maybe even thread-profiles in tables and norms: It has these tables built in.

Creating a thread is as simple as

.. code-block:: OpenSCAD

    use <threadlib/threadlib.scad>
    thread("G1/2-ext", turns=10);

.. image:: imgs/thread-G1o2-ext-10turns.png :alt: bolt-in-nut logo

to create a British Standard Pipe parallel external thread.

Why you may want to use threadlib

Installation

Prerequisits:

Save all of these into your OpenSCAD library folder <https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Libraries>__

threadlib:

Clone threadlib into the folder 'threadlib' inside your OpenSCAD library folder

Your libraries folder should now look similar to this:

::

libraries
├── list-comprehension-demos/
├── scad-utils/
├── thread_profile.scad
└── threadlib/

Usage

Before you start: threadlib is designed in millimeters (not meters, not inches). Make sure that your units are set accordingly or scale the output of threadlib to match the units you use in your project!

To create a bolt (without head) with 5 turns of M4 thread:

.. code-block:: OpenSCAD

    bolt("M4", turns=5, higbee_arc=30);

.. image:: imgs/bolt-M4.png :alt: Bolt with M4 thread

See these nice lead-in / lead-out tapers? Try a nut (this time using the default argument for higbee_arc):

.. code-block:: OpenSCAD

    nut("M12x0.5", turns=10, Douter=16);

.. image:: imgs/nut-M12x0.5.png :alt: M12x0.5 nut

Note that for a nut you also have to specify an outer diameter. The inner diameter is implicitly given by the thread designator ("M12x0.5" in this case). You can set the number of sides for the nut! So you can make hex nuts:

.. code-block:: OpenScad

    nut("M30", turns=4, Douter=46, nut_sides=6); 

To make a threaded hole (e.g. in a plate), an intuitive approach would be to create the difference of the plate and a bolt. However, this part would not work well in practice: You need a little space around the bolt to avoid collisions. threadlib's solution is to provide the tap module:

.. code-block:: OpenSCAD

    tap("G1/2", turns=5);

.. image:: imgs/tap-G1o2.png :alt: G1/2 tap

The tap shown above is intended for use like this and has accounted for the allowances needed in practice. Also, it will create the tapers:

.. code-block:: OpenSCAD

difference() { part_to_be_tapped_here(); tap("G1/2", turns=5); }

Make sure that the tap extends a tiny bit out of the part to be tapped. Otherwise, you will end up with infinitely thin artifacts covering the entrance of your tapped hole.

If you only need the threads alone:

.. code-block:: OpenSCAD

    thread("G1/2-ext", turns=5);

.. image:: imgs/thread-G1o2-ext.png :alt: G1/2 external thread

(Note: You need to specify whether you want internal ("-int") or external ("-ext") thread here.) Then, add the support you want. In the simplest case, a cylinder (which is what nut(...) uses):

.. code-block:: OpenSCAD

    specs = thread_specs("G1/2-ext");
    P = specs[0]; Rrot = specs[1]; Dsupport = specs[2];
    section_profile = specs[3];
    H = (5 + 1) * P;
    translate([0, 0, -P / 2])
        cylinder(h=H, d=Dsupport, $fn=120);

.. image:: imgs/flexible.png :alt: G1/2 bolt

Here, we have used the function thread_specs(...) to look up the threads specifications - including the recommended diameter of the support structure.

List of supported threads

Currently, threadlib knows these threads:

Extensibility

Don't find some of the threads you need for your project? Don't worry: You can add your own:

.. code-block:: OpenSCAD

    use <threadlib/threadlib.scad>

    MY_THREAD_TABLE = [
                       ["special", [pitch, Rrot, Dsupport,
                       [[r0, z0], [r1, z1], ..., [rn, zn]]]]
                       ];

    thread("special", turns=15, table=MY_THREAD_TABLE);

Care to share? Safe others from repeating the valuable work you have already accomplished and get the fame you deserve: Send in your tried and tested threads for addition to threadlib! See How to contribute <./CONTRIBUTING.md>_ for help on how to become a contributor.

Still reading?

If you read this far, you're probably not here for the first time. If you use and like threadlib, would you consider giving it a Github Star? (The button is at the top of this website.)

Contributing

Did you find a bug and would like to report it? Or maybe you've fixed it already or want to help fixing it? That's great! Please read CONTRIBUTING to learn how to proceed.

To help ascertain that contributing to this project is a pleasant experience, we have established a code of conduct. You can expect everyone to adhere to it, just make sure you do as well.

Change Log