linear_extrude()

Linear extrude uses a 2d shape and extrudes it along a single axis to create a 3d shape.

Let.s create a basic extrusion.

Create a 2d square , use square(10);

Precede the square(10); with linear_extrude(10)

You can extrude any 2d shape, and you can modify the extrusion along the way.

Adding a twist, if we center the square and add a 360 twist we get a screw-like shape.

Use this code ( the $fn=90, just makes it prettier ).

linear_extrude(10,twist=360)
    square(10,center=true);

$fn=90;

To make this shape:

Or let’s make a rope real fast. Try out this code ( don’t worry about the decimals for now the just put all three circles evenly around the center.

color( "Tan")

linear_extrude(300,twist=720) {
    translate([5,2.88675,0])
    circle(5);

    translate([-5,2.88675,0])
    circle(5);

    translate([0,-5.7735,0])
    circle(5);
}

$fn=90;

You can also extrude polygons using the polygon command.

linear_extrude(2)
polygon(points = [ [2,2],[15,4],[15,-4],[2,-2] ]);

The center command in linear extrude, centers the final result not the process. Half of the extrusion will be above the XY plane and half below the XY plane.

If you want the axis of the extrusion around the Z-Axis you should center the base object. The code below center the square before the extrusion, and then performs the extrusion. This is important and is the difference between a screw shape and a rope shape.

linear_extrude(10)
square(10,center=true);

2 Replies to “linear_extrude()”

  1. seidenblaster

    I’m trying to get a twisted square into TinkerCAD. It imports just fine, but it’s made of lots of rotated squares, rather than being a single screw shape with a smooth surface (as it appears in OpenSCAD).

    Is there a way to smooth the surface in OpenSCAD? Thanks.

    0
    0

Leave a Reply