cqparts_fasteners.fasteners package

Submodules

cqparts_fasteners.fasteners.base module

class cqparts_fasteners.fasteners.base.Fastener(*largs, **kwargs)

Bases: cqparts.assembly.Assembly

ParametricObject constructor parameters:

Parameters:parts (list of Part instances) – List of parts being fastened
class Applicator(evaluator, selector, parent=None)

Bases: object

The applicator performs 2 roles to apply a fastener to workpieces

  1. Translate & rotate given fastener
  2. Change workpieces to suit a given fastener

Translation is done first because the fastener is sometimes used as a cutting tool to subtract from mating part(s) (eg: thread tapping).

__init__(evaluator, selector, parent=None)
Parameters:
  • evaluator (Evaluator) – evaluator for fastener
  • selector (Selector) – selector for fastener
  • parent (Fastener) – parent object
apply_alterations()

Apply alterations to relevant parts based on the selected parts

class Evaluator(parts, parent=None)

Bases: object

An evaluator determines which parts may be effected by a fastener, and how.

__init__(parts, parent=None)
Parameters:
eval

Return the result of perform_evaluation(), and buffer it so it’s only run once per Evaluator instance.

Returns:result from perform_evaluation()
perform_evaluation()

Evaluate the given parts using any additional parameters passed to this instance.

Note

Override this function in your evaluator class to assess what parts are effected, and how.

Default behaviour: do nothing, return nothing

Returns:None
class Selector(evaluator, parent=None)

Bases: object

Facilitates the selection and placement of a fastener’s components based on an evaluation.

Each selector instance has an Evaluator for reference, and must have both the methods get_components() and get_constraints() overridden.

__init__(evaluator, parent=None)
Parameters:
  • evaluator (Evaluator) – evaluator of fastener parts
  • parent (Fastener) – parent object
components
constraints
get_components()

Return fastener’s components

Note

Must be overridden by inheriting class.

Read Fastener Build Cycle to learn more.

Returns:components for the fastener
Return type:dict of Component instances
get_constraints()

Return fastener’s constraints

Note

Must be overridden by inheriting class.

Read Fastener Build Cycle to learn more.

Returns:list of constraints
Return type:list of Constraint instances
make_alterations()
make_components()
make_constraints()

cqparts_fasteners.fasteners.nutbolt module

class cqparts_fasteners.fasteners.nutbolt.NutAndBoltFastener(*largs, **kwargs)

Bases: cqparts_fasteners.fasteners.base.Fastener

ParametricObject constructor parameters:

Parameters:parts (list of Part instances) – List of parts being fastened

Nut and Bolt fastener assembly.

Example usage can be found here: Nut & Bolt

class Applicator(evaluator, selector, parent=None)

Bases: cqparts_fasteners.utils.applicator.Applicator

apply_alterations()
Evaluator

alias of VectorEvaluator

class Selector(evaluator, parent=None)

Bases: cqparts_fasteners.utils.selector.Selector

get_components()
get_constraints()

cqparts_fasteners.fasteners.screw module

class cqparts_fasteners.fasteners.screw.ScrewFastener(*largs, **kwargs)

Bases: cqparts_fasteners.fasteners.base.Fastener

ParametricObject constructor parameters:

Parameters:parts (list of Part instances) – List of parts being fastened

Screw fastener assembly.

Example usage can be found here: Screw

class Applicator(evaluator, selector, parent=None)

Bases: cqparts_fasteners.utils.applicator.Applicator

apply_alterations()
Evaluator

alias of VectorEvaluator

class Selector(evaluator, parent=None)

Bases: cqparts_fasteners.utils.selector.Selector

get_components()
get_constraints()
ratio = 0.8

Module contents

class cqparts_fasteners.fasteners.Fastener(*largs, **kwargs)

Bases: cqparts.assembly.Assembly

ParametricObject constructor parameters:

Parameters:parts (list of Part instances) – List of parts being fastened
class Applicator(evaluator, selector, parent=None)

Bases: object

The applicator performs 2 roles to apply a fastener to workpieces

  1. Translate & rotate given fastener
  2. Change workpieces to suit a given fastener

Translation is done first because the fastener is sometimes used as a cutting tool to subtract from mating part(s) (eg: thread tapping).

__init__(evaluator, selector, parent=None)
Parameters:
  • evaluator (Evaluator) – evaluator for fastener
  • selector (Selector) – selector for fastener
  • parent (Fastener) – parent object
apply_alterations()

Apply alterations to relevant parts based on the selected parts

class Evaluator(parts, parent=None)

Bases: object

An evaluator determines which parts may be effected by a fastener, and how.

__init__(parts, parent=None)
Parameters:
eval

Return the result of perform_evaluation(), and buffer it so it’s only run once per Evaluator instance.

Returns:result from perform_evaluation()
perform_evaluation()

Evaluate the given parts using any additional parameters passed to this instance.

Note

Override this function in your evaluator class to assess what parts are effected, and how.

Default behaviour: do nothing, return nothing

Returns:None
class Selector(evaluator, parent=None)

Bases: object

Facilitates the selection and placement of a fastener’s components based on an evaluation.

Each selector instance has an Evaluator for reference, and must have both the methods get_components() and get_constraints() overridden.

__init__(evaluator, parent=None)
Parameters:
  • evaluator (Evaluator) – evaluator of fastener parts
  • parent (Fastener) – parent object
components
constraints
get_components()

Return fastener’s components

Note

Must be overridden by inheriting class.

Read Fastener Build Cycle to learn more.

Returns:components for the fastener
Return type:dict of Component instances
get_constraints()

Return fastener’s constraints

Note

Must be overridden by inheriting class.

Read Fastener Build Cycle to learn more.

Returns:list of constraints
Return type:list of Constraint instances
make_alterations()
make_components()
make_constraints()