cqparts_fasteners package

Submodules

cqparts_fasteners.bolts module

class cqparts_fasteners.bolts.Bolt(*largs, **kwargs)

Bases: cqparts_fasteners.male.MaleFastenerPart

ParametricObject constructor parameters:

Parameters:
  • drive (value for DriveType.type) – screw drive type and parameters
  • head (value for HeadType.type) – head type and parameters
  • length (float) – length from xy plane to tip
  • neck_diam (float) – neck radius, defaults to thread’s outer radius
  • neck_length (float) – length of neck, includes taper
  • neck_taper (float) – angle of neck’s taper (90 is perpendicular to neck)
  • thread (value for ThreadType.type) – thread type and parameters
  • tip_diameter (float) – diameter of tip’s point
  • tip_length (float) – length of taper on a pointed tip
class cqparts_fasteners.bolts.HexBolt(*largs, **kwargs)

Bases: cqparts_fasteners.bolts.Bolt

ParametricObject constructor parameters:

Parameters:
  • drive (value for DriveType.type) – screw drive type and parameters
  • head (value for HeadType.type) – head type and parameters
  • length (float) – length from xy plane to tip
  • neck_diam (float) – neck radius, defaults to thread’s outer radius
  • neck_length (float) – length of neck, includes taper
  • neck_taper (float) – angle of neck’s taper (90 is perpendicular to neck)
  • thread (value for ThreadType.type) – thread type and parameters
  • tip_diameter (float) – diameter of tip’s point
  • tip_length (float) – length of taper on a pointed tip
class cqparts_fasteners.bolts.SquareBolt(*largs, **kwargs)

Bases: cqparts_fasteners.bolts.Bolt

ParametricObject constructor parameters:

Parameters:
  • drive (value for DriveType.type) – screw drive type and parameters
  • head (value for HeadType.type) – head type and parameters
  • length (float) – length from xy plane to tip
  • neck_diam (float) – neck radius, defaults to thread’s outer radius
  • neck_length (float) – length of neck, includes taper
  • neck_taper (float) – angle of neck’s taper (90 is perpendicular to neck)
  • thread (value for ThreadType.type) – thread type and parameters
  • tip_diameter (float) – diameter of tip’s point
  • tip_length (float) – length of taper on a pointed tip

cqparts_fasteners.female module

class cqparts_fasteners.female.FemaleFastenerPart(*largs, **kwargs)

Bases: cqparts_fasteners.solidtypes.fastener_heads.driven.DrivenFastenerHead

ParametricObject constructor parameters:

Parameters:
  • access_diameter (float) – diameter of circle allowing tool access above fastener (defaults to diameter)
  • access_height (float) – depth of hole providing access (default 1m)
  • chamfer (float) – chamfer value (default: \(d/15\))
  • chamfer_base (bool) – if chamfer is set, base edges are chamfered
  • chamfer_top (bool) – if chamfer is set, top edges are chamfered
  • diameter (float) – fastener head diameter
  • edges (int) – number of edges on fastener head
  • height (float) – height of nut
  • thread (value for ThreadType.type) – thread type and parameters
  • washer (bool) – [no description]
  • washer_diameter (float) – [no description]
  • washer_height (float) – [no description]
  • width (float) – width of tool reqiured to fasten nut

Female fastener part; with an internal thread.

A female fastener part can only be externally driven, which is why this object inherits from DrivenFastenerHead.

from cqparts_fasteners.female import FemaleFastenerPart
from cqparts.display import display
nut = FemaleFastenerPart()
display(nut)  
../_images/female.default.png

You can also simplify the internal thread for rendering purposes with:

nut.thread._simple = True
../_images/female.default.simple.png

Instances of this class can also be customized during instantiation.

For example:

nut = FemaleFastenerPart(
    width=8.1,  # distance between parallel edges
    edges=6,  # hex bolt
    washer=True,  # washer as part of the bolt
    washer_diameter=11,
    washer_height=0.5,
    chamfer_base=False,  # don't chamfer under the washer
    thread=('triangular', {
        'diameter': 6,
        'diameter_core': 4.5,
        'pitch': 1.3,
        'angle': 20,
    }),
)
display(nut)
../_images/female.hex_flange.png
initialize_parameters()
make()
make_cutter()
make_simple()

cqparts_fasteners.male module

class cqparts_fasteners.male.MaleFastenerPart(*largs, **kwargs)

Bases: cqparts.part.Part

ParametricObject constructor parameters:

Parameters:
  • drive (value for DriveType.type) – screw drive type and parameters
  • head (value for HeadType.type) – head type and parameters
  • length (float) – length from xy plane to tip
  • neck_diam (float) – neck radius, defaults to thread’s outer radius
  • neck_length (float) – length of neck, includes taper
  • neck_taper (float) – angle of neck’s taper (90 is perpendicular to neck)
  • thread (value for ThreadType.type) – thread type and parameters
  • tip_diameter (float) – diameter of tip’s point
  • tip_length (float) – length of taper on a pointed tip

Male fastener part; with an external thread

                           _________  __ head height
                          | \/   \/ |
        z=0 __ _________  |_/\___/\_| __ z=0 (on x/y plane, +z is up)
               \       /    |     |
head height __  \     /     |     |
                 |   |      |     |   __ neck length (excludes taper)
                -\---/-     -\---/-
                -|---|-     -|---|-
                -|---|-     -|---|-
                -|---|-     -|---|-   __ tip (length from bottom)
                -\---/-     -\---/-
                  \_/         \_/     __ length

Warning

Tip thread tapering has not been implemented, except in the simplified model.

This part can be heavily customized to match many common fastener male parts you’ll find. The default is a 4.5mm long M3 screw, with a pan head and phillips screw drive:

from cqparts_fasteners.male import MaleFastenerPart
from cqparts.display import display
male = MaleFastenerPart()
display(male)  
../_images/male.default.png

(literally the first screw I found on my desk)

To simplify rendering, we can also simplify the thread with:

male = MaleFastenerPart()
male.thread._simple = True
display(male)
../_images/male.default.simple.png

This class can be heavily customized during instantiation. For the first example, we can make a screw with a countersunk head, and a neck.

screw = MaleFastenerPart(
    head=('countersunk_raised', {
        'diameter': 8,  # mm
        'height': 3.5,
        'raised': 2,
    }),
    drive=('french_recess', {
        'diameter': 4,
        'depth': 3.5,
        'width': 1,
    }),
    thread=('triangular', {
        'diameter': 4,
        'angle': 40,
        'pitch': 2.2,
    }),
    neck_diam=4.2,
    neck_length=5,
    neck_taper=45,
    length=12,
    tip_length=2,
    _render={'alpha': 0.5},
)
display(screw)  
../_images/male.custom01.png

We can also make a bolt.

bolt = MaleFastenerPart(
    head=('hex_flange', {
        'width': 10,
        'height': 5.3,
        'washer_diameter': 15,
        'washer_height': 1.5,
    }),
    drive=None,
    thread=('ball_screw', {
        'diameter': 6,
        'ball_radius': 1,
        'pitch': 5,
    }),
    neck_length=12,
    neck_taper=20,
    length=20,
    _render={'alpha': 0.5}
)
display(bolt)  
../_images/male.custom02.png

Although this won’t create every bolt or screw you find, it’s a good starting point.

initialize_parameters()
make()
make_cutter()

Makes a shape to be used as a negative; it can be cut away from other shapes to make a perfectly shaped pocket for this part.

For example, for a countersunk screw with a neck, the following cutter would be generated.

../_images/male.cutter.png

If the head were an externally driven shape (like a hex bolt), then the cutter’s head would be wide enough to accommodate a tool to fasten it.

cqparts_fasteners.nuts module

class cqparts_fasteners.nuts.HexFlangeNut(*largs, **kwargs)

Bases: cqparts_fasteners.female.FemaleFastenerPart

ParametricObject constructor parameters:

Parameters:
  • access_diameter (float) – diameter of circle allowing tool access above fastener (defaults to diameter)
  • access_height (float) – depth of hole providing access (default 1m)
  • chamfer (float) – chamfer value (default: \(d/15\))
  • chamfer_base (bool) – if chamfer is set, base edges are chamfered
  • chamfer_top (bool) – if chamfer is set, top edges are chamfered
  • diameter (float) – fastener head diameter
  • edges (int) – number of sides
  • height (float) – height of nut
  • thread (value for ThreadType.type) – thread type and parameters
  • washer (bool) – if True, washer created at base
  • washer_diameter (float) – [no description]
  • washer_height (float) – [no description]
  • width (float) – width of tool reqiured to fasten nut
class cqparts_fasteners.nuts.HexNut(*largs, **kwargs)

Bases: cqparts_fasteners.female.FemaleFastenerPart

ParametricObject constructor parameters:

Parameters:
  • access_diameter (float) – diameter of circle allowing tool access above fastener (defaults to diameter)
  • access_height (float) – depth of hole providing access (default 1m)
  • chamfer (float) – chamfer value (default: \(d/15\))
  • chamfer_base (bool) – if chamfer is set, base edges are chamfered
  • chamfer_top (bool) – if chamfer is set, top edges are chamfered
  • diameter (float) – fastener head diameter
  • edges (int) – number of sides
  • height (float) – height of nut
  • thread (value for ThreadType.type) – thread type and parameters
  • washer (bool) – [no description]
  • washer_diameter (float) – [no description]
  • washer_height (float) – [no description]
  • width (float) – width of tool reqiured to fasten nut
class cqparts_fasteners.nuts.SquareNut(*largs, **kwargs)

Bases: cqparts_fasteners.female.FemaleFastenerPart

ParametricObject constructor parameters:

Parameters:
  • access_diameter (float) – diameter of circle allowing tool access above fastener (defaults to diameter)
  • access_height (float) – depth of hole providing access (default 1m)
  • chamfer (float) – chamfer value (default: \(d/15\))
  • chamfer_base (bool) – if chamfer is set, base edges are chamfered
  • chamfer_top (bool) – if chamfer is set, top edges are chamfered
  • diameter (float) – fastener head diameter
  • edges (int) – number of sides
  • height (float) – height of nut
  • thread (value for ThreadType.type) – thread type and parameters
  • washer (bool) – [no description]
  • washer_diameter (float) – [no description]
  • washer_height (float) – [no description]
  • width (float) – width of tool reqiured to fasten nut

cqparts_fasteners.params module

class cqparts_fasteners.params.DriveType(default=None, doc=None)

Bases: cqparts_fasteners.params.FastenerComponentParam

component_base

alias of ScrewDrive

static finder_callback(*args, **kwargs)
name = 'drive'
type(value)
Parameters:value (see below) – defined type of screw-drive

value can be any of:

  • ScrewDrive instance
  • tuple of (drive type, parameters) where
    • drive type is one of
      • str: name of screw-drive (registered with register)
      • ScrewDrive subclass
    • parameters is a dict
class cqparts_fasteners.params.FastenerComponentParam(default=None, doc=None)

Bases: cqparts.params.parameter.Parameter

Custom fastener component as a parameter. (not to be confused with a Part)

component_base = None
classmethod deserialize(value)
finder_callback = None
name = None
classmethod serialize(value)
type(value)
class cqparts_fasteners.params.HeadType(default=None, doc=None)

Bases: cqparts_fasteners.params.FastenerComponentParam

component_base

alias of FastenerHead

static finder_callback(*args, **kwargs)
name = 'head'
type(value)
Parameters:value (see below) – defined type of male fastener head

value can be any of:

  • FastenerHead instance
  • tuple of (head type, parameters) where:
    • head type is one of
      • str name of fastener head (registered with register)
      • FastenerHead subclass
    • parameters is a dict
class cqparts_fasteners.params.ThreadType(default=None, doc=None)

Bases: cqparts_fasteners.params.FastenerComponentParam

component_base

alias of Thread

static finder_callback(*args, **kwargs)
name = 'thread'
type(value)
Parameters:value (see below) – defined type of thread

value can be any of:

  • Thread instance
  • tuple of (thread type, parameters) where:
    • thread type is one of
      • str: name of thread type (registered with register)
      • Thread subclass
    • parameters is a dict

cqparts_fasteners.screws module

class cqparts_fasteners.screws.Screw(*largs, **kwargs)

Bases: cqparts_fasteners.male.MaleFastenerPart

ParametricObject constructor parameters:

Parameters:
  • drive (value for DriveType.type) – screw drive type and parameters
  • head (value for HeadType.type) – head type and parameters
  • length (float) – screw’s length
  • neck_diam (float) – neck radius, defaults to thread’s outer radius
  • neck_length (float) – length of neck
  • neck_taper (float) – angle of neck’s taper (0 is parallel with neck)
  • thread (value for ThreadType.type) – thread type and parameters
  • tip_diameter (float) – diameter of tip’s point
  • tip_length (float) – length of taper on a pointed tip

Part representing a single screw

Module contents

Copyright 2018 Peter Boin

Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.