Source code for pyboxbuilder.builders.cap_path

# SPDX-License-Identifier: Apache-2.0
"""CapPathBoxBuilder — typed builder for cap-path lid boxes."""

from dataclasses import dataclass
from typing import ClassVar

from pyboxbuilder.builders._base import BoxBuilder
from pyboxbuilder.enums import BoxType


[docs] @dataclass(frozen=True) class CapPathBoxBuilder(BoxBuilder): """Builder for cap-path lid box type. Example: .. pythonscad-example:: project = Project("CapPathDemo") l_path = ( (0.0, 0.0), (55.0, 0.0), (55.0, 25.0), (25.0, 25.0), (25.0, 55.0), (0.0, 55.0), ) project.box( BoxType.CAP_PATH, "CapPathTray", size=(55.0, 55.0, 20.0), path=l_path, color=Color("teal"), lid=LidBuilder( label_mode=LabelMode.FRAMED, text_color=Color("white"), frame_color=Color("silver"), border_margin_mm=3.0, pattern=PatternBuilder(PatternType.HEX, spacing=8.0), ).titled("PARTS"), ) project.show(show_lids=True) """ box_type: ClassVar[BoxType] = BoxType.CAP_PATH path: tuple[tuple[float, float], ...] = () """Closed 2D outline of the tray footprint, in mm, in the box's own frame.""" cap_height: float | None = None """Skirt height in mm; None derives it from the box height.""" hollow: bool = True """False produces a solid block instead of a walled tray.""" def __post_init__(self) -> None: """Normalize path points to immutable tuples of floats.""" super().__post_init__() if self.path: object.__setattr__( self, "path", tuple((float(pt[0]), float(pt[1])) for pt in self.path), )