threads-scad OpenSCAD Library

repository·master·Indexed 43 days ago

https://github.com/rcolyer/threads-scad

An efficient OpenSCAD library for generating metric-compatible internal and external threads, auger threads, and hardware components like bolts, nuts, and washers as single polyhedra for improved rendering and print quality.

Tokens
1.8K
Snippets
4
Records
7
Agent score
5%

What's inside threads-scad

  1. Overview of the threads.scad module

    master

    The threads.scad module is an efficient OpenSCAD library designed to be used as a component in larger 3D designs. It provides tools for generating metric-compatible internal and external threads, auger threads, tapered threads, and various hardware components like hex bolts, nuts, washers, and Phillips tips.

    Key technical advantages include:

    • Performance: Uses list comprehensions to generate threads as a single polyhedron, improving rendering speed and robustness.
    • Quality: Decreases facet count and increases tactile smoothness compared to other approaches.
    • Versatility: Supports partially tapered ends, auger threads, and conventional threads that come to a point.
  2. 3D Printing Best Practices for threads.scad

    master

    To successfully print threaded parts using this library, consider the following:

    • Calibration: Ensure your printer is properly calibrated for extrusion width and produces consistent, stable parts.
    • Thread Sizing:
      • M2 and higher: Internal threads (holes) generally work well with standard metal bolts.
      • M3: External threads work under good conditions but are sensitive to print quality changes.
      • M4 and higher: Generally very reliable.
    • Tall Rods: Use the RodStart, RodEnd, and RodExtender modules to print vertical rods taller than your printer's height. These can be quite sturdy when printed with appropriate infill and plastic settings.
  3. API Reference: Threading and Hole Modules

    master

    The following modules are used to generate threaded geometry. Note that parameters with a default of 0 or -1 often indicate that a standard default value will be calculated internally if not overridden.

    // External threads
    module ScrewThread(outer_diam, height, pitch=0, tooth_angle=30, tolerance=0.4, tip_height=0, tooth_height=0, tip_min_fract=0)
    
    // External auger-style threads
    module AugerThread(outer_diam, inner_diam, height, pitch, tooth_angle=30, tolerance=0.4, tip_height=0, tip_min_fract=0)
    
    // Internal screw threads (hole)
    module ScrewHole(outer_diam, height, position=[0,0,0], rotation=[0,0,0], pitch=0, tooth_angle=30, tolerance=0.4, tooth_height=0)
    
    // Internal auger-style threads (hole)
    module AugerHole(outer_diam, inner_diam, height, pitch, position=[0,0,0], rotation=[0,0,0], tooth_angle=30, tolerance=0.4)
  4. API Reference: Utility Functions

    master

    The library provides several functions to retrieve standard metric values for a given diameter, which can be used to ensure compatibility in your own calculations:

    • ThreadPitch
    • HexAcrossFlats
    • HexAcrossCorners
    • HexDriveAcrossFlats
    • HexDriveAcrossCorners
    • CountersunkDriveAcrossFlats
    • CountersunkDriveAcrossCorners
    • NutThickness

    Additionally, ClosePoints(pointarrays) generates a closed polyhedron from an array of point loops (N arrays of P points) following the right-hand rule.

  5. API Reference: Extendable Rods and Joints

    master

    These modules support creating long rods by combining solid sections with threaded joints. This is useful for printing vertical rods taller than the printer's Z-axis height.

    // Solid rod on bottom, external threads on top
    module RodStart(diameter, height, thread_len=0, thread_diam=0, thread_pitch=0)
    
    // Solid rod on bottom, internal threads on top (flip around x-axis after printing to pair with RodStart)
    module RodEnd(diameter, height, thread_len=0, thread_diam=0, thread_pitch=0)
    
    // Internal threads on bottom, external threads on top
    module RodExtender(diameter, height, thread_len=0, thread_diam=0, thread_pitch=0)
  6. API Reference: Clearance and Specialized Holes

    master

    These modules allow you to insert non-threaded holes or specialized shapes into your geometry. Rotation vectors are applied first, followed by position translation, starting from a position upward from the z-axis at z=0.

    // Standard clearance hole
    module ClearanceHole(diameter, height, position=[0,0,0], rotation=[0,0,0], tolerance=0.4)
    
    // Clearance hole with a recessed bolt hole (defaults fit standard metric bolts)
    module RecessedClearanceHole(diameter, height, position=[0,0,0], rotation=[0,0,0], recessed_diam=-1, recessed_height=-1, tolerance=0.4)
    
    // Countersunk clearance hole (countersunk side is on the bottom by default)
    module CountersunkClearanceHole(diameter, height, position=[0,0,0], rotation=[0,0,0], sinkdiam=0, sinkangle=45, tolerance=0.4)
    
    // Phillips tip shaped hole
    module PhillipsTip(width=7, thickness=0, straightdepth=0, position=[0,0,0], rotation=[0,0,0])
  7. API Reference: Hardware and Fasteners

    master

    Use these modules to generate complete, standard-sized metric hardware components.

    // Metric hex bolt
    module MetricBolt(diameter, length, tolerance=0.4)
    
    // Metric countersunk (flat) bolt with hex key drive (length includes head)
    module MetricCountersunkBolt(diameter, length, tolerance=0.4)
    
    // Metric wood screw
    module MetricWoodScrew(diameter, length, tolerance=0.4)
    
    // Metric hex nut
    module MetricNut(diameter, thickness=0, tolerance=0.4)
    
    // Metric washer for a nominal thread diameter
    module MetricWasher(diameter)
    
    // A set of matching metric bolts, nuts, and washers
    module MetricBoltSet(diameter, length, quantity=1)