vslot shape
This commit is contained in:
@@ -4,16 +4,12 @@
|
|||||||
// Import PCIe holder functionality
|
// Import PCIe holder functionality
|
||||||
include <holder.scad>;
|
include <holder.scad>;
|
||||||
|
|
||||||
// Trapezium module - creates a centralized trapezoid shape
|
// Trapezium module - creates a centralized trapezoid shape (2D)
|
||||||
// Parameters:
|
// Parameters:
|
||||||
// base_width: width of the bottom edge
|
// base_width: width of the bottom edge
|
||||||
// top_width: width of the top edge
|
// top_width: width of the top edge
|
||||||
// height: height of the trapezium
|
// height: height of the trapezium
|
||||||
// depth: depth/thickness of the shape (default 1)
|
module trapezium_2d(base_width, top_width, height) {
|
||||||
module trapezium(base_width, top_width, height, depth = 1) {
|
|
||||||
// Calculate the difference in width
|
|
||||||
width_diff = base_width - top_width;
|
|
||||||
|
|
||||||
// Create the trapezoid points (centered)
|
// Create the trapezoid points (centered)
|
||||||
points = [
|
points = [
|
||||||
[-base_width/2, -height/2], // bottom left
|
[-base_width/2, -height/2], // bottom left
|
||||||
@@ -22,11 +18,56 @@ module trapezium(base_width, top_width, height, depth = 1) {
|
|||||||
[-top_width/2, height/2] // top left
|
[-top_width/2, height/2] // top left
|
||||||
];
|
];
|
||||||
|
|
||||||
// Extrude the 2D trapezoid to create 3D shape
|
|
||||||
linear_extrude(height = depth, center = true) {
|
|
||||||
polygon(points);
|
polygon(points);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Rectangle module - creates a rectangle extending from base (2D)
|
||||||
|
// Parameters:
|
||||||
|
// width: width of the rectangle
|
||||||
|
// height: height of the rectangle
|
||||||
|
// offset_y: vertical offset from origin (default 0)
|
||||||
|
module rectangle_2d(width, height, offset_y = 0) {
|
||||||
|
translate([0, offset_y])
|
||||||
|
square([width, height], center = true);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Combined module - joins trapezium and rectangle together
|
||||||
|
// Parameters:
|
||||||
|
// trap_base_width: trapezium base width
|
||||||
|
// trap_top_width: trapezium top width
|
||||||
|
// trap_height: trapezium height
|
||||||
|
// rect_width: rectangle width
|
||||||
|
// rect_height: rectangle height
|
||||||
|
// rect_offset: vertical offset for rectangle from trapezium base
|
||||||
|
module trapezium_with_rectangle_2d(
|
||||||
|
trap_base_width,
|
||||||
|
trap_top_width,
|
||||||
|
trap_height,
|
||||||
|
rect_width,
|
||||||
|
rect_height,
|
||||||
|
rect_offset = 0
|
||||||
|
) {
|
||||||
|
union() {
|
||||||
|
// Main trapezium
|
||||||
|
trapezium_2d(trap_base_width, trap_top_width, trap_height);
|
||||||
|
|
||||||
|
// Rectangle extending from base
|
||||||
|
translate([0, -trap_height/2 + rect_offset])
|
||||||
|
rectangle_2d(rect_width, rect_height);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Example usage (uncomment to test):
|
// Example usage (uncomment to test):
|
||||||
trapezium(base_width = 20, top_width = 10, height = 15, depth = 3);
|
// Individual shapes:
|
||||||
|
//trapezium_2d(base_width = 20, top_width = 10, height = 15);
|
||||||
|
//translate([30, 0]) rectangle_2d(width = 8, height = 5);
|
||||||
|
|
||||||
|
// Combined shape:
|
||||||
|
trapezium_with_rectangle_2d(
|
||||||
|
trap_base_width = 10.3,
|
||||||
|
trap_top_width = 6.3,
|
||||||
|
trap_height = 4.3,
|
||||||
|
rect_width = 6.3,
|
||||||
|
rect_height = 1.7,
|
||||||
|
rect_offset = -0.85 // Half of rectangle height to center it at base edge
|
||||||
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user