From 57e1bce3e7fea7365beab1e898c4e9935657695b Mon Sep 17 00:00:00 2001 From: Leni Aniva Date: Wed, 26 Jun 2024 09:48:32 -0400 Subject: [PATCH 1/2] feat: Material list --- README.md | 7 +++++++ nhf/materials.py | 19 +++++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 nhf/materials.py diff --git a/README.md b/README.md index 282f834..ae83ed0 100644 --- a/README.md +++ b/README.md @@ -15,3 +15,10 @@ and this should succeed python3 -c "import nhf" ``` +## Testing + +Run all tests with +``` sh +python3 -m unittest +``` + diff --git a/nhf/materials.py b/nhf/materials.py new file mode 100644 index 0000000..c752cd4 --- /dev/null +++ b/nhf/materials.py @@ -0,0 +1,19 @@ +""" +A catalog of material properties +""" +from enum import Enum +import cadquery as Cq + +def _color(name: str, alpha: float) -> Cq.Color: + r, g, b, _ = Cq.Color(name).toTuple() + return Cq.Color(r, g, b, alpha) + +class Material(Enum): + + WOOD_BIRCH = 0.8, _color('bisque', 0.9) + PLASTIC_PLA = 0.5, _color('azure3', 0.6) + ACRYLIC_BLACK = 0.5, _color('gray50', 0.6) + + def __init__(self, density: float, color: Cq.Color): + self.density = density + self.color = color From 1c7f218a2bdbf9772e7bdd35894b4d448568e0a4 Mon Sep 17 00:00:00 2001 From: Leni Aniva Date: Thu, 27 Jun 2024 23:26:21 -0400 Subject: [PATCH 2/2] feat: Add role for components --- nhf/materials.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/nhf/materials.py b/nhf/materials.py index c752cd4..7ac4c26 100644 --- a/nhf/materials.py +++ b/nhf/materials.py @@ -8,7 +8,25 @@ def _color(name: str, alpha: float) -> Cq.Color: r, g, b, _ = Cq.Color(name).toTuple() return Cq.Color(r, g, b, alpha) +class Role(Enum): + """ + Describes the role of a part + """ + + # Parent and child components in a load bearing joint + PARENT = _color('blue4', 0.6) + CHILD = _color('darkorange2', 0.6) + STRUCTURE = _color('gray', 0.4) + DECORATION = _color('lightseagreen', 0.4) + ELECTRONIC = _color('mediumorchid', 0.5) + + def __init__(self, color: Cq.Color): + self.color = color + class Material(Enum): + """ + A catalog of common material properties + """ WOOD_BIRCH = 0.8, _color('bisque', 0.9) PLASTIC_PLA = 0.5, _color('azure3', 0.6)