From 96bf4e08b95db8c4141b16fb2c4fd88f71ca1f08 Mon Sep 17 00:00:00 2001 From: Brian Schwind Date: Sat, 14 Sep 2024 14:21:32 +0900 Subject: [PATCH] Add an example for a bracket for flat ethernet cables --- examples/src/flat_ethernet_bracket.rs | 52 +++++++++++++++++++++++++++ examples/src/lib.rs | 3 ++ 2 files changed, 55 insertions(+) create mode 100644 examples/src/flat_ethernet_bracket.rs diff --git a/examples/src/flat_ethernet_bracket.rs b/examples/src/flat_ethernet_bracket.rs new file mode 100644 index 0000000..6e924d3 --- /dev/null +++ b/examples/src/flat_ethernet_bracket.rs @@ -0,0 +1,52 @@ +use glam::{dvec3, DVec3}; +use opencascade::{ + primitives::{Direction, IntoShape, Shape, Wire}, + workplane::Workplane, +}; + +pub fn shape() -> Shape { + let thumbtack_big_diameter = 10.75; + let thumbtack_big_radius = thumbtack_big_diameter / 2.0; + let thumbtack_pin_radius = 1.2 / 2.0; + let thickness = 1.5; + let cable_width = 7.6; + let cable_height = 2.3; + + let overhang_width = 1.0; + + let path: Wire = Workplane::xz() + .sketch() + .line_dx(thickness) + .line_dy(-(thumbtack_big_diameter + cable_width + 2.0)) + .line_dx(cable_height + 0.1) + .line_dy(cable_width + 0.1) + .line_dx(-overhang_width) + .line_dy(thickness) + .line_dx(overhang_width + thickness) + .line_dy(-(thickness + cable_width + thickness)) + .line_dx(-(thickness + cable_height + thickness)) + .close(); + + let mut bracket = path.to_face().extrude(dvec3(0.0, thumbtack_big_diameter, 0.0)).into_shape(); + + let top_edges = bracket.faces().farthest(Direction::PosZ).edges().parallel_to(Direction::PosX); + + bracket = bracket.fillet_edges(thumbtack_big_diameter / 2.1, top_edges); + + let cylinder = Shape::cylinder( + dvec3(thickness, thumbtack_big_radius, -thumbtack_big_radius), + thumbtack_big_radius + 0.2, + -DVec3::X, + thickness - 1.0, + ); + + bracket = bracket.subtract(&cylinder).fillet(0.2); + + bracket = bracket.drill_hole( + dvec3(thickness, thumbtack_big_radius, -thumbtack_big_radius), + -DVec3::X, + thumbtack_pin_radius, + ); + + bracket +} diff --git a/examples/src/lib.rs b/examples/src/lib.rs index d980318..1793bb7 100644 --- a/examples/src/lib.rs +++ b/examples/src/lib.rs @@ -5,6 +5,7 @@ pub mod airfoil; pub mod box_shape; pub mod cable_bracket; pub mod chamfer; +pub mod flat_ethernet_bracket; pub mod gizmo; pub mod heater_coil; pub mod high_level_bottle; @@ -25,6 +26,7 @@ pub enum Example { CableBracket, BoxShape, Chamfer, + FlatEthernetBracket, Gizmo, HeaterCoil, HighLevelBottle, @@ -47,6 +49,7 @@ impl Example { Example::CableBracket => cable_bracket::shape(), Example::BoxShape => box_shape::shape(), Example::Chamfer => chamfer::shape(), + Example::FlatEthernetBracket => flat_ethernet_bracket::shape(), Example::Gizmo => gizmo::shape(), Example::HeaterCoil => heater_coil::shape(), Example::HighLevelBottle => high_level_bottle::shape(),