BOSL2 icon indicating copy to clipboard operation
BOSL2 copied to clipboard

Any reason aluminium extrusion isnt part of the parts library?

Open twitchyliquid64 opened this issue 1 year ago • 7 comments

As the title says, I was pretty surprised there was no generic 2020 extrusion in the parts files.

I made one for generic 2020 as a side project to my first project with BOSL2, feel free to use (or feedback if its 💩 ):

include <BOSL2/std.scad>
include <BOSL2/screws.scad>

module ext_2020(
    l=60, s=20, edge_r=1.5, bore_r=2.5,
    slot_inset = 1.5, slot_inner_width = 11, slot_outer_width = 6.2, slot_depth = 4.3,
    cut_width = 5.26,
    anchor=BOTTOM, spin=0, orient=UP,
) {    
    tag_scope() diff()
        cuboid([s, s, l], rounding=edge_r, edges="Z", $fn=20, anchor=anchor,spin=spin,orient=orient) {
            align(CENTER, inside=true) cylinder(r=bore_r, h=l+1, anchor=CENTER);
            
            // trapezoidal slots
            face_mask([LEFT, RIGHT, FRONT, BACK])
                down(slot_inset)
                prismoid([slot_outer_width, l+1],[slot_inner_width, l+1],height=slot_depth, anchor=TOP);

            // cuts
            face_mask([LEFT, RIGHT, FRONT, BACK])
                up(0.01)
                cube([cut_width, l+1, slot_inset+0.02], anchor=TOP);

            children();
        }
}

ext_2020()
    position(RIGHT) orient(RIGHT)
        screw("M3", head="socket", drive="hex", length=12);

Image

twitchyliquid64 avatar Jun 11 '25 22:06 twitchyliquid64

I designed and printed some 80-20 before, but it came out terribly. There is no orientation that it can be printed in (with FDM/FFF) that doesn't break along layer lines when you tighten a screw down on it. So I never added the part to the library.

However, I can see the use of having it in the library, for image generation, or for printing in metal.

revarbat avatar Jun 12 '25 02:06 revarbat

I'd suggest making a 2D 80-20 profile module that can be linear_extrude()ed, for most flexibility and speed.

revarbat avatar Jun 12 '25 02:06 revarbat

Thinking on it, the various sizes of 80-20 may have profiles that aren't just scaled versions of one another.

revarbat avatar Jun 12 '25 02:06 revarbat

I'm actually using my 2020 module to help me visualize the assembly, but yeah definitely not going to print it 😅 but I will buy some and feed it to the chop saw :P

twitchyliquid64 avatar Jun 12 '25 03:06 twitchyliquid64

Agree that finding a way to make it parametric so you can do 2040, 8020 etc sounds ideal.

twitchyliquid64 avatar Jun 12 '25 03:06 twitchyliquid64

Here is my contribution:

// Profile size (square across flats)
Alum_Size = 20;  // [20, 30, 40, 45, 50, 60, 80, 100]

// Outer edge corner radius
Alum_Outer_Radius = 1;

// Slot inner edge corner radius
Alum_Inner_Radius = 0;

// Slot depth
Alum_Slot_Depth = 5;

// Slot mouth width (opening at face)
Alum_Slot_Mouth = 6;

// Slot throat width (inner width)
Alum_Slot_Throat = 12;

// Slot lip thickness (face to full throat)
Alum_Slot_Lip = 3;

// Slot access width
Alum_Slot_Access_Width = 6;

// Slot access depth
Alum_Slot_Access_Depth = 1;

// Center bore size
Alum_Bore_Size = 5;

// Center bore rounding ratio (0=square, 1=circle)
Alum_Bore_Rounding = 1;  // [0:0.05:1]

// Auxiliary pocket size
Alum_Aux_Size = 0;

// Auxiliary pocket rounding ratio (0=square, 1=circle)
Alum_Aux_Rounding = 0.5;  // [0:0.05:1]

// Auxiliary pocket offset from edge
Alum_Aux_Offset = 1;

/**
 * Create an aluminum extrusion profile cross-section.
 *
 * @param size            Size of the profile (size x size)
 * @param orounding       Outer edge rounding
 * @param irounding       Slot edge rounding
 * @param lip             Distance from face to full throat
 * @param mouth           Width of the slot opening
 * @param throat          Inner width of the slot
 * @param depth           Depth of the slot
 * @param access_width    Width of the screwdriver access slot
 * @param access_depth    Depth of the screwdriver access slot
 * @param bore_size       Diameter of the central bore
 * @param bore_rounding   Rounding radius for the bore corners
 * @param aux_size        Size of auxiliary pockets (0 to disable)
 * @param aux_rounding    Rounding radius for auxiliary pockets
 * @param aux_offset      Distance from edge to auxiliary pocket
 * @return                A polygon representing the aluminum profile cross-section
 */
function aluminum_profile(
    size=Alum_Size,
    orounding=Alum_Outer_Radius,
    irounding=Alum_Inner_Radius,
    lip=Alum_Slot_Lip,
    mouth=Alum_Slot_Mouth,
    throat=Alum_Slot_Throat,
    depth=Alum_Slot_Depth,
    access_width=Alum_Slot_Access_Width,
    access_depth=Alum_Slot_Access_Depth,
    bore_size = Alum_Bore_Size,
    bore_rounding = Alum_Bore_Rounding * (Alum_Bore_Size/2),
    aux_size = Alum_Aux_Size,
    aux_rounding = Alum_Aux_Rounding * (Alum_Aux_Size/2),
    aux_offset = Alum_Aux_Offset,
) =
    assert(size > 0, "Size must be positive")
    assert(orounding >= 0, "Outer rounding must be non-negative")
    assert(irounding >= 0, "Inner rounding must be non-negative")
    assert(size/2 > depth + access_depth, "Slot depth plus access depth must be less than half the size")
    let (
        outer = rect([size, size], rounding=orounding),
        corners = [0, 90, 180, 270],
        slot_h = depth + access_depth,
        slot = _tslot_cutout(lip, mouth, throat, depth, access_width, access_depth, irounding),
        slots = [for (angle = corners) zrot(angle, right(size/2-slot_h, slot))],
        bore = rect(bore_size, rounding=bore_rounding),
        aux = rect([aux_size, aux_size], rounding=aux_rounding),
        aux_o = size/2-aux_size/2-aux_offset,
        auxs = aux_size > 0 ? [for (angle = corners) zrot(angle, back(aux_o, right(aux_o, aux)))] : [],
    ) difference([outer, slots, bore, each auxs]);

module aluminum_profile(
    size=Alum_Size,
    orounding=Alum_Outer_Radius,
    irounding=Alum_Inner_Radius,
    lip=Alum_Slot_Lip,
    mouth=Alum_Slot_Mouth,
    throat=Alum_Slot_Throat,
    depth=Alum_Slot_Depth,
    access_width=Alum_Slot_Access_Width,
    access_depth=Alum_Slot_Access_Depth,
    bore_size = Alum_Bore_Size,
    bore_rounding = Alum_Bore_Rounding * (Alum_Bore_Size/2),
    aux_size = Alum_Aux_Size,
    aux_rounding = Alum_Aux_Rounding * (Alum_Aux_Size/2),
    aux_offset = Alum_Aux_Offset,
    debug = false,
    anchor = BOTTOM,
    spin = 0,
    orient = UP,
) {
    section = aluminum_profile(
        size, orounding, irounding, lip, mouth, throat, depth,
        access_width, access_depth, bore_size, bore_rounding,
        aux_size, aux_rounding, aux_offset
    );
    
    attachable(anchor, spin, orient, two_d=true, path=section, extent=false) {
        if (debug) {
            debug_region(section);
        } else {
            region(section);
        }
        children();
    }
}

/**
 * Create a T-slot cutout shape for aluminum profiles.
 *
 * @param lip             Distance from face to full throat
 * @param mouth           Width of the slot opening
 * @param throat          Inner width of the slot
 * @param depth           Depth to arc center
 * @param access_width    Width of the screwdriver access slot
 * @param access_depth    Depth of the screwdriver access slot
 * @param rounding        Rounding radius for corners
 * @return                A polygon representing the T-slot cutout shape
 */
function _tslot_cutout(
    lip=4,
    mouth=10,
    throat=18,
    depth=6,
    access_width=5,
    access_depth=2,
    rounding=0,
) =
    assert(mouth > 0, "Mouth must be positive")
    assert(lip > 0, "Lip must be positive")
    assert(depth > 0, "Depth must be positive")
    assert(throat >= mouth, "Throat must be greater than or equal to mouth")
    assert(access_width >= 0, "Access width must be non-negative")
    assert(access_depth >= 0, "Access depth must be non-negative")
    assert(access_width <= throat, "Access width must be less than or equal to throat")
    assert(rounding >= 0, "Rounding must be non-negative")
    let (
        lip = min(lip, depth),
        backing = max(depth - lip, 0),
         // trapezoid + rectangular throat
        slot = [
            [0,           +mouth/2],
            [lip,         +throat/2],
            [lip+backing, +throat/2],
            [lip+backing, -throat/2],
            [lip,         -throat/2],
            [0,           -mouth/2]
        ],
        // access gap
        access = right(depth, rect([access_depth, access_width], anchor=LEFT)),
        // excess material on the outside
        excess = right(depth+access_depth, rect([access_depth, throat], anchor=LEFT)),
        shape = union(slot, access, excess),
    ) round_corners(shape, joint=rounding);

It creates a generic aluminum extrusion 2D profile which can be used to generate a bunch of different variants, for example:

Image

I suspect performance could be improved if difference() were avoided, since it’s a relatively expensive operation — especially when subtracting high-resolution holes. For example, simply adding four corner pocket holes increases render time from ~200 ms to ~400 ms.

In my current approach, the profile is built by subtracting slots, but an alternative could be to trace the outline directly using turtle. That’s a bit beyond my skill level, though.

JasonKoolman avatar Sep 25 '25 09:09 JasonKoolman

I’ve also developed a set parametric cross-section profiles for hot-rolled steel and wood extrusions - including T-, L-, and I-beams, among others. These are based on real-world technical specifications, such as those documented here: https://www.dlubal.com/en/cross-section-properties/series-i-section-hot-rolled .

The code is open source on MakerWorld: https://makerworld.com/en/models/1818081-beam-generator-parametric-beams-bars-extrudes

I’d be happy to contribute this work to BOSL2 if there’s interest.

JasonKoolman avatar Sep 25 '25 09:09 JasonKoolman