Skip to content

Commit

Permalink
Added 3.5 HDD shelf
Browse files Browse the repository at this point in the history
  • Loading branch information
jmwright committed Oct 21, 2024
1 parent fecd168 commit 966d888
Show file tree
Hide file tree
Showing 3 changed files with 120 additions and 7 deletions.
35 changes: 35 additions & 0 deletions nimble_build_system/cad/device_placeholder.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,39 @@ def generate_nuc(device_name, width, depth, height):
return placeholder


def generate_hdd(device_name, width, depth, height):
"""
Generates a 3.5" HDD placeholder model.
"""

# The overall shape
placeholder = cq.Workplane().box(width, depth, height)

# Add the holes in the first side
hole_locations = [
(0.0, -6.35, 0.0),
(101.6 / 2.0, -6.35, 0.0),
(-101.6 / 2.0, -6.35, 0.0)
]
placeholder = (placeholder
.faces("<Y")
.workplane()
.pushPoints(hole_locations)
.hole(3.5, depth=5.0))

# Round the edges
placeholder = placeholder.edges("|Z").fillet(3.0)

# Add the text of what the device is to the top
placeholder = (placeholder.faces(">Z")
.workplane(centerOption="CenterOfBoundBox")
.text(device_name.replace(" shelf", ""),
fontsize=6,
distance=-0.1))

return placeholder


def generate_placeholder(device_name, width, depth, height):
"""
Generates a generalized placeholder object for a device.
Expand All @@ -173,6 +206,8 @@ def generate_placeholder(device_name, width, depth, height):
elif "nuc" in device_name.lower():
# The overall shape
placeholder = generate_nuc(device_name, width, depth, height)
elif "hdd" in device_name.lower():
placeholder = generate_hdd(device_name, width, depth, height)
else:
# The overall shape
placeholder = generate_generic(device_name, width, depth, height, smallest_dim)
Expand Down
76 changes: 75 additions & 1 deletion nimble_build_system/cad/shelf.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import cadquery as cq
import cadquery_png_plugin.plugin # This activates the PNG plugin for CadQuery
import cadscript
from cq_warehouse.fastener import ButtonHeadScrew, CounterSunkScrew
from cq_warehouse.fastener import ButtonHeadScrew, CounterSunkScrew, PanHeadScrew
from cq_annotate.views import explode_assembly
from cq_annotate.callouts import add_assembly_lines

Expand Down Expand Up @@ -491,6 +491,12 @@ def generate_assembly_model(self, explode=False):
fastener_type=fastener.fastener_type,
length=fastener.length,
simple=True).cq_object)
elif fastener.fastener_type == "asme_b_18.6.3":
# Create the cheesehead screw model
cur_fastener = cq.Workplane(PanHeadScrew(size=fastener.size,
fastener_type=fastener.fastener_type,
length=fastener.length,
simple=True).cq_object)
else:
# Create a button head screw model
cur_fastener = cq.Workplane(ButtonHeadScrew(size=fastener.size,
Expand Down Expand Up @@ -1006,6 +1012,74 @@ class HDD35Shelf(Shelf):
"""
Shelf class for a 3.5" hard drive device.
"""

def __init__(self,
device: Device,
assembly_key: str,
position: tuple[float, float, float],
color: str,
rack_params: RackParameters):

super().__init__(device,
assembly_key,
position,
color,
rack_params)

# Device location settings
self._device_depth_axis = "X"
# self._device_offset = (0.0, 0.0, 0.0)
self._device_explode_translation = (0.0, 0.0, 0.0)

self._fasteners = [
Screw(name=None,
position=(-self._device.depth / 2.0 - 7.0,
self._device.width / 2.0 + 3.75,
self._device.height / 3.0 + 0.25),
explode_translation=(0.0, 0.0, 35.0),
size="#6-32",
fastener_type="asme_b_18.6.3",
axis="-X",
length=6),
Screw(name=None,
position=(-self._device.depth / 2.0 - 7.0,
self._device.width / 2.0 + 45.35,
self._device.height / 3.0 + 0.25),
explode_translation=(0.0, 0.0, 35.0),
size="#6-32",
fastener_type="asme_b_18.6.3",
axis="-X",
length=6),
Screw(name=None,
position=(self._device.depth / 2.0 + 7.0,
self._device.width / 2.0 + 3.75,
self._device.height / 3.0 + 0.25),
explode_translation=(0.0, 0.0, 35.0),
size="#6-32",
fastener_type="asme_b_18.6.3",
axis="X",
length=6),
Screw(name=None,
position=(self._device.depth / 2.0 + 7.0,
self._device.width / 2.0 + 45.35,
self._device.height / 3.0 + 0.25),
explode_translation=(0.0, 0.0, 35.0),
size="#6-32",
fastener_type="asme_b_18.6.3",
axis="X",
length=6),
]
self.render_options = {
"color_theme": "default", # can also use black_and_white
"view": "front-top-right",
"standard_view": "front-top-right",
"annotated_view": "back-bottom-right",
"add_device_offset": False,
"add_fastener_length": True,
"zoom": 1.15,
}


def generate_shelf_model(self) -> cadscript.Body:
"""
A shelf for an 3.5" HDD
Expand Down
16 changes: 10 additions & 6 deletions tests/test_rendering.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,21 @@
from nimble_build_system.orchestration.configuration import NimbleConfiguration


# The configuration of hardware/shelves that we want to test against
test_config = ["Raspberry_Pi_4B",
"NUC8I5BEH",
"Unifi_Flex_Mini",
"Unifi_Switch_Flex",
"Hex",
# "Western_Digital_Red_HDD"
]


def test_assembly_png_rendering():
"""
Tests whether or not a PNG image can be output for an entire assembly.
"""

# The configuration of hardware/shelves that we want to test against
test_config = ["Raspberry_Pi_4B", "NUC8I5BEH", "Unifi_Flex_Mini", "Unifi_Switch_Flex", "Hex"]

# Load the needed information to generate a Shelf object
config = NimbleConfiguration(test_config)

Expand All @@ -40,9 +47,6 @@ def test_annotated_assembly_png_rendering():
annotations (i.e. assembly lines).
"""

# The configuration of hardware/shelves that we want to test against
test_config = ["Raspberry_Pi_4B", "NUC8I5BEH", "Unifi_Flex_Mini", "Unifi_Switch_Flex", "Hex"]

# Load the needed information to generate a Shelf object
config = NimbleConfiguration(test_config)

Expand Down

0 comments on commit 966d888

Please sign in to comment.