Can a shape change as it is extruded along the Z axis? (e.g. with BOSL2?)

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Can a shape change as it is extruded along the Z axis? (e.g. with BOSL2?)

Carsten Fuchs
Dear group,

I'm still new to OpenSCAD and have started to write my first projects. I've also read a lot in the BOSL2 documentation, which is very well written but is also a bit overwhelming.

What I would like to do is extrude a 2D shape along the Z axis, as with `linear_extrude()` keeping the shape always parallel to the XY plane, but also change its shape and move it along a smoothed path.

Please consider this example code, which can also be seen in the attached screenshot:

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

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


module TestShape() {
    h_leiste = 6;
    b_leiste = 6;
    h_senke = -3;
    b_senke = 4;
    h_seiten = -50;

    // Can we change this variable as the shape is swept along the Z-axis?
    // (Using `path_sweep()` with method="manual" and normal=[0, 0, 1]
    //  to keep the shape in the XY-plane along the entire path.)
    breite = 125;

    punkte = [
        [0, h_seiten],
        [0, h_leiste],
        [b_leiste, h_leiste],
        [b_leiste, h_senke],
        [breite - b_leiste, h_senke],
        [breite - b_leiste, h_leiste],
        [breite, h_leiste],
        [breite, h_seiten],
    ];

    // polygon(punkte);
    // polygon(round_corners(punkte, method="circle", cut=1, $fn=30));

    // Can the closing edge be omitted?
    shell2d(-1.5) {
        polygon(round_corners(punkte, method="circle", cut=1, $fn=30));
    };
}


TestShape();

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

I think that I can move the shape along a smoothed path using `path_sweep()` with `method="manual"` and `normal=[0, 0, 1]`, but how can I change it (i.e. the number `breite` in the code) as it is extruded?

Also, please see the question about the closing edge in the comment above. Using `stroke()` comes into mind, but it doesn't seem to the be right solution to me, as I need an inside shell rather than a stroked polygon.

Any help would very much be appreciated!

Best regards,
Carsten



--
Dipl.-Inf. Carsten Fuchs
Industriegebiet 3 ℅ Rofu
55768 Hoppstädten-Weiersbach
https://www.cafu.de

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

Bildschirmfoto von 2020-12-31 10-07-34.png (293K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Can a shape change as it is extruded along the Z axis? (e.g. with BOSL2?)

adrianv
In order to extrude a shape that changes arbitrarily you must use skin().  It
takes a list of shapes and links them together.  To do this you need to keep
your shape as a list of points rather than turning it into geometry, so
shell2d and polygon won't work here.  Stroke is actually the right way to do
what you want in 2d, but I think you need to use the offset_stroke version
because it can control the direction of the offset.  You would use it on the
original point list and it would give you the shape you need as geometry.  
That would work for linear_extrude but can't be used as an input to skin().  

To use skin() you'll need to construct your entire shape as coordinates.
Ideally you could still use offset_stroke to do this, but unfortunately it
is a module only and won't return its points.  So you have to call the
offset() function (note, this is part of BOSL2, not the offset module that
is core OpenSCAD) and connect the result to the points you start with.  

include <BOSL2/std.scad>
include <BOSL2/rounding.scad>
include <BOSL2/skin.scad>

function TestShape(breite) =
   let(
      h_leiste = 6,
      b_leiste = 6,
      h_senke = -3,
      b_senke = 4,
      h_seiten = -50,
      punkte = [
          [0, h_seiten],
          [0, h_leiste],
          [b_leiste, h_leiste],
          [b_leiste, h_senke],
          [breite - b_leiste, h_senke],
          [breite - b_leiste, h_leiste],
          [breite, h_leiste],
          [breite, h_seiten],
      ],
      shape = round_corners(punkte, method="circle", cut=1, $fn=30),
      inside = offset(shape,r=-1.5)
   )
   concat(shape, reverse(inside));

breite = [100,105, 110,120,170, 200];
z = [100, 120, 140, 160, 180, 200];

profiles = [for(b=breite) TestShape(b)];

skin(profiles, z=z, slices=0);



Carsten Fuchs wrote

> Dear group,
>
> I'm still new to OpenSCAD and have started to write my first projects.
> I've also read a lot in the BOSL2 documentation, which is very well
> written but is also a bit overwhelming.
>
> What I would like to do is extrude a 2D shape along the Z axis, as with
> `linear_extrude()` keeping the shape always parallel to the XY plane, but
> also change its shape and move it along a smoothed path.
>
> Please consider this example code, which can also be seen in the attached
> screenshot:
>
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
> include &lt;BOSL2/std.scad&gt;
> include &lt;BOSL2/rounding.scad&gt;
>
>
> module TestShape() {
>     h_leiste = 6;
>     b_leiste = 6;
>     h_senke = -3;
>     b_senke = 4;
>     h_seiten = -50;
>
>     // Can we change this variable as the shape is swept along the Z-axis?
>     // (Using `path_sweep()` with method="manual" and normal=[0, 0, 1]
>     //  to keep the shape in the XY-plane along the entire path.)
>     breite = 125;
>
>     punkte = [
>         [0, h_seiten],
>         [0, h_leiste],
>         [b_leiste, h_leiste],
>         [b_leiste, h_senke],
>         [breite - b_leiste, h_senke],
>         [breite - b_leiste, h_leiste],
>         [breite, h_leiste],
>         [breite, h_seiten],
>     ];
>
>     // polygon(punkte);
>     // polygon(round_corners(punkte, method="circle", cut=1, $fn=30));
>
>     // Can the closing edge be omitted?
>     shell2d(-1.5) {
>         polygon(round_corners(punkte, method="circle", cut=1, $fn=30));
>     };
> }
>
>
> TestShape();
>
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
> I think that I can move the shape along a smoothed path using
> `path_sweep()` with `method="manual"` and `normal=[0, 0, 1]`, but how can
> I change it (i.e. the number `breite` in the code) as it is extruded?
>
> Also, please see the question about the closing edge in the comment above.
> Using `stroke()` comes into mind, but it doesn't seem to the be right
> solution to me, as I need an inside shell rather than a stroked polygon.
>
> Any help would very much be appreciated!
>
> Best regards,
> Carsten
>
>
>
> --
> Dipl.-Inf. Carsten Fuchs
> Industriegebiet 3 ℅ Rofu
> 55768 Hoppstädten-Weiersbach
> https://www.cafu.de
>
> _______________________________________________
> OpenSCAD mailing list

> Discuss@.openscad

> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
>
>
> Bildschirmfoto von 2020-12-31 10-07-34.png (293K)
> &lt;http://forum.openscad.org/attachment/31390/0/Bildschirmfoto%20von%202020-12-31%2010-07-34.png&gt;





--
Sent from: http://forum.openscad.org/

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Can a shape change as it is extruded along the Z axis? (e.g. with BOSL2?)

Carsten Fuchs
Hello Adrian,

thank you very much for your explanation and the example, it helps a lot!

Best regards,
Carsten


Am 31.12.20 um 14:49 schrieb adrianv:

> In order to extrude a shape that changes arbitrarily you must use skin().  It
> takes a list of shapes and links them together.  To do this you need to keep
> your shape as a list of points rather than turning it into geometry, so
> shell2d and polygon won't work here.  Stroke is actually the right way to do
> what you want in 2d, but I think you need to use the offset_stroke version
> because it can control the direction of the offset.  You would use it on the
> original point list and it would give you the shape you need as geometry.  
> That would work for linear_extrude but can't be used as an input to skin().  
>
> To use skin() you'll need to construct your entire shape as coordinates.
> Ideally you could still use offset_stroke to do this, but unfortunately it
> is a module only and won't return its points.  So you have to call the
> offset() function (note, this is part of BOSL2, not the offset module that
> is core OpenSCAD) and connect the result to the points you start with.  
>
> include <BOSL2/std.scad>
> include <BOSL2/rounding.scad>
> include <BOSL2/skin.scad>
>
> function TestShape(breite) =
>    let(
>       h_leiste = 6,
>       b_leiste = 6,
>       h_senke = -3,
>       b_senke = 4,
>       h_seiten = -50,
>       punkte = [
>           [0, h_seiten],
>           [0, h_leiste],
>           [b_leiste, h_leiste],
>           [b_leiste, h_senke],
>           [breite - b_leiste, h_senke],
>           [breite - b_leiste, h_leiste],
>           [breite, h_leiste],
>           [breite, h_seiten],
>       ],
>       shape = round_corners(punkte, method="circle", cut=1, $fn=30),
>       inside = offset(shape,r=-1.5)
>    )
>    concat(shape, reverse(inside));
>
> breite = [100,105, 110,120,170, 200];
> z = [100, 120, 140, 160, 180, 200];
>
> profiles = [for(b=breite) TestShape(b)];
>
> skin(profiles, z=z, slices=0);
>
>
>
> Carsten Fuchs wrote
>> Dear group,
>>
>> I'm still new to OpenSCAD and have started to write my first projects.
>> I've also read a lot in the BOSL2 documentation, which is very well
>> written but is also a bit overwhelming.
>>
>> What I would like to do is extrude a 2D shape along the Z axis, as with
>> `linear_extrude()` keeping the shape always parallel to the XY plane, but
>> also change its shape and move it along a smoothed path.
>>
>> Please consider this example code, which can also be seen in the attached
>> screenshot:
>>
>> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>>
>> include &lt;BOSL2/std.scad&gt;
>> include &lt;BOSL2/rounding.scad&gt;
>>
>>
>> module TestShape() {
>>     h_leiste = 6;
>>     b_leiste = 6;
>>     h_senke = -3;
>>     b_senke = 4;
>>     h_seiten = -50;
>>
>>     // Can we change this variable as the shape is swept along the Z-axis?
>>     // (Using `path_sweep()` with method="manual" and normal=[0, 0, 1]
>>     //  to keep the shape in the XY-plane along the entire path.)
>>     breite = 125;
>>
>>     punkte = [
>>         [0, h_seiten],
>>         [0, h_leiste],
>>         [b_leiste, h_leiste],
>>         [b_leiste, h_senke],
>>         [breite - b_leiste, h_senke],
>>         [breite - b_leiste, h_leiste],
>>         [breite, h_leiste],
>>         [breite, h_seiten],
>>     ];
>>
>>     // polygon(punkte);
>>     // polygon(round_corners(punkte, method="circle", cut=1, $fn=30));
>>
>>     // Can the closing edge be omitted?
>>     shell2d(-1.5) {
>>         polygon(round_corners(punkte, method="circle", cut=1, $fn=30));
>>     };
>> }
>>
>>
>> TestShape();
>>
>> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>>
>> I think that I can move the shape along a smoothed path using
>> `path_sweep()` with `method="manual"` and `normal=[0, 0, 1]`, but how can
>> I change it (i.e. the number `breite` in the code) as it is extruded?
>>
>> Also, please see the question about the closing edge in the comment above.
>> Using `stroke()` comes into mind, but it doesn't seem to the be right
>> solution to me, as I need an inside shell rather than a stroked polygon.
>>
>> Any help would very much be appreciated!
>>
>> Best regards,
>> Carsten
>>
>>
>>
>> --
>> Dipl.-Inf. Carsten Fuchs
>> Industriegebiet 3 ℅ Rofu
>> 55768 Hoppstädten-Weiersbach
>> https://www.cafu.de
>>
>> _______________________________________________
>> OpenSCAD mailing list
>
>> Discuss@.openscad
>
>> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
>>
>>
>> Bildschirmfoto von 2020-12-31 10-07-34.png (293K)
>> &lt;http://forum.openscad.org/attachment/31390/0/Bildschirmfoto%20von%202020-12-31%2010-07-34.png&gt;
>
>
>
>
>
> --
> Sent from: http://forum.openscad.org/
>
> _______________________________________________
> OpenSCAD mailing list
> [hidden email]
> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
>

--
Dipl.-Inf. Carsten Fuchs
Industriegebiet 3 ℅ Rofu
55768 Hoppstädten-Weiersbach
https://www.cafu.de

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org