Spinning text gif that says yits site

Openscad Parametric Twist Containers

I printed one of the twist containers that Devin Montes made, and it turned out great. I had to make some of my own, so I could have any number of sides that I wanted. The idea is that there are two twisted prisms, where one is just slightly bigger than the other. If you get the tolerance right they will just barely slide past one another, which makes it hard for the air to get out. I designed them using the program openscad.

Since there is an inside and an outside the model should be saved as two stl files. I accomplished this with a shell script and an if statement with the input from the command. Here is the shell script:

#!/bin/sh
openscad -DPART='"inside"' -o inside.stl twist.scad
openscad -DPART='"outside"' -o outside.stl twist.scad

And then for openscad there needs to be an if statement to use this input. If the part is equal to "inside" then render the inside. Otherwise, if it equals "outside", render the outside. And if it is neither of those, display both for preview purposes. Here is the import part of the openscad code:

if (PART == "inside") {
        inside();
} else if (PART == "outside") {
        outside();
} else {
    inside();
    translate([size*2,0,0]) outside();
}

If the arguments say inside, it renders the inside. If they say outside, it renders the outside. Otherwise, it will preview both. Here is the full openscad code:

$fn=256; //resolution of shape, turn higher for more tris

height=100; //The height of the container

tolerance=1; //The distance between the outer and the inner vases

size=70; //Approximately the diameter of the container

roundness=20; //The radius of the corners

twist=-90; //Amount it twists by, negative to get a right handed container

chamfer_thickness=1; //How tall the chamfer is

chamfer_width=1; //How far in the chamfer goes

sides=3; //Number of sides on the container

base_thickness=3; //How tall the grip on the base is

base_width=2; //How for out the grip on the base is


base_slope=base_width/base_thickness; //How steep the grip is


module base() { //Make a circle for every side, and evenly space them
    hull() {
        for (i=[1:sides])
                        rotate(360/sides*i)translate([size/2-roundness,0,0])circle(roundness);
        }
}

module handle() { //Make two tapered prisms, and put them together
    translate([0,0,-base_thickness])
    linear_extrude(base_thickness/2,scale=(size+base_slope*base_thickness)/size)base();
    scale([1,1,-1])
    linear_extrude(base_thickness/2,scale=(size+base_slope*base_thickness)/size)base();
}

module chamfer() { //Make a taped prism for the top chamfer
        rotate([0,0,-twist])translate([0,0,height-chamfer_thickness])
        linear_extrude(chamfer_thickness,scale=(size-chamfer_width)/size)
        base();
}

//The inside is the combination of a twisted prism, the base, and the chamfer
module inside() {
    union() {
        handle();
            linear_extrude(height-chamfer_thickness,slices=$fn,twist=twist)base();
            chamfer();
    }
}

//The outside is just a twisted prism, just slightly bigger than the inside
module outside() {
        linear_extrude(height,slices=$fn,twist=twist)
        offset(tolerance)base();
}

//Get part information from the command line, so that both the inside and the outside can be rendered automatically
PART=undef;

if (PART == "inside") {
        inside();
} else if (PART == "outside") {
        outside();
} else {
    inside();
    translate([size*2,0,0]) outside();
}