kumiki.timber¶
Flat import path
kumiki/__init__.py re-exports everything on this page via from kumiki import *, so every name below is also available directly as kumiki.CSGUnion -- you do not need to import from the submodule path shown in the heading above.
kumiki.timber
¶
Kumiki - Timber types, enums, constants, and core classes Contains all core data structures and type definitions for the timber framing system
TimberLike
module-attribute
¶
TimberLike = Union[Timber, MeshTimber, RoundTimber, RegularPolygonTimber, Board]
TimberFeature
¶
Bases: Enum
feature
¶
feature() -> TimberFeature
face
¶
face() -> TimberFace
Convert to TimberFace. Values 1-6 map to faces.
Source code in kumiki/timber.py
end
¶
end() -> TimberEnd
Convert to TimberEnd. Values 1-2 map to ends.
Source code in kumiki/timber.py
long_face
¶
long_face() -> TimberLongFace
Convert to TimberLongFace. Values 3-6 map to long faces.
Source code in kumiki/timber.py
edge
¶
edge() -> TimberEdge
Convert to TimberEdge. Values 8-19 map to edges.
Source code in kumiki/timber.py
centerline
¶
centerline() -> TimberCenterline
Convert to TimberCenterline. Value 7 maps to CENTERLINE.
Source code in kumiki/timber.py
long_edge
¶
long_edge() -> TimberLongEdge
Convert to TimberLongEdge. Values 8-11 map to long edges.
Source code in kumiki/timber.py
short_edge
¶
short_edge() -> TimberShortEdge
Convert to TimberShortEdge. Values 12-19 map to short edges.
Source code in kumiki/timber.py
corner
¶
corner() -> TimberCorner
Convert to TimberCorner. Values 20-27 map to corners.
Source code in kumiki/timber.py
TimberFace
¶
Bases: Enum
get_direction
¶
get_direction() -> Direction3D
Get the direction vector for this face in world coordinates.
Source code in kumiki/timber.py
is_perpendicular
¶
is_perpendicular(other: TimberFace) -> bool
Check if two faces are perpendicular to each other.
Perpendicular face pairs (orthogonal axes): - X-axis faces (RIGHT, LEFT) <-> Y-axis faces (FRONT, BACK) - X-axis faces (RIGHT, LEFT) <-> Z-axis faces (TOP, BOTTOM) - Y-axis faces (FRONT, BACK) <-> Z-axis faces (TOP, BOTTOM)
Source code in kumiki/timber.py
get_opposite_face
¶
get_opposite_face() -> TimberFace
Get the opposite face (the face on the opposite side of the timber).
Opposite pairs: - TOP <-> BOTTOM - RIGHT <-> LEFT - FRONT <-> BACK
Source code in kumiki/timber.py
rotate_about
¶
rotate_about(face: TimberFace) -> TimberFace
Rotate this face by 90 degrees about face's outward-normal axis
(a quarter turn using the right-hand rule around that normal).
If this face IS the rotation axis (self == face or self == face.get_opposite_face()), it lies on the axis and is unaffected by the rotation, so it is returned unchanged.
Source code in kumiki/timber.py
TimberEnd
¶
Bases: Enum
TimberLongFace
¶
Bases: Enum
is_perpendicular
¶
is_perpendicular(other: TimberLongFace) -> bool
Check if two long faces are perpendicular to each other.
Perpendicular face pairs: - RIGHT <-> FRONT, RIGHT <-> BACK - LEFT <-> FRONT, LEFT <-> BACK
Source code in kumiki/timber.py
rotate_left
¶
rotate_left() -> TimberLongFace
Rotate the long face left (90 degrees counter-clockwise).
TimberCorner
¶
Bases: Enum
TimberCenterline
¶
Bases: Enum
TimberEdge
¶
Bases: Enum
canonical_line_from_corner
¶
canonical_line_from_corner() -> Tuple[TimberCorner, TimberFace]
Returns canonical way to express a line from an edge. The line is defined by starting from the TimberCorner and pointing in the direction of the returned TimberFace's outward normal.
For long edges the line starts at the bottom corner and points toward TOP. For short edges the direction follows cross(long_face_normal, end_outward).
Source code in kumiki/timber.py
long_edge
¶
long_edge() -> TimberLongEdge
Convert to TimberLongEdge. Values 8-11 map to long edges.
Source code in kumiki/timber.py
short_edge
¶
short_edge() -> TimberShortEdge
Convert to TimberShortEdge. Values 12-19 map to short edges.
Source code in kumiki/timber.py
TimberLongEdge
¶
Bases: Enum
TimberShortEdge
¶
Bases: Enum
long_face
property
¶
long_face: TimberLongFace
Get the TimberLongFace associated with this short edge.
PerfectTimberWithin
dataclass
¶
PerfectTimberWithin(length: Numeric, size: V2, transform: Transform, ticket: TimberTicket = TimberTicket())
Bases: ABC
Base class for all timber types in the timber framing system (immutable)
This is an abstract base class (ABC) to prevent direct instantiation. All timbers contain a perfect rectangular timber within their rough bounding box.
Note: Use create_timber() factory function to construct timber instances from length_direction and width_direction vectors. Subclasses are frozen to ensure immutability after construction.
Alternatively, if you already have a Transform object, you can construct a timber directly by passing: Timber(length, size, transform, ticket)
Attributes:
| Name | Type | Description |
|---|---|---|
length |
Numeric
|
Length of the timber along its centerline axis |
size |
V2
|
Cross-sectional size (width, height) of the perfect timber within |
transform |
Transform
|
Position and orientation in global coordinates |
ticket |
TimberTicket
|
Ticket for this timber (used for rendering/debugging) |
ticket
class-attribute
instance-attribute
¶
ticket: TimberTicket = field(default_factory=TimberTicket)
__post_init__
¶
get_orientation_global
¶
get_orientation_global() -> Orientation
get_bottom_position_global
¶
get_bottom_position_global() -> V3
Get the bottom position (center of bottom cross-section) in global coordinates from the transform.
get_length_direction_global
¶
get_length_direction_global() -> Direction3D
Get the length direction vector in global coordinates from the orientation matrix
Source code in kumiki/timber.py
get_width_direction_global
¶
get_width_direction_global() -> Direction3D
Get the width direction vector in global coordinates from the orientation matrix
Source code in kumiki/timber.py
get_height_direction_global
¶
get_height_direction_global() -> Direction3D
Get the height direction vector in global coordinates from the orientation matrix
Source code in kumiki/timber.py
get_face_direction_global
¶
get_face_direction_global(face: SomeTimberFace) -> Direction3D
Get the world direction vector for a specific face of this timber.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
face
|
SomeTimberFace
|
The face to get the direction for (can be TimberFace, TimberEnd, or TimberLongFace) |
required |
Returns:
| Type | Description |
|---|---|
Direction3D
|
Direction vector pointing outward from the specified face in world coordinates |
Source code in kumiki/timber.py
get_corner_position_global
¶
get_corner_position_global(corner: TimberCorner) -> V3
Get the position of a corner in global coordinates.
Source code in kumiki/timber.py
get_size_index_in_long_face_normal_axis
¶
get_size_index_in_long_face_normal_axis(face: TimberLongFace) -> int
Get the index of the size in the direction normal to the specified face.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
face
|
TimberLongFace
|
The long face to get the size index for (RIGHT/LEFT or FRONT/BACK) |
required |
Returns:
| Type | Description |
|---|---|
int
|
Index into self.size: 0 (width) for RIGHT/LEFT, 1 (height) for FRONT/BACK |
Source code in kumiki/timber.py
get_size_in_face_normal_axis
¶
get_size_in_face_normal_axis(face: SomeTimberFace) -> Numeric
Get the size of the timber in the direction normal to the specified face.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
face
|
SomeTimberFace
|
The face to get the size for (can be TimberFace, TimberEnd, or TimberLongFace) |
required |
Returns:
| Type | Description |
|---|---|
Numeric
|
The timber's extent along the axis normal to the given face: self.length for |
Numeric
|
TOP/BOTTOM, self.size[0] (width) for RIGHT/LEFT, self.size[1] (height) for FRONT/BACK |
Source code in kumiki/timber.py
get_rough_size_in_face_normal_axis
¶
get_rough_size_in_face_normal_axis(face: SomeTimberFace) -> Numeric
Get the full rough size of the timber in the direction normal to the specified face.
For long faces this returns the sum of the two half-sizes (e.g. right + left for RIGHT or LEFT). For end faces (TOP/BOTTOM) this returns the length.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
face
|
SomeTimberFace
|
The face to get the size for (can be TimberFace, TimberEnd, or TimberLongFace) |
required |
Source code in kumiki/timber.py
get_half_rough_size_in_face_normal_axis
¶
get_half_rough_size_in_face_normal_axis(face: SomeTimberFace) -> Numeric
Get the rough half-size of the timber from the centerline to the specified face.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
face
|
SomeTimberFace
|
A long face (RIGHT, LEFT, FRONT, or BACK). TOP/BOTTOM will raise ValueError since length has no asymmetry concept. |
required |
Returns:
| Type | Description |
|---|---|
Numeric
|
The half-size from centerline to the specified face. |
Source code in kumiki/timber.py
get_nominal_size_in_face_normal_axis
¶
get_nominal_size_in_face_normal_axis(face: SomeTimberFace) -> Numeric
get_half_nominal_size_in_face_normal_axis
¶
get_half_nominal_size_in_face_normal_axis(face: SomeTimberFace) -> Numeric
get_size_in_direction_2d
¶
Get the size of the timber's cross-section measured along an arbitrary 2D direction.
The direction is in the timber's local cross-section plane where x is the width axis and y is the height axis. Returns the total extent (support width) of the rectangular cross-section projected onto that direction.
For axis-aligned directions this matches get_size_in_face_normal_axis.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
direction
|
V2
|
A 2D direction vector (x=width, y=height) in local cross-section space. Does not need to be normalized. |
required |
Returns:
| Type | Description |
|---|---|
Numeric
|
The size of the cross-section measured along the given direction. |
Source code in kumiki/timber.py
get_size_in_direction_3d
¶
get_size_in_direction_3d(direction: Direction3D) -> Numeric
Get the size of the timber measured along an arbitrary 3D direction in global space.
Transforms the direction into the timber's local frame and computes the total extent (support width) of the rectangular prism projected onto that direction.
For axis-aligned directions this matches get_size_in_face_normal_axis.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
direction
|
Direction3D
|
A 3D direction vector in global coordinates. Does not need to be normalized. |
required |
Returns:
| Type | Description |
|---|---|
Numeric
|
The size of the timber measured along the given direction. |
Source code in kumiki/timber.py
get_closest_oriented_face_from_global_direction
¶
get_closest_oriented_face_from_global_direction(target_direction: Direction3D) -> TimberFace
Find which face of this timber best aligns with the target direction.
The target_direction should point "outwards" from the desired face (not into it).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target_direction
|
Direction3D
|
Direction vector to match against |
required |
Returns:
| Type | Description |
|---|---|
TimberFace
|
The TimberFace that best aligns with the target direction |
Source code in kumiki/timber.py
get_closest_oriented_long_face_from_global_direction
¶
get_closest_oriented_long_face_from_global_direction(target_direction: Direction3D) -> TimberLongFace
Find which long face of this timber best aligns with the target direction.
The target_direction should point "outwards" from the desired face (not into it).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target_direction
|
Direction3D
|
Direction vector to match against |
required |
Returns:
| Type | Description |
|---|---|
TimberLongFace
|
The TimberLongFace that best aligns with the target direction |
Source code in kumiki/timber.py
get_closest_oriented_end_face_from_global_direction
¶
get_closest_oriented_end_face_from_global_direction(target_direction: Direction3D) -> TimberEnd
Find which end face of this timber best aligns with the target direction.
The target_direction should point "outwards" from the desired end face (not into it).
Returns:
| Type | Description |
|---|---|
TimberEnd
|
The TimberEnd that best aligns with the target direction |
Source code in kumiki/timber.py
get_inside_face_from_footprint
¶
get_inside_face_from_footprint(footprint: Footprint) -> TimberFace
Get the inside face of this timber relative to the footprint.
This method finds which face of the timber is oriented toward the interior of the footprint by: 1. Finding the nearest boundary of the footprint to the timber's centerline 2. Getting the inward normal of that boundary 3. Finding which timber face best aligns with that inward direction
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
footprint
|
Footprint
|
The footprint to determine inside/outside orientation |
required |
Returns:
| Type | Description |
|---|---|
TimberFace
|
The TimberFace that points toward the inside of the footprint |
Source code in kumiki/timber.py
get_outside_face_from_footprint
¶
get_outside_face_from_footprint(footprint: Footprint) -> TimberFace
Get the outside face of this timber relative to the footprint.
This method finds which face of the timber is oriented toward the exterior of the footprint by: 1. Finding the nearest boundary of the footprint to the timber's centerline 2. Getting the inward normal of that boundary 3. Finding which timber face best aligns with the opposite (outward) direction
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
footprint
|
Footprint
|
The footprint to determine inside/outside orientation |
required |
Returns:
| Type | Description |
|---|---|
TimberFace
|
The TimberFace that points toward the outside of the footprint |
Source code in kumiki/timber.py
get_transform_matrix
¶
get_transform_matrix() -> Matrix
Get the 4x4 transformation matrix for this timber
Source code in kumiki/timber.py
project_global_point_onto_timber_face_global
¶
project_global_point_onto_timber_face_global(global_point: V3, face: SomeTimberFace) -> V3
Project a point from global coordinates onto the timber's face and return result in global coordinates.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
global_point
|
V3
|
The point to project in global coordinates (3x1 Matrix) |
required |
face
|
SomeTimberFace
|
The face to project onto (can be TimberFace, TimberEnd, or TimberLongFace) |
required |
Source code in kumiki/timber.py
get_perfect_size
¶
get_perfect_size() -> V2
Returns the perfect cross sectional size of the timber.
The perfect size is the cross sectional size of the perfect timber within.
can_be_extended_for_joints
¶
Returns True if the timber can be extended when cutting joints.
Returns:
| Type | Description |
|---|---|
bool
|
True if the timber can be extended when cutting joints. |
get_rough_half_sizes
abstractmethod
¶
Returns the rough half-sizes of the timber measured from the centerline.
The rough bounding box is defined by four half-sizes measured from the centerline in each direction. This allows the rough timber to be non-coaxial with the perfect timber within (useful for square rule layout).
Returns:
| Type | Description |
|---|---|
Tuple[V2, V2]
|
Tuple of two V2s: - width_halves: V2(right_half, left_half) — half-sizes in the width dimension - height_halves: V2(front_half, back_half) — half-sizes in the height dimension |
Source code in kumiki/timber.py
get_nominal_half_sizes
¶
get_rough_size
¶
get_rough_size() -> V2
Returns the rough cross sectional size of the timber.
The rough size is the total cross sectional size defined by the rough half-sizes. For a perfect timber, this matches the perfect size. For an imperfect timber, this may differ and represents the intended bounding box for joint layout and intersection tests.
Source code in kumiki/timber.py
get_perfect_timber_within_csg_local
¶
get_perfect_timber_within_csg_local() -> RectangularPrism
Returns the perfect rectangular prism CSG in local coordinates.
This represents the perfect timber within as a CSG object -- the idealized, finished-dimension bounding box (self.size), not the rough/as-sawn stock boundary. All timber types have a perfect rectangular prism that bounds their actual geometry.
Returns:
| Type | Description |
|---|---|
RectangularPrism
|
RectangularPrism in local coordinates (relative to timber's bottom position) |
Source code in kumiki/timber.py
csg_label_name
classmethod
¶
What this kind of timber is called in a CSG label.
Derived from the class name -- "board", "round_timber" -- so a new timber type names itself without anyone remembering to add it here.
Source code in kumiki/timber.py
csg_label
classmethod
¶
csg_label(*qualifiers: str) -> CutCSGLabel
Label for one of this timber's own CSG shapes.
A classmethod so the name follows the derived class -- a Board's rough extended prism reads "board (rough, extended)", not "timber (...)".
Source code in kumiki/timber.py
get_actual_csg_local
¶
get_actual_csg_local() -> CutCSG
Returns the actual CSG geometry for this timber.
For the base PerfectTimberWithin class, this returns the perfect rectangular prism. Subclasses override this to return different geometries (cylinder, mesh, etc.).
Returns:
| Type | Description |
|---|---|
CutCSG
|
CutCSG representing the actual geometry in local coordinates |
Source code in kumiki/timber.py
get_extended_actual_csg_local
¶
get_extended_actual_csg_local(extend_bot: bool, extend_top: bool) -> CutCSG
Returns the actual CSG geometry extended to infinity at specified ends.
For the base PerfectTimberWithin class, this returns a rectangular prism using the perfect timber within size, optionally extended to infinity.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
extend_bot
|
bool
|
If True, extend to -infinity at bottom (z=0) |
required |
extend_top
|
bool
|
If True, extend to +infinity at top (z=length) |
required |
Returns:
| Type | Description |
|---|---|
CutCSG
|
CutCSG representing the extended geometry in local coordinates |
Source code in kumiki/timber.py
get_extended_perfect_csg_local
¶
get_extended_perfect_csg_local(extend_bot: bool, extend_top: bool) -> CutCSG
Returns the PERFECT (finished-dimension) CSG geometry extended to infinity at specified ends -- always self.get_perfect_size(), regardless of any rough/actual sizing a subclass's get_extended_actual_csg_local may use instead. Unlike get_extended_actual_csg_local, this is not overridden per-subclass: every timber type's perfect timber within is a rectangular prism (see get_perfect_timber_within_csg_local), so one implementation suffices for all of them.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
extend_bot
|
bool
|
If True, extend to -infinity at bottom (z=0) |
required |
extend_top
|
bool
|
If True, extend to +infinity at top (z=length) |
required |
Returns:
| Type | Description |
|---|---|
CutCSG
|
CutCSG representing the extended geometry in local coordinates |
Source code in kumiki/timber.py
is_face_perfect
¶
is_face_perfect(face: TimberFace) -> bool
Check if the specified face of the timber is perfect (matches the perfect timber within).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
face
|
TimberFace
|
The TimberFace to check |
required |
Source code in kumiki/timber.py
is_perfect_timber
¶
Check if this timber's actual geometry matches its rough bounding box.
Returns True when the rough half-sizes are symmetric and equal to half the perfect timber within size.
Returns:
| Type | Description |
|---|---|
bool
|
True if the timber is a perfect timber, False otherwise |
Source code in kumiki/timber.py
get_imperfect_fringe_csg_local
¶
get_imperfect_fringe_csg_local() -> CutCSG
Returns the CSG (local coordinates) of the region where this timber's actual geometry sticks out beyond its perfect-timber-within boundary, i.e. actual minus perfect.
Source code in kumiki/timber.py
Timber
dataclass
¶
Timber(length: Numeric, size: V2, transform: Transform, ticket: TimberTicket = TimberTicket(), rough_half_sizes: Optional[Tuple[V2, V2]] = None)
Bases: PerfectTimberWithin
Rectangular timber which may or may not be perfect.
Inherits all attributes and methods from PerfectTimberWithin
- length: Length of the timber
- size: Cross-sectional size (width, height)
- transform: Position and orientation
- name: Optional name
rough_half_sizes
class-attribute
instance-attribute
¶
from_perfect_timber_within
staticmethod
¶
from_perfect_timber_within(perfect_timber: PerfectTimberWithin, rough_half_sizes: Optional[Tuple[V2, V2]] = None) -> Timber
Create a Timber instance from a PerfectTimberWithin instance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
perfect_timber
|
PerfectTimberWithin
|
An instance of PerfectTimberWithin |
required |
rough_half_sizes
|
Optional[Tuple[V2, V2]]
|
Optional asymmetric half-sizes from centerline |
None
|
Source code in kumiki/timber.py
get_rough_half_sizes
¶
Returns the rough half-sizes of the timber.
If rough_half_sizes is set, returns that. Otherwise returns symmetric half-sizes derived from the perfect timber within size.
Returns:
| Type | Description |
|---|---|
Tuple[V2, V2]
|
Tuple of (V2(right_half, left_half), V2(front_half, back_half)) |
Source code in kumiki/timber.py
get_actual_csg_local
¶
get_actual_csg_local() -> CutCSG
Returns the actual CSG geometry for this timber.
For Timber, this returns a rectangular prism using the rough half-sizes, offset from the centerline when the half-sizes are asymmetric.
Returns:
| Type | Description |
|---|---|
CutCSG
|
RectangularPrism representing the actual geometry in local coordinates |
Source code in kumiki/timber.py
get_extended_actual_csg_local
¶
get_extended_actual_csg_local(extend_bot: bool, extend_top: bool) -> CutCSG
Returns the actual CSG geometry extended to infinity at specified ends.
For Timber, this returns a rectangular prism using the rough half-sizes, offset from the centerline when the half-sizes are asymmetric.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
extend_bot
|
bool
|
If True, extend to -infinity at bottom (z=0) |
required |
extend_top
|
bool
|
If True, extend to +infinity at top (z=length) |
required |
Returns:
| Type | Description |
|---|---|
CutCSG
|
CutCSG representing the extended geometry in local coordinates |
Source code in kumiki/timber.py
Board
dataclass
¶
Board(length: Numeric, size: V2, transform: Transform, ticket: TimberTicket = TimberTicket())
Bases: PerfectTimberWithin
Boards are perfect timbers with board-specific semantics
Boards are structurally identical to perfect timbers but carry additional semantics: - the "length" of the board runs in the Z direction so the TOP and BOTTOM faces are referred to as the "ends" of the board - the "width" of the board runs in the X direction so the LEFT and RIGHT faces are referred to as the "sides" of the board - the "thickness" of the board runs in the Y direction so the FRONT and BACK faces are the same as the "faces" of the board
Like timbers, we assume the grain is always running in the length direction.
Note that you can end cut along the length direction but not in the other directions so you must ensure the board dimensions are large enough to incorporate the cuts
get_rough_half_sizes
¶
Returns the rough half-sizes of the board.
For Board, these are symmetric halves of the perfect timber within size.
Returns:
| Type | Description |
|---|---|
Tuple[V2, V2]
|
Tuple of (V2(right_half, left_half), V2(front_half, back_half)) |
Source code in kumiki/timber.py
get_extended_actual_csg_local
¶
get_extended_actual_csg_local(extend_bot: bool, extend_top: bool) -> CutCSG
Returns the actual CSG geometry extended to infinity at specified ends.
For Board, this returns a rectangular prism using the perfect timber within size.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
extend_bot
|
bool
|
If True, extend to -infinity at bottom (z=0) |
required |
extend_top
|
bool
|
If True, extend to +infinity at top (z=length) |
required |
Returns:
| Type | Description |
|---|---|
CutCSG
|
CutCSG representing the extended geometry in local coordinates |
Source code in kumiki/timber.py
RoundTimber
dataclass
¶
RoundTimber(length: Numeric, size: V2, transform: Transform, ticket: TimberTicket = TimberTicket(), *, diameter: Numeric)
Bases: PerfectTimberWithin
Cylindrical timber (e.g., logs, poles)
Round timbers have a circular cross-section centered on the centerline. The rough bounding box is a square that contains the circle, but the actual geometry is a cylinder.
is_perfect_timber
¶
from_perfect_timber_within
staticmethod
¶
from_perfect_timber_within(perfect_timber: PerfectTimberWithin, diameter: Optional[Numeric] = None) -> RoundTimber
Create a Timber instance from a PerfectTimberWithin instance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
perfect_timber
|
PerfectTimberWithin
|
An instance of PerfectTimberWithin |
required |
diameter
|
Optional[Numeric]
|
Optional diameter for the round timber, if None, then the diagonal of the perfect_timber.size is used to compute the diameter. |
None
|
Source code in kumiki/timber.py
get_rough_half_sizes
¶
Returns the rough half-sizes of the round timber.
For round timbers, this is a symmetric square bounding box using the diameter.
Returns:
| Type | Description |
|---|---|
Tuple[V2, V2]
|
Tuple of (V2(d/2, d/2), V2(d/2, d/2)) |
Source code in kumiki/timber.py
get_actual_csg_local
¶
get_actual_csg_local() -> CutCSG
Returns the actual CSG geometry for this timber.
For RoundTimber, this returns a Cylinder with the specified diameter.
Returns:
| Type | Description |
|---|---|
CutCSG
|
Cylinder representing the actual geometry in local coordinates |
Source code in kumiki/timber.py
get_extended_actual_csg_local
¶
get_extended_actual_csg_local(extend_bot: bool, extend_top: bool) -> CutCSG
Returns the actual CSG geometry extended to infinity at specified ends.
For RoundTimber, this returns a Cylinder optionally extended to infinity.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
extend_bot
|
bool
|
If True, extend to -infinity at bottom (z=0) |
required |
extend_top
|
bool
|
If True, extend to +infinity at top (z=length) |
required |
Returns:
| Type | Description |
|---|---|
CutCSG
|
Cylinder representing the extended geometry in local coordinates |
Source code in kumiki/timber.py
MeshTimber
dataclass
¶
MeshTimber(length: Numeric, size: V2, transform: Transform, ticket: TimberTicket = TimberTicket())
Bases: PerfectTimberWithin
Timber represented by an arbitrary mesh geometry
This timber type uses a mesh CSG to represent complex or irregular timber geometries that cannot be represented by simple primitives.
TODO: Add mesh_csg field and override get_actual_csg_local()
get_rough_half_sizes
¶
can_be_extended_for_joints
¶
get_extended_actual_csg_local
¶
get_extended_actual_csg_local(extend_bot: bool, extend_top: bool) -> CutCSG
Returns the actual CSG geometry extended to infinity at specified ends.
For MeshTimber, this returns a rectangular prism using the perfect timber within size (the bounding box). Note: MeshTimber cannot be extended for joints.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
extend_bot
|
bool
|
If True, extend to -infinity at bottom (z=0) |
required |
extend_top
|
bool
|
If True, extend to +infinity at top (z=length) |
required |
Returns:
| Type | Description |
|---|---|
CutCSG
|
CutCSG representing the extended geometry in local coordinates |
Source code in kumiki/timber.py
RegularPolygonTimber
dataclass
¶
RegularPolygonTimber(length: Numeric, size: V2, transform: Transform, ticket: TimberTicket = TimberTicket(), *, num_sides: int)
Bases: PerfectTimberWithin
Timber with regular polygonal cross-section
This timber type has a polygonal (non-rectangular) cross-section that is extruded along the length axis. Examples include hexagonal or octagonal timbers.
The polygon is inscribed in a circle with radius equal to half the minimum dimension of the rough bounding box.
is_perfect_timber
¶
get_rough_half_sizes
¶
Returns the rough half-sizes of the polygon timber.
For polygon extrusion timbers, these are symmetric halves of the rectangular bounding box.
Returns:
| Type | Description |
|---|---|
Tuple[V2, V2]
|
Tuple of (V2(w/2, w/2), V2(h/2, h/2)) |
Source code in kumiki/timber.py
get_actual_csg_local
¶
get_actual_csg_local() -> CutCSG
Returns the actual CSG geometry for this timber.
For RegularPolygonTimber, this returns a ConvexPolygonExtrusion with the specified number of sides.
Returns:
| Type | Description |
|---|---|
CutCSG
|
ConvexPolygonExtrusion representing the actual geometry in local coordinates |
Source code in kumiki/timber.py
get_extended_actual_csg_local
¶
get_extended_actual_csg_local(extend_bot: bool, extend_top: bool) -> CutCSG
Returns the actual CSG geometry extended to infinity at specified ends.
For RegularPolygonTimber, this returns a ConvexPolygonExtrusion optionally extended to infinity.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
extend_bot
|
bool
|
If True, extend to -infinity at bottom (z=0) |
required |
extend_top
|
bool
|
If True, extend to +infinity at top (z=length) |
required |
Returns:
| Type | Description |
|---|---|
CutCSG
|
ConvexPolygonExtrusion representing the extended geometry in local coordinates |
Source code in kumiki/timber.py
Cutting
dataclass
¶
Cutting(timber: PerfectTimberWithin, maybe_top_end_cut_distance_from_bottom: Optional[Numeric] = None, maybe_bottom_end_cut_distance_from_bottom: Optional[Numeric] = None, negative_csg: Optional[CutCSG] = None, label: CutCSGLabel = NoLabel(), assembly_freedom: Optional[AssemblyFreedom] = None, assembly_ordering: Ordering = Ordering())
A set of cuts on a timber (to create a joint, for example), defined by a CSG object representing the volume to be removed.
The CSG object represents the volume to be REMOVED from the timber (negative CSG), in LOCAL coordinates (relative to timber.bottom_position).
maybe_top_end_cut_distance_from_bottom
class-attribute
instance-attribute
¶
maybe_top_end_cut_distance_from_bottom: Optional[Numeric] = None
maybe_bottom_end_cut_distance_from_bottom
class-attribute
instance-attribute
¶
maybe_bottom_end_cut_distance_from_bottom: Optional[Numeric] = None
label
class-attribute
instance-attribute
¶
label: CutCSGLabel = field(default_factory=CutCSGLabel.NoLabel)
assembly_freedom
class-attribute
instance-attribute
¶
assembly_freedom: Optional[AssemblyFreedom] = None
get_maybe_top_end_cut
¶
get_maybe_top_end_cut() -> Optional[HalfSpace]
Return the top end cut HalfSpace derived from distance metadata.
Source code in kumiki/timber.py
get_maybe_bottom_end_cut
¶
get_maybe_bottom_end_cut() -> Optional[HalfSpace]
Return the bottom end cut HalfSpace derived from distance metadata.
Source code in kumiki/timber.py
get_negative_csg_local
¶
get_negative_csg_local() -> Optional[CutCSG]
Get the complete negative CSG including end cuts.
Returns the union of negative_csg with any end cuts that are defined, or None when this cutting removes nothing at all.
Source code in kumiki/timber.py
make_end_cut_distance_from_bottom
staticmethod
¶
make_end_cut_distance_from_bottom(timber: PerfectTimberWithin, end: TimberEnd, distance_from_end_to_cut: Numeric) -> Numeric
Convert distance-from-end to cut-plane distance from timber bottom.
Source code in kumiki/timber.py
CutTimber
¶
CutTimber(timber: PerfectTimberWithin, cuts: Optional[List[Cutting]] = None, joints: Optional[List[Joint]] = None)
A timber with cuts applied to it.
Create a CutTimber from a Timber.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
timber
|
PerfectTimberWithin
|
The timber to be cut |
required |
cuts
|
Optional[List[Cutting]]
|
List of cuts to apply (default: empty list) |
None
|
joints
|
Optional[List[Joint]]
|
Joints this timber participates in (default: empty list). Populated by the from_joints constructors. Anything asking "which joint produced this cut?" reads it, so a CutTimber built by hand simply cannot answer that -- which is the honest outcome, since by hand there is no joint to name. |
None
|
Source code in kumiki/timber.py
resolve_joint_path
¶
Which of this timber's joints a name refers to.
A list, for the same reason Frame.resolve_timber_path returns one: two identical joints on one timber -- both ends of a brace -- share a name, and pretending a name means one joint quietly picks whichever was cut first. Where it does match several the reference stops being stable, so it warns.
Counted over this timber's cuts, in order, which is what the cut labels and the CSG paths below them are numbered by.
Source code in kumiki/timber.py
from_joints
classmethod
¶
from_joints(timber: PerfectTimberWithin, joints: List[Joint]) -> CutTimber
Build a CutTimber for timber by collecting every Cutting across joints
whose Cutting.timber is this exact timber (matched by identity -- the same
matching Frame.from_joints uses to merge cuttings for a timber across the
whole frame).
Useful when a joint function needs "this timber's actual body so far" (e.g.
cut_free_house_joint's housed_timbers) but the timber has cuts from more than
one joint (e.g. a corner miter plus a roundover decoration): rather than
manually picking which Joint.cuttings key belongs to which timber (easy to
mix up -- see cuttings["timberA"] vs cuttings["timberB"]), this collects
every relevant cutting automatically, in the order joints are given.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
timber
|
PerfectTimberWithin
|
The timber to build a CutTimber for |
required |
joints
|
List[Joint]
|
Joints to search for cuttings on |
required |
Returns:
| Type | Description |
|---|---|
CutTimber
|
CutTimber wrapping |
Source code in kumiki/timber.py
render_timber_with_cuts_csg_local
¶
render_timber_with_cuts_csg_local() -> CutCSG
Returns a CSG representation of the timber with all cuts applied.
Returns:
| Type | Description |
|---|---|
CutCSG
|
Difference CSG representing the timber with all cuts subtracted |
Source code in kumiki/timber.py
get_perfect_timber_within_bounding_box_prism
¶
get_perfect_timber_within_bounding_box_prism() -> RectangularPrism
Get the bounding box prism for this timber cropped based on its end cuts if any, otherwise the original perfet timber within box is produced. The bounding box is aligned with the timber's orientation.
Uses PerfectTimberWithin size to determine the cross-sectional size of the bounding box. Uses the end cuts (maybe_top_end_cut and maybe_bottom_end_cut) to determine the extent of the timber along its length. For skewed end cuts, finds where the plane intersects the four long edges of the timber and takes the max/min.
Returns:
| Name | Type | Description |
|---|---|---|
RectangularPrism |
RectangularPrism
|
The bounding box for the cut timber in global coordinates |
Source code in kumiki/timber.py
get_rough_bounding_box_prism
¶
get_rough_bounding_box_prism() -> RectangularPrism
Get the bounding box prism for this timber's ROUGH (as-sawn) cross-section, cropped in length the same way as get_perfect_timber_within_bounding_box_prism (the most restrictive end cut across every Cutting on this timber -- the frame's aggregated outer length trims, not each joint's own internal cut geometry).
Unlike the perfect-timber-within box, the rough box may be off-center from the timber's centerline (see get_rough_half_sizes -- e.g. for square-rule layout) and is generally larger than the perfect/finished size.
Returns:
| Name | Type | Description |
|---|---|---|
RectangularPrism |
RectangularPrism
|
The rough bounding box for the cut timber, in global coordinates |
Source code in kumiki/timber.py
get_bounding_box_prism
¶
get_bounding_box_prism() -> RectangularPrism
DEPRECATED_approximate_bounding_prism
¶
DEPRECATED_approximate_bounding_prism() -> RectangularPrism
TODO someday we want a fully analytical solution for this, but for now this is sufficient for our needs.
Get the bounding box prism for this timber including all its cuts. The bounding box is aligned with the timber's orientation.
Uses a hybrid approach: analytical methods for simple cases (HalfSpace cuts), and sampling for complex CSG operations. Works with all CSG types and orientations.
Returns:
| Name | Type | Description |
|---|---|---|
RectangularPrism |
RectangularPrism
|
The bounding box for the cut timber in global coordinates |
Source code in kumiki/timber.py
2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 | |
Accessory
dataclass
¶
Accessory(*, ticket: AccessoryTicket = AccessoryTicket(), assembly_freedom: Optional[AssemblyFreedom] = None, assembly_ordering: Ordering = Ordering())
Bases: ABC
Base class for joint accessories like wedges, drawbores, etc.
ticket
class-attribute
instance-attribute
¶
ticket: AccessoryTicket = field(default_factory=AccessoryTicket, kw_only=True)
assembly_freedom
class-attribute
instance-attribute
¶
assembly_freedom: Optional[AssemblyFreedom] = field(default=None, kw_only=True)
assembly_ordering
class-attribute
instance-attribute
¶
get_csg_local
abstractmethod
¶
get_csg_local() -> CutCSG
Generate CSG representation of the accessory in local space.
The local space is defined by the accessory's orientation and position, where the CSG is generated at the origin with identity orientation.
Returns:
| Name | Type | Description |
|---|---|---|
CutCSG |
CutCSG
|
The CSG representation of the accessory in local space |
Source code in kumiki/timber.py
PegShape
¶
Peg
dataclass
¶
Peg(transform: Transform, size: Numeric, shape: PegShape, forward_length: Numeric, stickout_length: Numeric, *, ticket: AccessoryTicket = AccessoryTicket(), assembly_freedom: Optional[AssemblyFreedom] = None, assembly_ordering: Ordering = Ordering())
Bases: Accessory
Represents a peg used in timber joinery (e.g., draw bore pegs, komisen).
The peg is stored in GLOBAL SPACE with absolute position and orientation. In identity orientation, the peg points in the +Z direction, with the insertion end at the origin.
By convention, the origin of the peg is on the mortise face that the peg is going into. This is why there are 2 lengths parameters, one for how deep the peg goes past the mortise face, and one for how far the peg sticks out of the mortise face.
Attributes:
| Name | Type | Description |
|---|---|---|
transform |
Transform
|
Transform (position and orientation) of the peg in global space |
size |
Numeric
|
Size/diameter of the peg (for square pegs, this is the side length) |
shape |
PegShape
|
Shape of the peg (SQUARE or ROUND) |
forward_length |
Numeric
|
How far the peg reaches in the forward direction (into the mortise) |
stickout_length |
Numeric
|
How far the peg "sticks out" in the back direction (outside the mortise) |
get_csg_local
¶
get_csg_local() -> CutCSG
Generate CSG representation of the peg in local space.
The peg is centered at the origin with identity orientation, extending from -stickout_length to forward_length along the Z axis.
Returns:
| Name | Type | Description |
|---|---|---|
CutCSG |
CutCSG
|
The CSG representation of the peg |
Source code in kumiki/timber.py
WedgeShape
dataclass
¶
Wedge
dataclass
¶
Wedge(transform: Transform, base_width: Numeric, tip_width: Numeric, height: Numeric, length: Numeric, stickout_length: Numeric = scalar(0), *, ticket: AccessoryTicket = AccessoryTicket(), assembly_freedom: Optional[AssemblyFreedom] = None, assembly_ordering: Ordering = Ordering())
Bases: Accessory
Represents a wedge used in timber joinery (e.g., wedged tenons).
The wedge is stored in local space of a timber. In identity orientation, the pointy end of the wedge goes in the length direction of the timber.
The profile of the wedge (trapezoidal shape) is in the Y axis (height in Y). The width of the wedge is in the X axis. The origin (0,0) is at the bottom center of the longer side of the triangle.
Visual representation (looking at wedge from the side):
+z
_ <- tip width
/ \ \
/ \ \ +y
-x /____\ <- base width
↑
origin
get_csg_local
¶
get_csg_local() -> CutCSG
Generate CSG representation of the wedge in local space.
The wedge is created using a polyline extrusion (ConvexPolygonExtrusion) with a trapezoidal profile in the XZ plane. The base is at z=0 with base_width, and the tip is at z=length with tip_width. The extrusion extends along Y from -height/2 to height/2.
The polygon profile is a trapezoid in the XZ plane: - Base at z=0 with width = base_width (centered at x=0) - Tip at z=length with width = tip_width (centered at x=0)
The transform is rotated so that +Y goes to +Z (rotation around X axis by +90°).
Returns:
| Name | Type | Description |
|---|---|---|
CutCSG |
CutCSG
|
The CSG representation of the wedge |
Source code in kumiki/timber.py
2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 | |
CSGAccessory
dataclass
¶
CSGAccessory(transform: Transform, positive_csg: CutCSG, *, ticket: AccessoryTicket = AccessoryTicket(), assembly_freedom: Optional[AssemblyFreedom] = None, assembly_ordering: Ordering = Ordering())
Bases: Accessory
Generic accessory represented as local-space positive CSG plus a global transform.
Sticker
dataclass
¶
Sticker(transform: Transform, size: Numeric = inches(1), *, ticket: AccessoryTicket = AccessoryTicket(), assembly_freedom: Optional[AssemblyFreedom] = None, assembly_ordering: Ordering = Ordering())
Bases: Accessory
Just a marking used for debugging (ball at center + shaft in local +Z).
get_csg_local
¶
get_csg_local() -> CutCSG
Source code in kumiki/timber.py
Joint
dataclass
¶
Joint(cuttings: Dict[str, Cutting], ticket: JointTicket, jointAccessories: Dict[str, Accessory] = dict())
jointAccessories
class-attribute
instance-attribute
¶
jointAccessories: Dict[str, Accessory] = field(default_factory=dict)
__post_init__
¶
Source code in kumiki/timber.py
is_decorative
¶
with_order
¶
with_order(order: Union[int, Mapping[str, int], Iterable[Tuple[Union[str, PerfectTimberWithin, Accessory], int]]]) -> Joint
Return a copy of this joint with assembly order(s) assigned.
Assembly freedoms and suborders are authored by the cut functions; the order is the frame-level plan and is assigned here, after cutting (smaller order = extracted earlier during disassembly).
with_order(n): sets order=n on every cutting and accessory, keeping their suborders, so intra-joint sequencing (peg pops before the tenon slides) is preserved within step n.
with_order({key: n, ...}) or with_order([(member, n), ...]): sets Ordering(n, 0) on each named member — referenced by cutting/accessory string key, or by the timber / accessory object itself (a timber reference applies to every cutting holding it; use the pair-list form for object references, which are unhashable). Unnamed members keep their current ordering. Raises ValueError for unknown references, or when the new orderings break the strict precedence the cut function expressed via suborders (any member pair previously strictly ordered must remain strictly ordered).
Assign orders BEFORE building the Frame: this rebuilds the member objects (dataclasses.replace, preserving timber references), so a Frame built earlier would still hold the previous orderings.
Source code in kumiki/timber.py
2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 | |
Frame
dataclass
¶
Frame(cut_timbers: List[CutTimber], accessories: List[Accessory] = list(), name: Optional[str] = None, source_joints: Optional[List] = None, footprints: List[Footprint] = list(), drawings: List[Drawing] = list())
Represents a complete timber frame structure with all cut timbers and accessories.
In traditional timber framing, a 'frame' is the complete structure ready for raising. This class encapsulates all the timbers that have been cut with their joints, plus any accessories like pegs, wedges, or drawbores.
Attributes:
| Name | Type | Description |
|---|---|---|
cut_timbers |
List[CutTimber]
|
List of CutTimber objects representing all timbers in the frame |
accessories |
List[Accessory]
|
List of Accessory objects (already in global space) |
name |
Optional[str]
|
Optional name for this frame (e.g., "Oscar's Shed", "Main Frame") |
accessories
class-attribute
instance-attribute
¶
accessories: List[Accessory] = field(default_factory=list)
source_joints
class-attribute
instance-attribute
¶
footprints
class-attribute
instance-attribute
¶
footprints: List[Footprint] = field(default_factory=list)
resolve_timber_path
¶
resolve_timber_path(path: TimberPath) -> List[ResolvedTimberPath]
Which timbers a name refers to, in this frame.
A list, because a name may match several: paths are not required to be unique, and pretending one always means one timber would quietly pick whichever came first. Where it does match several, the reference stops being stable -- each is then told apart by the order the frame built them, so inserting another above them moves every reference below. That is worth saying out loud rather than discovering later, so it warns.
Source code in kumiki/timber.py
timber_paths
¶
timber_paths() -> List[TimberPath]
Every name in the frame, in order, duplicates included.
from_joints
classmethod
¶
from_joints(joints: List[Joint], additional_unjointed_timbers: Optional[List[PerfectTimberWithin]] = None, name: Optional[str] = None) -> Frame
Create a Frame from a list of joints and optional additional unjointed timbers.
This constructor extracts all cut timbers and accessories from the joints, and combines cut timbers that share the same underlying timber reference.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
joints
|
List[Joint]
|
List of Joint objects |
required |
additional_unjointed_timbers
|
Optional[List[PerfectTimberWithin]]
|
Optional list of PerfectTimberWithin objects that don't participate in any joints (default: empty list) |
None
|
name
|
Optional[str]
|
Optional name for the frame |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
Frame |
Frame
|
A new Frame object with merged cut timbers and collected accessories |
Raises:
| Type | Description |
|---|---|
ValueError
|
If two timbers with the same name but same underlying timber have different references (indicates a bug) |
Source code in kumiki/timber.py
2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 | |
get_bounding_box
¶
Get the axis-aligned bounding box for the entire frame in global coordinates.
This computes the bounding box by getting the bounding prism for each cut timber and finding the global min/max coordinates that enclose all of them.
Returns:
| Type | Description |
|---|---|
tuple[V3, V3]
|
tuple[V3, V3]: (min_corner, max_corner) where each is a 3x1 Matrix representing the minimum and maximum corners of the axis-aligned bounding box in global coordinates |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the frame contains no cut timbers |
Source code in kumiki/timber.py
2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 | |
KumikiArrangementError
¶
Bases: ValueError
Raised when a timber arrangement or joint parameter fails a validation check.
Unlike AssertionError, this survives python -O and is safe for callers to
catch specifically when handling invalid joint/arrangement configurations.
compute_timber_orientation
¶
compute_timber_orientation(length_direction: Direction3D, width_direction: Direction3D) -> Orientation
Compute the orientation matrix from length and width directions
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
length_direction
|
Direction3D
|
Direction vector for the length axis as 3D vector, the +length direction is the +Z direction |
required |
width_direction
|
Direction3D
|
Direction vector for the width axis as 3D vector, the +width direction is the +X direction |
required |
Returns:
| Type | Description |
|---|---|
Orientation
|
Orientation object representing the timber's orientation in 3D space |
Source code in kumiki/timber.py
create_timber
¶
create_timber(length: Numeric, size: V2, bottom_position: V3, length_direction: Direction3D, width_direction: Direction3D, ticket: Optional[Union[TimberTicket, str]] = None) -> Timber
Factory function to create a Timber with computed orientation from direction vectors
This is the main way to construct Timber instances. It takes direction vectors and computes the proper orientation matrix automatically.
AGENT NOTE: AVOID this function if possible, prefer methods like join_timber, attach_timber, create_*_timber_on_footprint, or even create_axis_aligned_timber, which are more robust and easier to use.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
length
|
Numeric
|
Length of the timber |
required |
size
|
V2
|
Cross-sectional size (width, height) as 2D vector, width is the X dimension (left to right), height is the Y dimension (front to back) |
required |
bottom_position
|
V3
|
Position of the bottom point (center of cross-section) as 3D vector |
required |
length_direction
|
Direction3D
|
Direction vector for the length axis as 3D vector, the +length direction is the +Z direction |
required |
width_direction
|
Direction3D
|
Direction vector for the width axis as 3D vector, the +width direction is the +X direction |
required |
ticket
|
Optional[Union[TimberTicket, str]]
|
Optional ticket for this timber (can be TimberTicket object or string name, used for rendering/debugging) |
None
|
Returns:
| Type | Description |
|---|---|
Timber
|
Timber instance with computed orientation |
Source code in kumiki/timber.py
did_end_cuts_extend_timber
¶
did_end_cuts_extend_timber(timber: PerfectTimberWithin, cuts: List[Cutting]) -> bool
Check if any end cuts extend beyond the timber's original bounds.
An end cut extends beyond if: - Top cut: The cutting plane is at z > timber.length (cuts beyond the top) - Bottom cut: The cutting plane is at z < 0 (cuts beyond the bottom)
In local coordinates, HalfSpace end cuts are defined with: - Top cuts: normal pointing up (+Z), offset at the cut location - Bottom cuts: normal pointing down (-Z), offset at the cut location (negative value)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
timber
|
PerfectTimberWithin
|
The timber being cut |
required |
cuts
|
List[Cutting]
|
List of cuts on the timber |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if any end cut extends beyond the timber's original length |
Source code in kumiki/timber.py
make_compound_joint
¶
make_compound_joint(joints: List[Joint], ticket: JointTicket) -> Joint
Create a compound joint that combines multiple joints together.
The cuttings and accessories from all joints are merged into a single Joint object. Numeric suffixes are added to accessory and cutting keys if there are conflicts. The tickets of the input joints are ignored.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
joints
|
List[Joint]
|
List of Joint objects to combine |
required |
ticket
|
JointTicket
|
JointTicket for the compound joint |
required |
Source code in kumiki/timber.py
require_check
¶
add_milestone
¶
Emit a milestone marker for the viewer loading screen.
Writes a JSON protocol message to the real stdout pipe so the viewer extension can display progress during script execution. No-ops when not running inside the Kigumi extension (checks KIGUMI_VIEWER_MILESTONES environment variable).
Source code in kumiki/timber.py
solve_frame_assembly
¶
solve_frame_assembly(frame: Frame, should_cancel: Optional[Callable[[], bool]] = None) -> Optional[AssemblySolution]
Solve the disassembly sequence for a frame's source joints.
Adapts the frame into the abstract assembly graph of kumiki/assembly.py — one AssemblyMember per distinct timber/accessory (keyed by ticket kumiki_id, positioned at the timber centroid) and one AssemblyJoint per source joint — then delegates to solve_assembly.
Returns None when no member of any source joint has an assembly freedom.
Source code in kumiki/timber.py
3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 | |