2017-04-30 20:28:05 +08:00
# path_extrude
It extrudes a 2D shape along a path. This module is suitable for a path created by a continuous function.
2017-05-04 10:29:31 +08:00
It depends on the `rotate_p` function and the `polysections` module. Remember to include "rotate_p.scad" and "polysections.scad".
2017-04-30 20:28:05 +08:00
2017-05-10 16:31:13 +08:00
When using this module, you should use points to represent the 2D shape. If your 2D shape is not solid, indexes of triangles are required. See [polysections ](https://openhome.cc/eGossip/OpenSCAD/lib-polysections.html ) for details.
2017-04-30 20:28:05 +08:00
## Parameters
- `shape_pts` : A list of points represent a shape. See the example below.
- `path_pts` : A list of points represent the path.
2017-05-10 16:31:13 +08:00
- `triangles` : `"SOLID"` (default), `"HOLLOW"` or user-defined indexes. See example below.
2017-05-02 20:03:36 +08:00
- `twist` : The number of degrees of through which the shape is extruded.
2017-05-02 20:15:48 +08:00
- `scale` : Scales the 2D shape by this value over the length of the extrusion. Scale can be a scalar or a vector.
2017-05-03 15:42:33 +08:00
- `closed` : If the first point and the last point of `path_pts` has the same coordinate, setting `closed` to `true` will connect them automatically.
2017-04-30 20:28:05 +08:00
## Examples
include < rotate_p.scad > ;
include < polysections.scad > ;
include < path_extrude.scad > ;
include < bezier_curve.scad > ;
2017-05-16 11:16:34 +08:00
2017-04-30 20:28:05 +08:00
t_step = 0.05;
width = 2;
2017-05-16 11:16:34 +08:00
2017-04-30 20:28:05 +08:00
p0 = [0, 0, 0];
p1 = [40, 60, 35];
p2 = [-50, 70, 0];
p3 = [20, 150, -35];
p4 = [30, 50, -3];
2017-05-16 11:16:34 +08:00
shape_pts = [
[5, -5],
[3, 4],
[0, 5],
[-5, -5]
2017-04-30 20:28:05 +08:00
];
2017-05-16 11:16:34 +08:00
2017-04-30 20:28:05 +08:00
path_pts = bezier_curve(t_step,
2017-05-16 11:16:34 +08:00
[p0, p1, p2, p3, p4]
2017-04-30 20:28:05 +08:00
);
2017-05-16 11:16:34 +08:00
2017-04-30 20:28:05 +08:00
path_extrude(shape_pts, path_pts);
![path_extrude ](images/lib-path_extrude-1.JPG )
include < rotate_p.scad > ;
include < polysections.scad > ;
include < path_extrude.scad > ;
include < bezier_curve.scad > ;
2017-05-16 11:16:34 +08:00
2017-04-30 20:28:05 +08:00
t_step = 0.05;
2017-05-16 11:16:34 +08:00
2017-04-30 20:28:05 +08:00
p0 = [0, 0, 0];
p1 = [40, 60, 35];
p2 = [-50, 70, 0];
p3 = [20, 150, -35];
p4 = [30, 50, -3];
2017-05-16 11:16:34 +08:00
2017-04-30 20:28:05 +08:00
shape_pts = [
2017-05-16 11:16:34 +08:00
// outer
2017-05-19 09:30:51 +08:00
[5, 0],
[3, 9],
[0, 10],
[-5, 0],
2017-05-16 11:16:34 +08:00
// inner
2017-05-19 09:30:51 +08:00
[3, 2],
[2, 7],
[0, 7],
[-3, 2]
2017-04-30 20:28:05 +08:00
];
2017-05-16 11:16:34 +08:00
2017-04-30 20:28:05 +08:00
path_pts = bezier_curve(t_step,
2017-05-16 11:16:34 +08:00
[p0, p1, p2, p3, p4]
2017-04-30 20:28:05 +08:00
);
2017-05-16 11:16:34 +08:00
2017-04-30 20:28:05 +08:00
path_extrude(shape_pts, path_pts, triangles = "HOLLOW");
![path_extrude ](images/lib-path_extrude-2.JPG )
include < rotate_p.scad > ;
include < polysections.scad > ;
include < path_extrude.scad > ;
include < bezier_curve.scad > ;
t_step = 0.05;
p0 = [0, 0, 0];
p1 = [40, 60, 35];
p2 = [-50, 70, 0];
2017-05-16 11:16:34 +08:00
p3 = [20, 150, -5];
p4 = [50, 50, -3];
2017-04-30 20:28:05 +08:00
shape_pts = [
// outer
2017-05-19 09:30:51 +08:00
[10, 0],
[-5, 10],
[-10, 0],
2017-04-30 20:28:05 +08:00
// inner
2017-05-19 09:30:51 +08:00
[7, 1],
[-4, 8],
[-7, 1]
2017-04-30 20:28:05 +08:00
];
path_pts = bezier_curve(t_step,
[p0, p1, p2, p3, p4]
);
path_extrude(
shape_pts,
path_pts,
triangles = [
2017-05-16 11:16:34 +08:00
[0, 4, 3],
[0, 1, 4],
[1, 5, 4],
[1, 2, 5],
[2, 3, 5],
[2, 0, 3]
]
2017-04-30 20:28:05 +08:00
);
![path_extrude ](images/lib-path_extrude-3.JPG )