diff --git a/pcie.scad b/pcie.scad index 6d11c6c..b4fceaf 100644 --- a/pcie.scad +++ b/pcie.scad @@ -4,140 +4,29 @@ // Import PCIe holder functionality include ; -// === 2020 Extrusion Insert Parameters === -extrusion_2020_outer = 20; // 2020 extrusion outer dimension -extrusion_2020_inner = 16.2; // Internal cavity dimension -extrusion_2020_slot_width = 6; // T-slot opening width -extrusion_2020_slot_depth = 1.8; // T-slot depth from outer edge -tab_clearance = 0.2; // Clearance for tabs to fit in T-slots -insert_clearance = 0.1; // General clearance for the insert body - -// === 2020 Extrusion Insert Module === -module extrusion_2020_insert_2d( - with_tabs = true, // Include tabs for T-slot engagement - tab_width = 4, // Width of each tab - tab_thickness = 1.6, // Thickness of tabs (fits in T-slot depth) - insert_width = 15.8, // Width of main insert body (with clearance) - insert_height = 15.8, // Height of main insert body (with clearance) - tab_positions = [0.25, 0.75], // Relative positions of tabs (0-1) - corner_radius = 0.5 // Corner radius for smoother printing -) { +// Trapezium module - creates a centralized trapezoid shape +// Parameters: +// base_width: width of the bottom edge +// top_width: width of the top edge +// height: height of the trapezium +// depth: depth/thickness of the shape (default 1) +module trapezium(base_width, top_width, height, depth = 1) { + // Calculate the difference in width + width_diff = base_width - top_width; - // Calculate dimensions - effective_insert_width = insert_width; - effective_insert_height = insert_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 + ]; - // Main insert body - difference() { - // Create main rectangular body with rounded corners - offset(r = corner_radius) - offset(r = -corner_radius) - square([effective_insert_width, effective_insert_height], center = true); - - // Optional cutouts can be added here for weight reduction or specific features + // Extrude the 2D trapezoid to create 3D shape + linear_extrude(height = depth, center = true) { + polygon(points); } - - // Add tabs for T-slot engagement if requested - if (with_tabs) { - // Top tabs - for (pos = tab_positions) { - translate([ - (pos - 0.5) * effective_insert_width, - effective_insert_height/2 + tab_thickness/2 - ]) - square([tab_width, tab_thickness], center = true); - } - - // Bottom tabs - for (pos = tab_positions) { - translate([ - (pos - 0.5) * effective_insert_width, - -(effective_insert_height/2 + tab_thickness/2) - ]) - square([tab_width, tab_thickness], center = true); - } - - // Left tabs - for (pos = tab_positions) { - translate([ - -(effective_insert_width/2 + tab_thickness/2), - (pos - 0.5) * effective_insert_height - ]) - square([tab_thickness, tab_width], center = true); - } - - // Right tabs - for (pos = tab_positions) { - translate([ - effective_insert_width/2 + tab_thickness/2, - (pos - 0.5) * effective_insert_height - ]) - square([tab_thickness, tab_width], center = true); - } - } - - // Display insert specifications - echo("=== 2020 Extrusion Insert Specifications ==="); - echo(str("Insert dimensions: ", effective_insert_width, "mm x ", effective_insert_height, "mm")); - echo(str("Tab width: ", tab_width, "mm")); - echo(str("Tab thickness: ", tab_thickness, "mm")); - echo(str("Tabs enabled: ", with_tabs)); - echo(str("Tab positions: ", tab_positions)); - echo("=== End Insert Specifications ==="); } -// === Function to create 3D insert from 2D profile === -module extrusion_2020_insert_3d( - length = 50, // Length to extrude the insert - with_tabs = true, - tab_width = 4, - tab_thickness = 1.6, - insert_width = 15.8, - insert_height = 15.8, - tab_positions = [0.25, 0.75], - corner_radius = 0.5 -) { - linear_extrude(height = length) - extrusion_2020_insert_2d( - with_tabs = with_tabs, - tab_width = tab_width, - tab_thickness = tab_thickness, - insert_width = insert_width, - insert_height = insert_height, - tab_positions = tab_positions, - corner_radius = corner_radius - ); -} - -// === Usage Examples === - -// Generate the PCIe riser holder using imported functionality -pcie_riser_holder( - thickness = thickness, - hole_diameter = hole_diameter, - margin_x = margin_x, - holder_width = holder_width, - first_spacing = first_hole_spacing, - second_spacing = second_hole_spacing, - third_spacing = third_hole_spacing, - show_preview_holes = false // Set to true to see hole positions in preview -); - -// Uncomment below to generate a 2020 extrusion insert instead -// Example 1: 2D profile for manual extrusion -//extrusion_2020_insert_2d(); - -// Example 2: 3D insert with 50mm length -//extrusion_2020_insert_3d(length = 50); - -// Example 3: Insert without tabs (for loose fit) -//extrusion_2020_insert_3d(length = 30, with_tabs = false); - -// Example 4: Custom tab configuration -//extrusion_2020_insert_3d( -// length = 40, -// tab_width = 6, -// tab_positions = [0.2, 0.8], -// insert_width = 15.5, -// insert_height = 15.5 -//); +// Example usage (uncomment to test): +trapezium(base_width = 20, top_width = 10, height = 15, depth = 3);