<p>I am working with openSCAD to ultimately use it as an STL file for my ankermake 3D printer. I have gotten to this point, where I want to be able to slide a headband through the front cutout and then again through the cube (I started with a cube that you see in the center of the frame, however, what I want it to be is a cube with two slots, top and bottom, so that the headband can first slide through the top slot and then again through the cube.</p>
<p><a href="https://i.sstatic.net/UFOcWJED.png" rel="nofollow noreferrer" title="Screenshot of a 3D model frame in OpenSCAD"><img src="https://i.sstatic.net/UFOcWJED.png" alt="Screenshot of a 3D model frame in OpenSCAD" title="Screenshot of a 3D model frame in OpenSCAD" /></a></p>
<p>However, another thing I want is for the &quot;cube&quot; to be more like an indent, so when the headband slides through, the headband is visible on the other side, if the frame were flipped.</p>
<p>Here is my code that creates the image:</p>
<pre><code>// Parameters for the rectangular frame
outer_length = 85;       // Outer length of the frame (in mm)
outer_width = 65;        // Outer width of the frame (in mm)
border_thickness = 2;    // Thickness of the raised border (in mm)
border_height = 10;      // Height of the raised border (in mm)
inner_length = outer_length - 2 * border_thickness;  // Inner length of the frame (in mm)
inner_width = outer_width - 2 * border_thickness;    // Inner width of the frame (in mm)
bottom_thickness = 1;    // Thickness of the thin opaque bottom layer (in mm)
corner_radius = 5;       // Radius for rounded corners (in mm)
slot_width = 10;         // Width for headband slots (in mm)
slot_depth = 5;          // Depth for headband slots (in mm)

// Function to create a rectangular frame with rounded corners, a hollow interior, and a thin opaque bottom layer
module frame() {
    difference() {
        // Create the outer shell with rounded corners and raised border
        translate([0, 0, -border_height])
        linear_extrude(height = border_height + bottom_thickness) {
            offset(r = corner_radius) {
                square([outer_length, outer_width], center = true);
            }
        }

        // Create the inner hollow part with rounded corners
        translate([0, 0, -border_height])
        linear_extrude(height = border_height + bottom_thickness) {
            offset(r = corner_radius - 1) {
                square([inner_length, inner_width], center = true);
            }
        }

        // Create the thin opaque bottom layer
        translate([0, 0, -bottom_thickness])
        square([outer_length, outer_width], center = true);
        
        // Create the top cutout for the headband in the center of the narrow side
        translate([outer_length / 2 - slot_width / 2, -slot_width / 2, -border_height]) {
            cube([slot_width, border_height + 1, slot_depth]);
        }
    }

    // Create the thin opaque bottom layer
    translate([0, 0, -bottom_thickness - border_height])
    linear_extrude(height = bottom_thickness) {
        offset(r = corner_radius) {
            square([outer_length, outer_width], center = true);
        }
    }
}

// Create the frame using the module
frame();

// Additional cube in the center of the frame with slots
module center_cube_with_slots() {
    translate([0, 0, -bottom_thickness - 10]) { // Position the cube inside the frame
        difference() {
            cube([slot_width, slot_width, 20], center = true); // Center the cube at the origin
            // Top slot cutout
            translate([-slot_width / 2, -5, 10]) { // Adjust position for the top slot
                cube([slot_width, 10, 10]); // Top slot dimensions
            }
            // Bottom slot cutout
            translate([-slot_width / 2, -5, -10]) { // Adjust position for the bottom slot
                cube([slot_width, 10, 10]); // Bottom slot dimensions
            }
        }
    }
}

// Create the cube with slots
center_cube_with_slots();
</code></pre>
<p>I tried to add slots first to play around with the cube, but ultimately I want the cube to be hollow (basically look like an indent if the frame were flipped). The goal is to get a headband through the top slot of the border and again through the cue, to hit the bottom of the frame finally. Any idea on how to successfully do this?</p>

CC BY-SA 4.0
2024-10-02T14:29:57.540Z
You have tagged your question with `diy-3d-printer` and `stl` but don't mention anything about 3D printing in the body of the question. Please [edit] the question to include this information so that it stays [on-topic](https://3dprinting.stackexchange.com/help/on-topic).
agarza
CC BY-SA 4.0
2024-10-02T15:18:09.317Z
Just edited, thank you!
Jackie Chiljian
CC BY-SA 4.0
2024-10-02T18:31:14.387Z
Wow, that is a lot of code for such a simple box, I'd likely more inclined to use Minkovsi and you should be ready with just a few lines of code. I'm not in the neighborhood of a PC for a while, so I cannot help out. Maybe you can add a sketch of how it is supposed to look to prevent misunderstanding?
0scar
<diy-3d-printer><stl><openscad>
Trying to adjust slots and create an indent in openSCAD
Jackie Chiljian
# Trying to adjust slots and create an indent in openSCAD

(Asked by: username_0 on 2024-10-02)

I am working with openSCAD to ultimately use it as an STL file for my ankermake 3D printer. I have gotten to this point, where I want to be able to slide a headband through the front cutout and then again through the cube (I started with a cube that you see in the center of the frame, however, what I want it to be is a cube with two slots, top and bottom, so that the headband can first slide through the top slot and then again through the cube.

However, another thing I want is for the "cube" to be more like an indent, so when the headband slides through, the headband is visible on the other side, if the frame were flipped.
Here is my code that creates the image:
// Parameters for the rectangular frame
outer_length = 85;       // Outer length of the frame (in mm)
outer_width = 65;        // Outer width of the frame (in mm)
border_thickness = 2;    // Thickness of the raised border (in mm)
border_height = 10;      // Height of the raised border (in mm)
inner_length = outer_length - 2 * border_thickness;  // Inner length of the frame (in mm)
inner_width = outer_width - 2 * border_thickness;    // Inner width of the frame (in mm)
bottom_thickness = 1;    // Thickness of the thin opaque bottom layer (in mm)
corner_radius = 5;       // Radius for rounded corners (in mm)
slot_width = 10;         // Width for headband slots (in mm)
slot_depth = 5;          // Depth for headband slots (in mm)

// Function to create a rectangular frame with rounded corners, a hollow interior, and a thin opaque bottom layer
module frame() {
    difference() {
        // Create the outer shell with rounded corners and raised border
        translate([0, 0, -border_height])
        linear_extrude(height = border_height + bottom_thickness) {
            offset(r = corner_radius) {
                square([outer_length, outer_width], center = true);
            }
        }

        // Create the inner hollow part with rounded corners
        translate([0, 0, -border_height])
        linear_extrude(height = border_height + bottom_thickness) {
            offset(r = corner_radius - 1) {
                square([inner_length, inner_width], center = true);
            }
        }

        // Create the thin opaque bottom layer
        translate([0, 0, -bottom_thickness])
        square([outer_length, outer_width], center = true);
        
        // Create the top cutout for the headband in the center of the narrow side
        translate([outer_length / 2 - slot_width / 2, -slot_width / 2, -border_height]) {
            cube([slot_width, border_height + 1, slot_depth]);
        }
    }

    // Create the thin opaque bottom layer
    translate([0, 0, -bottom_thickness - border_height])
    linear_extrude(height = bottom_thickness) {
        offset(r = corner_radius) {
            square([outer_length, outer_width], center = true);
        }
    }
}

// Create the frame using the module
frame();

// Additional cube in the center of the frame with slots
module center_cube_with_slots() {
    translate([0, 0, -bottom_thickness - 10]) { // Position the cube inside the frame
        difference() {
            cube([slot_width, slot_width, 20], center = true); // Center the cube at the origin
            // Top slot cutout
            translate([-slot_width / 2, -5, 10]) { // Adjust position for the top slot
                cube([slot_width, 10, 10]); // Top slot dimensions
            }
            // Bottom slot cutout
            translate([-slot_width / 2, -5, -10]) { // Adjust position for the bottom slot
                cube([slot_width, 10, 10]); // Bottom slot dimensions
            }
        }
    }
}

// Create the cube with slots
center_cube_with_slots();

I tried to add slots first to play around with the cube, but ultimately I want the cube to be hollow (basically look like an indent if the frame were flipped). The goal is to get a headband through the top slot of the border and again through the cue, to hit the bottom of the frame finally. Any idea on how to successfully do this?

**Tags:** diy-3d-printer, stl, openscad
> **Comments:**
> **username_1**: You have tagged your question with `diy-3d-printer` and `stl` but don't mention anything about 3D printing in the body of the question. Please [edit] the question to include this information so that it stays [on-topic](https://3dprinting.stackexchange.com/help/on-topic).  
> **username_0**: Just edited, thank you!  
> **username_2**: Wow, that is a lot of code for such a simple box, I'd likely more inclined to use Minkovsi and you should be ready with just a few lines of code. I'm not in the neighborhood of a PC for a while, so I cannot help out. Maybe you can add a sketch of how it is supposed to look to prevent misunderstanding?  

---

## 0 answers

