cqparts_fasteners.utils package

Submodules

cqparts_fasteners.utils.applicator module

class cqparts_fasteners.utils.applicator.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

cqparts_fasteners.utils.evaluator module

class cqparts_fasteners.utils.evaluator.CylinderEvaluator(parts, parent=None)

Bases: cqparts_fasteners.utils.evaluator.Evaluator

effect_class

alias of VectorEffect

class cqparts_fasteners.utils.evaluator.Effect

Bases: object

class cqparts_fasteners.utils.evaluator.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 cqparts_fasteners.utils.evaluator.VectorEffect(location, part, result)

Bases: cqparts_fasteners.utils.evaluator.Effect

An evaluator effect is the conclusion to an evaluation with regard to a single solid.

Effects are sortable (based on proximity to evaluation origin)

__init__(location, part, result)
Parameters:
  • location (CoordSystem) – where the fastener is to be applied (eg: for a screw application will be along the -Z axis)
  • part (cadquery.Workplane) – effected solid
  • result (cadquery.Workplane) – result of evaluation
end_coordsys

Coordinate system at end of effect.

All axes are parallel to the original vector evaluation location, with the origin moved to this effect’s end point.

Returns:coordinate system at end of effect
Return type:CoordSys
end_point

End vertex of effect

Returns:vertex (as vector)
Return type:cadquery.Vector
origin_displacement

planar distance of start point from self.location along \(-Z\) axis

start_coordsys

Coordinate system at start of effect.

All axes are parallel to the original vector evaluation location, with the origin moved to this effect’s start point.

Returns:coordinate system at start of effect
Return type:CoordSys
start_point

Start vertex of effect

Returns:vertex (as vector)
Return type:cadquery.Vector
wire
class cqparts_fasteners.utils.evaluator.VectorEvaluator(parts, location, parent=None)

Bases: cqparts_fasteners.utils.evaluator.Evaluator

__init__(parts, location, parent=None)
Parameters:
  • parts (list of cqparts.Part) – parts involved in fastening
  • location (CoordSystem) – where the fastener is to be applied (eg: for a screw application will be along the -Z axis)
  • parent (Fastener) – parent object

Location

The orientation of location may not be important; it may be for a basic application of a screw, in which case the \(-Z\) axis will be used to perform the evaluation, and the \(X\) and :math`Y` axes are of no consequence.

For some fasteners, the orientation of location will be important.

effect_class

alias of VectorEffect

max_effect_length
Returns:The longest possible effect vector length.
Return type:float

In other words, the radius of a sphere:

  • who’s center is at start.
  • all parts are contained within the sphere.
perform_evaluation()

Determine which parts lie along the given vector, and what length

Returns:effects on the given parts (in order of the distance from the start point)
Return type:list(VectorEffect)

cqparts_fasteners.utils.selector module

class cqparts_fasteners.utils.selector.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

Module contents

class cqparts_fasteners.utils.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 cqparts_fasteners.utils.VectorEvaluator(parts, location, parent=None)

Bases: cqparts_fasteners.utils.evaluator.Evaluator

__init__(parts, location, parent=None)
Parameters:
  • parts (list of cqparts.Part) – parts involved in fastening
  • location (CoordSystem) – where the fastener is to be applied (eg: for a screw application will be along the -Z axis)
  • parent (Fastener) – parent object

Location

The orientation of location may not be important; it may be for a basic application of a screw, in which case the \(-Z\) axis will be used to perform the evaluation, and the \(X\) and :math`Y` axes are of no consequence.

For some fasteners, the orientation of location will be important.

effect_class

alias of VectorEffect

max_effect_length
Returns:The longest possible effect vector length.
Return type:float

In other words, the radius of a sphere:

  • who’s center is at start.
  • all parts are contained within the sphere.
perform_evaluation()

Determine which parts lie along the given vector, and what length

Returns:effects on the given parts (in order of the distance from the start point)
Return type:list(VectorEffect)
class cqparts_fasteners.utils.CylinderEvaluator(parts, parent=None)

Bases: cqparts_fasteners.utils.evaluator.Evaluator

effect_class

alias of VectorEffect

class cqparts_fasteners.utils.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
class cqparts_fasteners.utils.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