Asking for Feedback: ChiralSym Thread Generator (4.5.3)

Here is a helical thread-generator I’ve been working on. Mostly intended to generate custom-threads for 3d-printing. However, it might be useful for other people.

Despite the “simplicity” of helical threads, getting everything together turned out to be much more work than I expected. Especially when allowing for tapered threads.

Please have a look, and let me know if anything breaks, or how to improve this Grasshopper script. I’m using this project to learn Grasshopper as well as make something (hopefully) useful.

Sincerely,
–Anthony “ChiralSym” Yan

I’m releasing this under an MIT License (open-source, free, generally permissive).
ChiralSym Thread Generator (4.5.3).zip (6.7 MB)



Outputs

5 Likes

Fixed a minor bug in this update.

ChiralSym Thread Generator (4.5.4).zip (6.7 MB)

3 Likes

Once, I drew some NPT threads. I needed to know long the assembled, tightened fitting was. I wish I had something like that when I was making them.

2 Likes

I guess it’d be easy to know how long the assembly was, when it was “geometrically tightened.” You could just analyze the geometry in CAD. Maybe good enough for “finger-tight.”

But in practice, so many minor things might affect how much it can be tightened, such as surface finish, tolerances of the machining, and hardness of the metal, specified torque, etc. If you torque down really hard, you might get anywhere from 1/8th to a full turn, or more? Especially if the threads are cut in a softer material, such as brass or aluminum. Maybe you’d have to consult an engineer or machinist.

1 Like

A quick and dirty demo video. About 6 min.

1 Like

I just needed to be close. There was a 90-degree fitting, and a clearance issue behind the fitting.

1 Like

Here’s the ReadMe about the thread generator, that gives a little explanation.


Intro: ChiralSym’s Thread Generator (4.5.4)

I wanted a thread-generator for 3d-printing custom threads, and this is what I came up with. It allows you to input a custom thread-profile and the number of thread-starts. It then generates internal and external thread surfaces based on a thread-tolerance.


Brief Description:

The geometry is generated by lofts, with the cross-sections being in planes that contain the thread-axis. You can think of this as sweeping out a surface while translating (along) and rotating (around) the thread axis.

This is “approximately” what happens on a machinist’s lathe during single-point thread-cutting.


Inputs:

(1) Two points representing the start and end of the thread-axis.
(2) A curve that represents a full-cycle of thread tooth profile.
(3) Number of thread-starts.
(4) An angular resolution. This is the sampling-resolution used to generate the thread-helix.
(5) A thread tolerance. The external-threads (bolt) will be smaller by the thread-tolerance. The internal-threads (nut) will be larger by the thread-tolerance. That means there will be twice the thread tolerance between the internal and external threads.

IMPORTANT NOTE: The position and orientation of input curve (2), is very important in THREE ways (not obvious):

(A) The position and orientation of the curve(2) affects the output geometry.
The START-POINT of the curve sets the pitch-radius of the threads.
The END-POINT of the curve controls if the threads will be tapered or straight.

This means the position, orientation, and geometry of the thread-profile (2) controls the thread-pitch, pitch-radius, and taper of the final thread. See (B) and (C) for more details.

(B) If the thread-axis and the thread-profile are co-planer, then we generate the thread as follows:
First, we make multiple copies of the thread form, and Join them together, end-to-end, into a big curve.
This big curve sweeps out a surface as it is translated (along) and rotated (around) the thread axis.

Therefore, the thread-profile (and its relationship to the thread axis) generates BOTH the thread pitch, and the thread-taper.

(C) If the thread-axis and the thread-profile are not in the same plane, then we first do a “minimal” rotation to get the thread-profile (2) into a plane that contains the thread-axis (1). If needed, you can output (Grasshopper bake) the final oriented thread profile, as well as various specifications, such as the thread-taper in degrees, and the thread-pitch.


Outputs:

(1) A “thread-cutter.” This is a “thin” helix-like solid (closed polysurface). The thickness of the thread-cutter is twice the thread tolerance. Take a cylinder, and Boolean-subtract away the thread-cutter, and you’ve cut matching internal and external threads.
(2) External threads (bolt) without tolerance. I call this the “idealized thread.”
(3) The thread-profile, but aligned and positioned for Loft(s) along the thread helix.
(4) Miscellaneous additional info about the thread specifications, such as thread pitch, pitch radius, axis length, taper, etc.

The simple examples in the .3dm file take a few seconds to compute. Super-complicated threads, with a huge number of thread-starts, can take much longer (minutes).

In Demo.png, you can see a “fractal like” thread. That took several minutes to compute, and is pretty much the limit of how complicated the geometry can be. Any more complicated, and Rhino’s geometry engine starts breaking down. I don’t know how to make it any faster.


Help:

If more detailed instructions would be helpful, then just let me know.
If you find any bugs, or if you have suggestions, please point them out.

I’m only working on this project informally (for my own use), so I may not fix all bugs, or implement all suggestions, depending.

If you find this useful, then give a thanks! My goal is to learn Grasshopper and build tools that are useful for others.


Technical Notes

Some mistakes I made along the way:
(1) I used Sweep2 at first. Sweep2 is good for threads with no taper (straight), but cannot be used to generate tapered threads! So I ended up using Loft.
(2) At first, I used Offset Surface to generate the thread tolerances. But Offset Surface is computationally expensive, and very complicated. Sometimes it would fail in unexpected ways. So instead, I use Offset Curves, and then use the offset curves to generate the surfaces with tolerance. This is faster, and more robust (in my experience).
(3) The final solids are stitched together with a Brep Join of the helical surfaces and planar caps. However, Brep Join fails if a surface either self-intersects, or touches itself. This means the helical surface can’t be a single surface (ie: not a polysurface) and used to make a solid, because it has edges that touch its own edges (self-touching). We can fix this by splitting the surface into two parts, and join them into a polysurface. Then, each surface of the poly-surface does not self-touch, and Brep Join will work.


License:

This project is released under an Open MIT License.
See LICENSE.TXT.


Sincerely,
–Anthony K. Yan (“ChiralSym”)
(2023-02-12)

Minor update. Reduced complexity of some intermediate calculations, fixed a bug or two.
This will be the last update for awhile, unless people find more bugs, or have suggestions.

ChiralSym Thread Generator (4.5.8).zip (6.7 MB)

Another update.

Improved some internal calculations to handle extremely complex and/or unusual thread-profiles. Let me know if you find any bugs, or if you have suggestions.

ChiralSym Thread Generator (4.6.1).zip (6.8 MB)

Just for fun. After improving the ability to handle complex thread-profiles, I made this. This thread form isn’t practical, of course, because a tapered thread can’t screw-together if it has “overhangs.” And this thread has a gazillion “overhangs.”

This is just about the most complex thread that I can generate on my computer. Any more complexity, and Rhino runs out of memory (I have 64 GB).

Mechanically, this doesn’t work, but somehow I thought this was fun and vaguely architectural and/or sculptural.

4 Likes

Another minor update.
Improved some internal calculations.
Some cleaner code now that I have a better understanding of data-trees.

ChiralSym Thread Generator (4.6.3).zip (7.2 MB)

I’d give this a like if discourse worked properly, it looks nuts!

2 Likes

What would be really nice is a library of thread profiles and the ability to pick a hole on an existing model to add a thread to!

Useful tool so far though!

1 Like

Updated to version 5.3.1.

Now has semi-manual chamfering of threads.

One of the outputs are a series of open cones, that represent the chamfers of the threads. You can use the cone(s) with Solid->Boolean Split to cut your chamfers. Also you can convert the cones to solids, and use Boolean Subtract.

To adjust the chamfer, you can set the chamfer angle. Also, the cones can be re-positioned and/or Scaled if you want to adjust the chamfer size.

More details in the ReadMe file.

I haven’t had time to fully test the new version, so let me know if you have any problems. Suggestions are welcome. Released as open-source under an MIT License.

ChiralSym Thread Generator (5.3.1).zip (7.1 MB)

Updated to version 5.4.0.

Now can be easily used as a Hops component in Grasshopper. This is a much more convenient way to include the Thread Generator in your own Grasshopper scripts.

The Thread Generator now has a Boolean Toggle that you can set to True if you want to use it as a Hops component. Otherwise, set the toggle to False. The toggle is called,“Use Hops plugin?”
Rhino_vjz63yxJgl

See the ReadMe.txt for more details.

Let me know if you have problems, find bugs, or have suggestions.
Released as open-source under an MIT License.

ChiralSym Thread Generator (5.4.0).zip (7.2 MB)