Skip to content

Commit

Permalink
Add an example file for a zotac zbox PC mount
Browse files Browse the repository at this point in the history
  • Loading branch information
bschwind committed Sep 14, 2024
1 parent 2dbe1ed commit 72b051c
Show file tree
Hide file tree
Showing 2 changed files with 94 additions and 0 deletions.
3 changes: 3 additions & 0 deletions examples/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ pub mod swept_wire;
pub mod swept_wire_variable;
pub mod turners_cube;
pub mod variable_fillet;
pub mod zbox_case;

#[derive(Debug, Copy, Clone, PartialEq, ValueEnum)]
pub enum Example {
Expand All @@ -40,6 +41,7 @@ pub enum Example {
SweptWireVariable,
TurnersCube,
VariableFillet,
ZboxCase,
}

impl Example {
Expand All @@ -63,6 +65,7 @@ impl Example {
Example::SweptWireVariable => swept_wire_variable::shape(),
Example::TurnersCube => turners_cube::shape(),
Example::VariableFillet => variable_fillet::shape(),
Example::ZboxCase => zbox_case::shape(),
}
}
}
91 changes: 91 additions & 0 deletions examples/src/zbox_case.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
use glam::dvec3;
use opencascade::{
primitives::{Direction, Shape},
workplane::Workplane,
};

pub fn shape() -> Shape {
// The origin of the coordinate system is the closest bottom left corner of
// the PC box, when viewing its ports from behind.
let case_thickness = 2.0;
let case_width = 212.0;
let case_height = 60.0;
let case_depth = 64.0; // Not measured, arbitrary value

let hook_thickness = 3.0;
let wire_gap = 2.6;

let case_box = Shape::box_with_dimensions(case_width, case_height, case_depth);

let back_face = case_box.faces().farthest(Direction::PosY);

let case_box = case_box.hollow(case_thickness, [back_face]);

let port_cutout = Workplane::xz()
.sketch()
.move_to(10.0, 9.0)
.line_to(10.0, 55.0)
.line_to(200.0, 55.0)
.line_to(200.0, 9.0)
.close()
.to_face();

let cutout = port_cutout.extrude(dvec3(0.0, -case_thickness, 0.0)).into();

let mut case_box = case_box.subtract(&cutout);

// Add the back hooks
let bottom_face = case_box.faces().farthest(Direction::NegZ);

for x_offset in [-75.0, -25.0, 25.0, 75.0] {
let mut hook: Shape = bottom_face
.workplane()
.translated(dvec3(x_offset, -20.0, 0.0))
.rect(40.0, 20.0)
.to_face()
.extrude(dvec3(0.0, 0.0, -(hook_thickness + wire_gap)))
.into();

let hook_bottom = hook.faces().farthest(Direction::NegY);

let hook_descent = hook_bottom
.workplane()
.translated(dvec3(0.0, -(hook_thickness + wire_gap) / 2.0 + hook_thickness / 2.0, 0.0))
.rect(40.0, hook_thickness)
.to_face()
.extrude(dvec3(0.0, -20.0, 0.0))
.into();

hook = hook.union(&hook_descent).into();

let bottom_hook_edges =
hook.faces().farthest(Direction::NegY).edges().parallel_to(Direction::PosZ);
hook = hook.fillet_edges(10.0, bottom_hook_edges);

case_box = case_box.union(&hook);
}

// Punch some holes in the back for optional zipties
for x_offset in [-100.0, -50.0, 0.0, 50.0, 100.0] {
let ziptie_hole = bottom_face
.workplane()
.translated(dvec3(x_offset, -20.0, 0.0))
.circle(0.0, 0.0, 2.25)
.to_face()
.extrude(dvec3(0.0, 0.0, 10.0))
.into();

case_box = case_box.subtract(&ziptie_hole)
}

// Cut out a circle on the front
let front_face = case_box
.faces()
.farthest(Direction::PosZ)
.workplane()
.translated(dvec3(0.0, 75.0, 0.0))
.circle(0.0, 0.0, 100.0)
.to_face();

front_face.subtractive_extrude(&case_box, -case_thickness)
}

0 comments on commit 72b051c

Please sign in to comment.