Files
dingfeng.wong 40e9ec35f8 t
2025-07-22 00:49:32 +08:00

98 lines
3.0 KiB
OpenSCAD

// 2020 Extrusion Insert
// Configurable 3D printable insert for 2020 aluminum extrusion
// Import PCIe holder functionality
include <holder.scad>;
// Import hexagon functionality for M3 nut holes
include <hexagon.scad>;
// Trapezium module - creates a centralized trapezoid shape (2D)
// Parameters:
// base_width: width of the bottom edge
// top_width: width of the top edge
// height: height of the trapezium
module trapezium_2d(base_width, top_width, height) {
// Create the trapezoid points (centered)
points = [
[-base_width/2, -height/2], // bottom left
[base_width/2, -height/2], // bottom right
[top_width/2, height/2], // top right
[-top_width/2, height/2] // top left
];
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):
// Individual shapes:
//trapezium_2d(base_width = 20, top_width = 10, height = 15);
//translate([30, 0]) rectangle_2d(width = 8, height = 5);
// Combined shape extruded to 3D with M3 nut hole:
rect_height_val = 1.7;
extrude_height = 10;
difference() {
// Main extruded shape
linear_extrude(height = extrude_height) {
trapezium_with_rectangle_2d(
trap_base_width = 10.95,
trap_top_width = 5.5,
trap_height = 4.0,
rect_width = 6.3,
rect_height = rect_height_val,
rect_offset = -rect_height_val/2 + 0.01 // Small overlap for clean union
);
}
// M3 nut hole on top face of trapezium (extended outward for clean cut)
translate([0, 4.0/2 + (m3_nut_height + 2)/2, extrude_height/2]) {
rotate([90, 0, 0]) {
hexagon_3d(m3_nut_width, m3_nut_height + 2); // Extra height for clean cut
}
}
// M3 bolt hole through entire trapezium
translate([0, 4.0/2, extrude_height/2]) {
rotate([90, 0, 0]) {
cylinder(h = rect_height_val + 20, d = 3.2, center = true, $fn = 32); // Long M3 clearance hole
}
}
}