Skip to content

Commit

Permalink
Add an example for a bracket for flat ethernet cables
Browse files Browse the repository at this point in the history
  • Loading branch information
bschwind committed Sep 14, 2024
1 parent e4ccbf4 commit 96bf4e0
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 0 deletions.
52 changes: 52 additions & 0 deletions examples/src/flat_ethernet_bracket.rs
Original file line number Diff line number Diff line change
@@ -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
}
3 changes: 3 additions & 0 deletions examples/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -25,6 +26,7 @@ pub enum Example {
CableBracket,
BoxShape,
Chamfer,
FlatEthernetBracket,
Gizmo,
HeaterCoil,
HighLevelBottle,
Expand All @@ -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(),
Expand Down

0 comments on commit 96bf4e0

Please sign in to comment.