cqparts.constraint package¶
Submodules¶
cqparts.constraint.base module¶
cqparts.constraint.constraints module¶
-
class
cqparts.constraint.constraints.
Coincident
(mate, to_mate)¶ Bases:
cqparts.constraint.base.Constraint
Set a component’s world coordinates of
mate.component
so thatmate.world_coords
==to_mate.world_coords
.To successfully determine the component’s location, the relative component must be solvable.
-
class
cqparts.constraint.constraints.
Fixed
(mate, world_coords=None)¶ Bases:
cqparts.constraint.base.Constraint
Sets a component’s world coordinates so the given
mate
is positioned and orientated to the givenworld_coords
.There is only 1 possible solution.
-
__init__
(mate, world_coords=None)¶ Parameters: - mate (
Mate
) – mate to lock - world_coords (
CoordSystem
) – world coordinates to lockmate
to
Raises: TypeError – if an invalid parameter type is passed
If the
world_coords
parameter is set as aMate
instance, the mate’s.world_coords
is used.If
world_coords
isNone
, the object is locked to the origin.- mate (
-
cqparts.constraint.mate module¶
-
class
cqparts.constraint.mate.
Mate
(component, local_coords=None)¶ Bases:
object
A mate is a coordinate system relative to a component’s origin.
-
__add__
(other)¶ Parameters: other – the object being added Behaviour based on type being added:
Mate
+CoordSystem
:Return a copy of
self
withother
added to.local_coords
Raises: TypeError – if type of other
is not supported
-
__init__
(component, local_coords=None)¶ Parameters: - component (
Component
) – component the mate is relative to - local_coords (
CoordSystem
) – coordinate system of mate relative to component’s origin
If
component
is explicitly set to None, the mate’sworld_coords()
==local_coords
.If
local_coords
is not set, the component’s origin is used (ie: coords at0,0,0
, with no rotation)- component (
-
world_coords
¶ Returns: world coordinates of mate. Return type: CoordSystem
Raises: ValueError – if .component
does not have valid world coordinates.If
.component
isNone
, then the.local_coords
are returned.
-
cqparts.constraint.solver module¶
-
cqparts.constraint.solver.
solver
(constraints, coord_sys=None)¶ Solve constraints. Solutions pair
Constraint
instances with their suitableCoordSystem
world coordinates.Parameters: - constraints (iterable of
Constraint
) – constraints to solve - coord_sys (
CoordSystem
) – coordinate system to offset solutions (default: no offset)
Returns: generator of (
Component
,CoordSystem
) tuples.- constraints (iterable of
Module contents¶
-
class
cqparts.constraint.
Mate
(component, local_coords=None)¶ Bases:
object
A mate is a coordinate system relative to a component’s origin.
-
__add__
(other)¶ Parameters: other – the object being added Behaviour based on type being added:
Mate
+CoordSystem
:Return a copy of
self
withother
added to.local_coords
Raises: TypeError – if type of other
is not supported
-
__init__
(component, local_coords=None)¶ Parameters: - component (
Component
) – component the mate is relative to - local_coords (
CoordSystem
) – coordinate system of mate relative to component’s origin
If
component
is explicitly set to None, the mate’sworld_coords()
==local_coords
.If
local_coords
is not set, the component’s origin is used (ie: coords at0,0,0
, with no rotation)- component (
-
world_coords
¶ Returns: world coordinates of mate. Return type: CoordSystem
Raises: ValueError – if .component
does not have valid world coordinates.If
.component
isNone
, then the.local_coords
are returned.
-
-
class
cqparts.constraint.
Constraint
¶ Bases:
object
A means to limit the relative position &/or motion of 1 or more components.
Constraints are combined and solved to set world coordinates of the components within an assembly.
-
class
cqparts.constraint.
Fixed
(mate, world_coords=None)¶ Bases:
cqparts.constraint.base.Constraint
Sets a component’s world coordinates so the given
mate
is positioned and orientated to the givenworld_coords
.There is only 1 possible solution.
-
__init__
(mate, world_coords=None)¶ Parameters: - mate (
Mate
) – mate to lock - world_coords (
CoordSystem
) – world coordinates to lockmate
to
Raises: TypeError – if an invalid parameter type is passed
If the
world_coords
parameter is set as aMate
instance, the mate’s.world_coords
is used.If
world_coords
isNone
, the object is locked to the origin.- mate (
-
-
class
cqparts.constraint.
Coincident
(mate, to_mate)¶ Bases:
cqparts.constraint.base.Constraint
Set a component’s world coordinates of
mate.component
so thatmate.world_coords
==to_mate.world_coords
.To successfully determine the component’s location, the relative component must be solvable.