Parts and frames
Definitions own local geometry and manufacturing intent; an
assembly supplies installed placement. Part.build()
returns local geometry. Part.build_for_print() applies the declared fabrication
orientation and moves the result onto the bed.
Bodies can be native CadQuery shapes or explicit cadkit.geometry.Mesh values.
Native-only manufacturing features, finishing callbacks and sheet validation
require native bodies. Mesh parts retain their provenance and export STL, with
explicit omission reporting for STEP.
Manufacturing groups, notes, production inclusion and expected solid counts belong to the Part. See Project inventory for uninstalled coupons, variants and quantity overrides.
Part
dataclass
Part(
name: str,
body: Callable,
manufacture: FDM | LaserCut,
features: Mapping[str, Feature] = dict(),
ports: Mapping[str, Frame] = dict(),
finalize: Callable | None = None,
*,
group: str = "parts",
description: str = "",
production: bool = True,
expected_solids: int | None = 1,
notes: str = ""
)
An immutable local definition with owned features and attachment ports.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Stable artifact name using letters, numbers, |
required |
body
|
Callable
|
Zero-argument builder returning a valid native solid, explicit
native compound or |
required |
manufacture
|
FDM | LaserCut
|
Explicit |
required |
features
|
Mapping[str, Feature]
|
Named feature objects, applied in mapping insertion order. |
dict()
|
ports
|
Mapping[str, Frame]
|
Named local Frames for composition; these do not cut geometry. |
dict()
|
finalize
|
Callable | None
|
Optional callable receiving the featured Shape and returning a native result, for operations such as final edge finishing. |
None
|
group
|
str
|
Manufacturing group used by selection and quantity reports. |
'parts'
|
description
|
str
|
Short description of the manufactured part. |
''
|
production
|
bool
|
Include this definition in the default |
True
|
expected_solids
|
int | None
|
Positive expected solid count, or None for a variable count. |
1
|
notes
|
str
|
Markdown manufacturing notes. |
''
|
Mappings are copied and exposed read-only. Building starts with a copy of the body. Assembly placement never changes this reusable definition.
build_for_print
Build fabrication geometry, applying its print transform and placing it on Z=0.
Returns:
| Type | Description |
|---|---|
Shape | Mesh
|
Fabrication geometry. This never changes installed
placement or the result of |
Feature protocol
Built-in manufacturing features and mount roles satisfy this protocol. A custom feature must return valid native geometry and describe its own manufacturing intent.
Feature
Bases: Protocol
Protocol for a named operation owned by one declarative Part.
Attributes:
| Name | Type | Description |
|---|---|---|
at |
Frame
|
Local manufacturing datum. |
apply(body) returns a native CadQuery solid. describe() returns
JSON-compatible feature metadata, optionally including manufacturing
operations. Features run in mapping insertion order.
Manufacturing processes
FDM("PETG", print_rotation=(90, 0, 0)) applies explicit X/Y/Z angles for
fabrication. When the design-to-fabrication transform is already known, use
FDM("PETG", print_frame=ck.Frame(...)) instead. A print_frame cannot be
combined with nonzero print_rotation. Both paths move the final lowest Z
point onto the bed without changing installed assembly geometry.
FDM
dataclass
FDM(
material: str,
print_rotation: tuple = (0, 0, 0),
*,
print_frame: Frame | None = None
)
Manufacturing metadata for a fused-deposition printed part.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
material
|
str
|
Explicit material name; use |
required |
print_rotation
|
tuple
|
Finite X, Y, Z angles in degrees. Applied only by the fabrication builder, never during local assembly placement. |
(0, 0, 0)
|
print_frame
|
Frame | None
|
Optional rigid transform from design to fabrication coordinates.
Used instead of a nonzero |
None
|
LaserCut
dataclass
A native blank cut from explicitly dimensioned sheet stock.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
material
|
str
|
Sheet material name; use |
required |
thickness
|
float
|
Positive sheet thickness in millimetres, along local Z. |
required |
Validation compares the final body's Z extent with thickness. It does not
prove constant cross-section or generate a machine-ready cutting toolpath.
Purchased components
Purchased
dataclass
Purchased(
name: str,
body: Callable,
ports: Mapping[str, Frame] = dict(),
features: Mapping = dict(),
description: str = "",
supplier: str = "",
sku: str = "",
representation: str = "envelope",
quantity: int = 1,
)
A supplied component with local geometry and attachment datums.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Stable definition name. |
required |
body
|
Callable
|
Zero-argument builder returning a valid native solid, native
compound, or explicit |
required |
ports
|
Mapping[str, Frame]
|
Named local Frames. |
dict()
|
features
|
Mapping
|
Explicit feature operations. Use |
dict()
|
description
|
str
|
Human-readable component description. |
''
|
supplier
|
str
|
Supplier name for the purchased BOM. |
''
|
sku
|
str
|
Supplier identifier for the purchased BOM. |
''
|
representation
|
str
|
|
'envelope'
|
quantity
|
int
|
Positive supplier quantity represented by each assembly instance. |
1
|
Purchased objects are not exported as manufactured Parts by as_project().
An envelope does not establish exact supplier fit.
Frame
A Frame specifies orientation with two perpendicular axes, rather than Euler
angles. Use Frame(origin=(0, 0, 10), z=(0, 0, -1)) for a downward-facing entry
at Z=10. A frame is a datum; it does not itself move or cut the body.
Frame
dataclass
An orthonormal local datum in millimetres.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
origin
|
tuple
|
XYZ position in millimetres. |
(0, 0, 0)
|
z
|
tuple
|
Positive local Z direction; normalized on construction. |
(0, 0, 1)
|
x
|
tuple
|
Positive local X direction; normalized and required perpendicular to Z. |
(1, 0, 0)
|
Local Y follows the right-handed CadQuery plane convention. All coordinates must be finite. Manufacturing features and mounts assign different meanings to Z; consult the feature or mount reference before reusing a datum.
from_location
classmethod
Convert a native CadQuery Location into an explicit Frame.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
location
|
Location
|
Rigid translation and rotation. |
required |
Returns:
| Type | Description |
|---|---|
Frame
|
Origin and orthonormal axes of the location. |
Patterns
Patterns live in a feature's local XY plane. For a rectangular four-hole pattern, for example:
PointPattern
dataclass
Explicit sites in a feature's local XY plane.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
points
|
tuple[tuple[float, float], ...]
|
Nonempty, distinct |
((0, 0),)
|
PolarPattern
dataclass
Distinct sites on a circle in a feature's local XY plane.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
radius
|
float
|
Positive pattern radius in millimetres. |
required |
angles
|
tuple[float, ...]
|
Nonempty tuple of finite angles in degrees, measured from +X toward +Y. Angles equivalent modulo 360 are rejected as duplicates. |
required |