cqparts_fasteners.utils package¶
Submodules¶
cqparts_fasteners.utils.applicator module¶
-
class
cqparts_fasteners.utils.applicator.Applicator(evaluator, selector, parent=None)¶ Bases:
objectThe applicator performs 2 roles to apply a fastener to workpieces
- Translate & rotate given fastener
- 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:
-
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.Evaluator(parts, parent=None)¶ Bases:
objectAn evaluator determines which parts may be effected by a fastener, and how.
-
__init__(parts, parent=None)¶ Parameters: - parts (list of
cqparts.Part) – parts involved in fastening - parent (
Fastener) – parent object
- parts (list of
-
eval¶ Return the result of
perform_evaluation(), and buffer it so it’s only run once perEvaluatorinstance.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.EffectAn 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
- location (
-
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
locationmay 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
locationwill be important.- parts (list of
-
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
partsare contained within the sphere.
- who’s center is at
-
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:
objectFacilitates the selection and placement of a fastener’s components based on an evaluation.
Each selector instance has an
Evaluatorfor reference, and must have both the methodsget_components()andget_constraints()overridden.-
__init__(evaluator, parent=None)¶ Parameters: - evaluator (
Evaluator) – evaluator of fastener parts - parent (
Fastener) – parent object
- evaluator (
-
components¶
-
constraints¶
-
get_components()¶ Return fastener’s components
Returns: components for the fastener Return type: dictofComponentinstances
-
get_constraints()¶ Return fastener’s constraints
Returns: list of constraints Return type: listofConstraintinstances
-
Module contents¶
-
class
cqparts_fasteners.utils.Evaluator(parts, parent=None)¶ Bases:
objectAn evaluator determines which parts may be effected by a fastener, and how.
-
__init__(parts, parent=None)¶ Parameters: - parts (list of
cqparts.Part) – parts involved in fastening - parent (
Fastener) – parent object
- parts (list of
-
eval¶ Return the result of
perform_evaluation(), and buffer it so it’s only run once perEvaluatorinstance.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
locationmay 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
locationwill be important.- parts (list of
-
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
partsare contained within the sphere.
- who’s center is at
-
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:
objectFacilitates the selection and placement of a fastener’s components based on an evaluation.
Each selector instance has an
Evaluatorfor reference, and must have both the methodsget_components()andget_constraints()overridden.-
__init__(evaluator, parent=None)¶ Parameters:
-
components¶
-
constraints¶
-
get_components()¶ Return fastener’s components
Returns: components for the fastener Return type: dictofComponentinstances
-
get_constraints()¶ Return fastener’s constraints
Returns: list of constraints Return type: listofConstraintinstances
-
-
class
cqparts_fasteners.utils.Applicator(evaluator, selector, parent=None)¶ Bases:
objectThe applicator performs 2 roles to apply a fastener to workpieces
- Translate & rotate given fastener
- 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:
-
apply_alterations()¶ Apply alterations to relevant parts based on the selected parts