// Parameters
block_x = 10;
block_y = 45;
block_z = 10;

block2_y = 65;


m4_clearance = 4.2;
slot_start = 26;
slot_end   = 40;

// Triangle base size
tri_base = 105;   // X direction
tri_height = 41; // Z direction
tri_depth = 10;  // Y extrusion

frame_thickness = 7;   // frame width (10x10mm)
fillet_radius   = 4;    // roundness of inner corners



// Imported STL
module imported_part() {
    color("blue")
        translate([-10, 0, 0])
            import("rehoop3.stl");
}

// Imported STL
module imported_part2() {
    color("orange")
        translate([0, 12.5, 99.9])
            import("block3.stl");
}


// Parametric block with slot
module block() {
    color("orange")
    difference() {
        // Main block
        cube([block_x, block_y, block_z]);

        // Rounded slot (obround), through Z
        hull() {
            translate([block_x/2, slot_start, -1])
                cylinder(h = block_z + 2, r = m4_clearance/2, $fn = 40);

            translate([block_x/2, slot_end, -1])
                cylinder(h = block_z + 2, r = m4_clearance/2, $fn = 40);
        }
    }
}

module extra_block () {
    
            // Main block
        cube([block_x, block_z, 17]);}
        
module extra_block_tri () {
    
            // Main block
        cube([10, 10, block2_y]);}

module triangle_2d(){
    
    polygon(points=[
        [0,0],            // bottom-left
        [tri_base,0],     // bottom-right
        [0,tri_height]    // top-left
    ]);
}

module triangle_frame(){
    color("red")
    linear_extrude(height = tri_depth)
        difference(){
            // Outer triangle
            triangle_2d();

            // Inner rounded cutout
                offset(delta = -frame_thickness)
                    triangle_2d();
        }
}



// ===== Assembly =====

// Position block relative to imported part
//translate([0, -10, 119.9])
   // block();
//translate([10, 0, 47])
//rotate([0,270,0])
//rotate([90,0,0])
//triangle_frame();

imported_part();
imported_part2();
translate([0, -10, 89.9])
extra_block();
rotate([0,28,0])
translate([-49.9, -10, 30])
extra_block_tri();
