# [OpenSCAD] Curved groove gets wrong depth

Wed Oct 5 05:53:33 EDT 2016

```I think that instead of reducing the lengths of the groove you should just

I.e.

translate([0, d, 5])
linear_extrude(2) sheet_metal_2d(3, 10 - d, case);

You also need to set the convexity in the linear extrudes.

On 5 October 2016 at 10:16, Bananapeel <lunatica.xiaoyu at gmail.com> wrote:

> I'm trying to make a groove in a bend, but I can't get it to have an even
> depth. It gets shallower in the middle. Any ideas?
>
> Code:
>
> \$fn=100;
>
> function first(list) = list[0];
> function tail(list) = [for (i=[1:len(list)-1]) list[i]];
> function snd(list) = list[1];
>
> module bend_2d(thickness, inner_radius, angle=90 /* 1->180 */) {
>     outer_r = inner_r + thickness;
>
>     angle_real = abs(angle);
>     invert = angle < 0;
>     mirror_vec_y = invert ? 1 : 0;
>     translate_y = invert ? thickness : 0;
>
>     translate([0, translate_y, 0]) // negative bends
>       mirror([0, mirror_vec_y, 0]) //
>
>       translate([0, outer_r])
>         difference() {
>             circle(outer_r);
>
>             circle(inner_r);
>
>             rotate(angle_real-90)
>               square(outer_r);
>
>             translate([-outer_r, -outer_r])
>                 square([outer_r, outer_r*2]);
>
>             if (angle_real < 90)
>                 square(outer_r);
>         }
> }
>
> /*
>     Make bent sheet metal
>
>     The bend list contains bend points and angles
>     as [length, angle]. The length refers to the length
>     of unbent metal before the bend.
>
>     The last angle can be undef, in which case no bend is produced.
>
>     Draws a 2d profile that must be extruded.
> */
> module sheet_metal_2d(thickness, inner_radius, bend_list) {
>
>     if (len(bend_list) > 1) {
>                    /* distance of bend */    /* distance due to straight
> part rotation */
>       angle_abs    = abs(angle);
>
>       // parameters for positive angles (around outside radius)
>
>       // parameters for negative angles (around inside radius, mirrored)
>
>       invert = angle < 0;
>       bend_width  = invert ? inv_bend_width  : pos_bend_width;
>       bend_height = invert ? inv_bend_height : pos_bend_height;
>
>       translate([bend_width, bend_height]) // to angle end
>         translate([straight, 0]) // to straight end
>           rotate(angle)
>
>     } // endif
>
>     square([straight, thickness]);
>     if (angle != undef) {
>         translate([straight, 0])
>     }
>
> }
>
> /*
> //bend_2d(3, 7, 60);
> //bend_2d(3, 10, -70);
>
> *sheet_metal_2d(1, 10, [ [20, -120],  [30, 30] ]);
> *linear_extrude(100)
>     sheet_metal_2d(5, 10, [ [40, 30],  [60, -90], [10, -90], [40, -30],
> [60]
> ]);
> */
>
> case = [ [200, 90], [200,90], [200, undef] ];
> d = 2;
> case_groove = [  [200-d, 90], [200-d*2,90], [200-d, undef] ];
>
> difference() {
>   linear_extrude(135)
>     sheet_metal_2d(3, 10, case);
>
>   translate([0, d, 5])
>     linear_extrude(2) sheet_metal_2d(3, 10, case_groove);
> }
>
>
>
>
> --
> View this message in context: http://forum.openscad.org/
> Curved-groove-gets-wrong-depth-tp18537.html
> Sent from the OpenSCAD mailing list archive at Nabble.com.
>
> _______________________________________________
>
-------------- next part --------------
An HTML attachment was scrubbed...
```