Skip to content

Instantly share code, notes, and snippets.

@LeSpocky
Last active August 7, 2025 20:21
Show Gist options
  • Save LeSpocky/7880703 to your computer and use it in GitHub Desktop.
Save LeSpocky/7880703 to your computer and use it in GitHub Desktop.
rounded square in openscad
module rounded_square( width, radius_corner ) {
translate( [ radius_corner, radius_corner, 0 ] )
minkowski() {
square( width - 2 * radius_corner );
circle( radius_corner );
}
}
module alternative_square( width, r_c ) {
hull() {
translate( [r_c, r_c, 0] ) circle( r_c );
translate( [r_c, width - r_c, 0 ] ) circle( r_c );
translate( [width - r_c, r_c, 0] ) circle( r_c );
translate( [width - r_c, width - r_c, 0] ) circle( r_c );
}
}
@jcoehoorn
Copy link

jcoehoorn commented Aug 7, 2025

Can be simplified and add a feature at the same time:

module rounded_rect(l, w, r)
{
    translate([r, r, 0])
    offset(r=r, $fn = 60) 
    square([l-(2*4), w-(2*r)]);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment