wizulus
wizulus

Reputation: 6343

OpenSCAD - Cylinder from axis

How can I create this shape? The depicted shape can be interpreted as one of the following:

  1. A cone that comes to a line instead of a point.
  2. A loft from a circle to a straight line.
  3. A loft from a circle to a square of [0,1].
  4. A cylinder with one side squeezed in.

-- The curve on the face of the circle would be ideal for accuracy, but not strictly necessary.

Approximation in OpenSCAD using this code:

Cylinder projected from axis

Shape achieved in Fusion360:

Shape achieved in Fusion360

Upvotes: 1

Views: 852

Answers (2)

a_manthey_67
a_manthey_67

Reputation: 4286

You can simply extrude a circle and scale it over the length of extrusion to a flat line. The scale-parameter s. documentation of linear_extrude can be a scalar or a vector with x- and y-scale-factor. Set one of them to 1 and the other to 0:

$fs = 0.01;
$fa = 0.01;

linear_extrude(height = 15, scale =[0, 1]) circle(d = 10);

The result: enter image description here

Upvotes: 5

wizulus
wizulus

Reputation: 6343

I learned you can do a convex loft using hull.

module pinch(h=1,r1=1,r2=1,r3=0) {
    zero = 0.00000000001;
    steps = $fn ? $fn : $fa;
    res = h/steps;
    r1 = r1 ? r1 : res;
    r2 = r2 ? r2 : res;
    r3 = r3 ? r3 : zero;
    hull() {
        cylinder(h=zero,r=r1,r2=res,r3=0,center=false);
        translate([-r2, -r3, h - zero]) cube([
            r2 * 2,
            r3 * 2,
            zero
        ]);
    }
}

translate([1,0,.5]) rotate([0,-90,0]) pinch(1, .5, .5, $fn=50);

Loft using Hull

Upvotes: 0

Related Questions