Skip to content

Instantly share code, notes, and snippets.

@gretel
Last active May 22, 2017 10:26
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gretel/3a2ff28e2489105f966c787eed160ef1 to your computer and use it in GitHub Desktop.
Save gretel/3a2ff28e2489105f966c787eed160ef1 to your computer and use it in GitHub Desktop.
// www.thingiverse.com/thing:1397964
// https://gist.github.com/gretel/3a2ff28e2489105f966c787eed160ef1
/* Measurements */
// Dog Width in inches
A = 5.906;
// Dog Height in inches
B = 11.417;
// Dog Length in inches
C = 17.717;
// Weight of Dog in pounds(<10 pounds will have an extra support bar)
D = 11;
/* Parts
01: All Parts
99: Wheelchair Simulation
10: Part A
20: Part B
21: Part B2
30: Part C
40: Part D
50: Part E
*/
DEFAULT_PART = 99;
/* Materials */
// in inches!
//wheel_diameter = 2.04724; // 52mm skateboard wheels
wheel_diameter = 2.75591; // 70mm skateboard wheels
// in inches!
screw_diameter = 0.19685; // 5.00mm
// in inches!
//tube_outer_diameter = 0.79331; // 20.15mm polycarbonat tube
tube_outer_diameter = 0.79527; // 20.20mm polycarbonat tube
// degrees
wheel_angle = 0; // 15 for back tilt
/* Computer */
dog_width = A; // A = As is
dog_height = B - wheel_diameter / 2 - 1; // B = measurement - wheel radius - 1"
dog_length = C - 2; // C = length of dog from their belly to their tail, minus 2"
dog_bar = D > 10; // D = weight of dog
$fn=70; // TODO ?
tube_outer_radius = tube_outer_diameter / 2;
// Joint Piece Inner Readius Cutout (9.525 mm or 0.375 inch is exact size, 9.85mm or 0.388 inch is slightly larger for Makerbots)
inner_radius = tube_outer_radius * 25.4;
screwsize = screw_diameter * 12.7;
wheelsize = wheel_diameter * 12.7;
// Joint Piece Outer Radius
//outer_radius = inner_radius * 1.57; // TODO ?
outer_radius = 14.95425;
// Cylinder Length
cyllength = 25.4;
// Torus Bend Parameters
bend_radius = 1;
angle_1 = -30;
angle_2 = 60;
// Wheelchair Simulation
chairlength = dog_length * 25.4 - 50.8;
chairwidth = dog_width * 25.4;
chairheight = dog_height * 25.4 - wheelsize - 25.4;
chairwheeldistance = 90;
// Total lenght of tube material required
tube_len = chairlength * 2 + chairwidth * 2 + chairheight * 2;
// Verbose
echo("version_num", version_num());
echo("dog_height=", dog_height, "dog_width=", dog_width, ", dog_length=", dog_length, ", dog_bar=", dog_bar);
echo("tube_outer_diameter=", tube_outer_diameter, "tube_outer_radius=", tube_outer_radius, ", inner_radius=", inner_radius);
echo("screwsize=", screwsize, "wheelsize=", wheelsize);
echo("chairlength=", chairlength, "chairwidth=", chairwidth, ", chairheight=", chairheight);
echo("tube_len=", tube_len);
/* Functions */
module wheelchair(){
union(){
translate([ chairwidth, 0 ,0])
rotate(a=90, v=[1,0,0])
cylinder(r=inner_radius, h=chairlength, $fn=60);
mirror(){
rotate(a=90, v=[1,0,0])
cylinder(r=inner_radius, h=chairlength, $fn=60);
}
rotate(a=90, v=[0,1,0])
cylinder(r=inner_radius, h=chairwidth, $fn=60);
rotate(a=wheel_angle, v=[1,0,0])
translate([ 0, -chairwheeldistance ,-chairheight])
cylinder(r=inner_radius, h=chairheight, $fn=60);
mirror (){
rotate(a=wheel_angle, v=[1,0,0])
translate([ -chairwidth, -chairwheeldistance ,-chairheight])
cylinder(r=inner_radius, h=chairheight, $fn=60);
}
if (dog_bar) {
if (wheel_angle) {
translate([ 0, wheel_angle * 2 ,0])
rotate(a=90, v=[0,1,0])
translate([ chairheight, -chairwheeldistance ,0])
cylinder(r=inner_radius, h=chairwidth, $fn=60);
} else {
rotate(a=90, v=[0,1,0])
translate([ chairheight, -chairwheeldistance ,0])
cylinder(r=inner_radius, h=chairwidth, $fn=60);
}
}
}
if (wheel_angle) {
translate([ 0, wheel_angle * 2 ,0])
color("black")
intersection(){
rotate(a=90, v=[0,1,0])
translate([ chairheight + 30, -chairwheeldistance , -28])
scale([1,1,0.25])
sphere(r=wheelsize, $fn=60);
}
translate([ 0, wheel_angle * 2 ,0])
color("black")
mirror (){
rotate(a=90, v=[0,1,0])
translate([ chairheight + 30, -chairwheeldistance , - chairwidth -28])
scale([1,1,0.25])
sphere(r=wheelsize, $fn=60);
}
} else {
color("dimgrey")
intersection(){
rotate(a=90, v=[0,1,0])
translate([ chairheight + 30, -chairwheeldistance , -28])
scale([1,1,0.25])
sphere(r=wheelsize, $fn=60);
}
color("dimgrey")
mirror (){
rotate(a=90, v=[0,1,0])
translate([ chairheight + 30, -chairwheeldistance , - chairwidth -28])
scale([1,1,0.25])
sphere(r=wheelsize, $fn=60);
}
}
}
module wheelchairwithbar(){
wheelchair();
rotate(a=90, v=[0,1,0])
translate([ chairheight, -chairwheeldistance ,0])
cylinder(r=inner_radius, h=chairwidth, $fn=60);
}
module bend(){
// bend
difference(){
// torus
rotate_extrude()
translate([bend_radius + outer_radius, 0, 0])
circle(r=outer_radius, $fn=6);
// torus cutout
rotate_extrude()
translate([bend_radius + outer_radius, 0, 0])
circle(r=inner_radius);
// lower cutout
rotate([0, 0, angle_1])
translate([-100 * (((angle_2 - angle_1) <= 180)?1:0), -100, -50])
cube([300, 100, 100]);
// upper cutout
rotate([0, 0, angle_2])
translate([-100 * (((angle_2 - angle_1) <= 180)?1:0), 0, -50])
cube([300, 100, 100]);
}
}
module bend2(){
intersection(){
rotate([0, 0, -30])
translate([0,0,-50])
cube([100, 100, 100]);
union(){
// bend
difference(){
// torus
rotate_extrude()
translate([bend_radius + outer_radius, 0, 0])
rotate([0, 0, 90])
circle(r=outer_radius, $fn=6);
// torus cutout
rotate_extrude()
translate([bend_radius + outer_radius, 0, 0])
circle(r=inner_radius);
// lower cutout
rotate([0, 0, angle_1])
translate([-100 * (((angle_2 - angle_1) <= 180)?1:0), -100, -50])
cube([300, 100, 100]);
// upper cutout
rotate([0, 0, angle_2])
translate([-100 * (((angle_2 - angle_1) <= 180)?1:0), 0, -50])
cube([300, 100, 100]);
}
}
}
}
module strapholes(){
translate([-15, 33, -50])
cylinder(r=screwsize, h= 100);
}
module straps1(){
//straps
difference(){
union(){
translate([-25.38, 28.9, -10])
cube([20, 20, 20]);
}
union(){
rotate(a=-30, v=[1,0,0])
translate([-40, -100, 20.926])
cube([200, 200, 20]);
rotate(a=30, v=[1,0,0])
translate([-40, -100, -43.63])
cube([200, 200, 22.7]);
translate([-40, 39, -20])
cube([200, 200, 50]);
}
rotate(a= 10, v=[1,0,0])
strapholes();
}
}
module straps2(){
//straps
difference(){
union(){
translate([-25.38, 28.9, -10])
cube([12, 20, 20]);
}
union(){
rotate(a=-30, v=[1,0,0])
translate([-40, -100, 20.926])
cube([200, 200, 20]);
rotate(a=30, v=[1,0,0])
translate([-40, -100, -43.63])
cube([200, 200, 22.7]);
}
translate([-40, 39, -20])
cube([200, 200, 50]);
rotate(a=90, v=[0,1,0])
translate([0, 33, -50])
cylinder(r=screwsize, h= 205);
}
}
module straps3(){
//straps
difference(){
union(){
translate([-25.38, 28.9, -10])
cube([20, 20, 20]);
}
union(){
rotate(a=-30, v=[1,0,0])
translate([-40, -100, 20.926])
cube([200, 200, 20]);
rotate(a=30, v=[1,0,0])
translate([-40, -100, -43.63])
cube([200, 200, 22.7]);
translate([-40, 39, -20])
cube([200, 200, 50]);
}
rotate(a= -10, v=[1,0,0])
strapholes();
}
}
module partA() {
union() {
// lower arm
rotate([0, 0, angle_1])
translate([bend_radius + outer_radius, 0.02, 0])
rotate([90, 90, 0])
difference() {
cylinder(r=outer_radius, h=cyllength, $fn=6);
translate([0, 0, -1])
cylinder(r=inner_radius, h=cyllength +5 );
}
// upper arm
rotate([0, 0, angle_2])
translate([bend_radius + outer_radius, -0.02, 0])
rotate([-90, 90, 0])
difference() {
cylinder(r=outer_radius, h=cyllength, $fn=6);
translate([0, 0, -1])
cylinder(r=inner_radius, h=cyllength + 5);
}
bend2();
union(){
rotate(a=-30, v=[0,0,1])
// translate([-25.4, 0, -10]) // TODO ?
straps1();
}
}
}
module partB() {
if (wheel_angle ==15){
union(){
rotate(a=120, v=[0,0,1])
union() {
// lower arm
rotate([0, 0, angle_1])
//tangle is 0
translate([bend_radius + outer_radius - 1.3, 0.02 + 6.8 , 0])
rotate([90, 0, wheel_angle])
difference() {
cylinder(r=outer_radius, h=cyllength + 8, $fn=6);
translate([0, 0, -10])
cylinder(r=inner_radius, h=cyllength +20);
union(){
rotate([0, 75, 0])
translate([bend_radius + outer_radius - 7, -38, 45])
translate([0, 38, -50])
cylinder(r=inner_radius, h=cyllength * 4);
}
}
// upper arm
rotate([0, 0, angle_2])
translate([bend_radius + outer_radius, -38, 0])
rotate([-90, 0, 0])
difference() {
cylinder(r=outer_radius, h=cyllength * 1.75, $fn=6 );
translate([0, 0, -1])
cylinder(r=inner_radius, h=cyllength *2 + 5);
}
difference(){
bend();
rotate([0, 0, angle_2])
translate([bend_radius + outer_radius, -40, 0])
rotate([-90, 0, 0])
translate([0, 0, -1])
cylinder(r=inner_radius, h=cyllength *2 + 5);
union(){
rotate(a=64, v=[0,0,1])
translate([-47, -50, -25])
cube(50,50,50);
}
}
}
}
rotate(a=90, v=[0,1,0])
rotate(a=-90, v=[0,0,1])
translate([-12.62, -15.95, -15.95])
straps3();
} else {
union(){
rotate(a=120, v=[0,0,1])
union() {
// lower arm
rotate([0, 0, angle_1])
//tangle is 0
translate([bend_radius + outer_radius, 0.02, 0])
rotate([90, 0, wheel_angle])
difference() {
cylinder(r=outer_radius, h=cyllength, $fn=6);
translate([0, 0, -10])
cylinder(r=inner_radius, h=cyllength +15);
}
// upper arm
rotate([0, 0, angle_2])
translate([bend_radius + outer_radius, -38, 0])
rotate([-90, 0, 0])
difference() {
cylinder(r=outer_radius, h=cyllength * 1.75, $fn=6 );
translate([0, 0, -1])
cylinder(r=inner_radius, h=cyllength *2 + 5);
}
difference(){
bend();
rotate([0, 0, angle_2])
translate([bend_radius + outer_radius, -40, 0])
rotate([-90, 0, 0])
translate([0, 0, -1])
cylinder(r=inner_radius, h=cyllength *2 + 5);
}
}
}
rotate(a=90, v=[0,1,0])
rotate(a=-90, v=[0,0,1])
translate([-12.62, -15.95, -15.95])
straps1();
}
}
module partB2() {
mirror(){
if (wheel_angle == 15){
union(){
rotate(a=120, v=[0,0,1])
union() {
// lower arm
rotate([0, 0, angle_1])
//tangle is 0
translate([bend_radius + outer_radius - 1.3, 0.02 + 6.8 , 0])
rotate([90, 0, wheel_angle])
difference() {
cylinder(r=outer_radius, h=cyllength + 8, $fn=6);
translate([0, 0, -10])
cylinder(r=inner_radius, h=cyllength +20);
union(){
rotate([0, 75, 0])
translate([bend_radius + outer_radius - 7, -38, 45])
translate([0, 38, -50])
cylinder(r=inner_radius, h=cyllength * 4);
}
}
// upper arm
rotate([0, 0, angle_2])
translate([bend_radius + outer_radius, -38, 0])
rotate([-90, 0, 0])
difference() {
cylinder(r=outer_radius, h=cyllength * 1.75, $fn=6);
translate([0, 0, -1])
cylinder(r=inner_radius, h=cyllength *2 + 5);
}
difference(){
bend();
rotate([0, 0, angle_2])
translate([bend_radius + outer_radius, -40, 0])
rotate([-90, 0, 0])
translate([0, 0, -1])
cylinder(r=inner_radius, h=cyllength *2 + 5);
union(){
rotate(a=64, v=[0,0,1])
translate([-47, -50, -25])
cube(50,50,50);
}
}
}
}
rotate(a=90, v=[0,1,0])
rotate(a=-90, v=[0,0,1])
translate([-12.62, -15.95, -15.95])
straps3();
} else {
union(){
rotate(a=120, v=[0,0,1])
union() {
// lower arm
rotate([0, 0, angle_1])
//tangle is 0
translate([bend_radius + outer_radius, 0.02 , 0])
rotate([90, 0, wheel_angle])
difference() {
cylinder(r=outer_radius, h=cyllength, $fn=6);
translate([0, 0, -10])
cylinder(r=inner_radius, h=cyllength +15);
}
// upper arm
rotate([0, 0, angle_2])
translate([bend_radius + outer_radius, -38, 0])
rotate([-90, 0, 0])
difference() {
cylinder(r=outer_radius, h=cyllength * 1.75, $fn=6 );
translate([0, 0, -1])
cylinder(r=inner_radius, h=cyllength *2 + 5);
}
difference(){
bend();
rotate([0, 0, angle_2])
translate([bend_radius + outer_radius, -40, 0])
rotate([-90, 0, 0])
translate([0, 0, -1])
cylinder(r=inner_radius, h=cyllength *2 + 5);
}
}
}
rotate(a=90, v=[0,1,0])
rotate(a=-90, v=[0,0,1])
translate([-12.62, -15.95, -15.95])
straps1();
}
}
}
module partC() {
difference(){
rotate(a=120, v=[0,0,1])
union() {
// lower arm
rotate([0, 0, angle_1])
translate([bend_radius + outer_radius, 0.02, 0])
rotate([90, 0, 0])
rotate([0, 0, 90])
difference() {
cylinder(r=outer_radius, h=cyllength - 5.4, $fn=6 );
translate([0, 0,-10])
cylinder(r=inner_radius, h=cyllength + 60 );
}
}
}
translate([25.36, 0, 0])
straps1();
}
module partD() {
difference(){
union() {
rotate(a=120, v=[0,0,1])
// lower arm
rotate([0, 0, angle_1])
translate([bend_radius + outer_radius, 0.02, 0])
rotate([90, 0, 0])
rotate([0, 0, 90])
difference() {
cylinder(r=outer_radius, h=cyllength + 20, $fn=6 );
translate([0, 0,10])
cylinder(r=inner_radius, h=cyllength +25 );
}
}
}
union(){
translate([50.76, 0, 0])
straps1();
translate([25.36, 0, 0])
straps2();
}
}
module partE() {
if (wheel_angle){
translate ([0,0,- wheel_angle * 2.2])
rotate (a=wheel_angle, v=[1,0,0])
difference(){
rotate(a=120, v=[0,0,1])
union() {
if (dog_bar) {
// lower arm
rotate([0, 0, angle_1])
translate([bend_radius + outer_radius, 0.02, 0])
rotate([90, 90, 0])
difference() {
cylinder(r=outer_radius, h=cyllength, $fn=6);
translate([0, 0, -1])
cylinder(r=inner_radius, h=cyllength +5);
}
}
// upper arm
rotate([0, 0, angle_2])
translate([bend_radius + outer_radius, -43, 0])
rotate([-90, 90, 0])
difference() {
cylinder(r=outer_radius, h=cyllength * 1.75 +25.4 , $fn=6);
translate([0, 0, -1])
cylinder(r=inner_radius, h=cyllength *2 + 5);
// start wheel hole
translate([0, 50, 60])
rotate(a=90, v=[1,0,0])
cylinder(r=screwsize, h= 205);
}
//end wheel hole
difference(){
if (dog_bar) {
bend2();
}
//glitch that makes no sense but needs to exist (sorry)
cylinder(r=0, h=0);
//end glitch
rotate([0, 0, angle_2])
translate([bend_radius + outer_radius, -40, 0])
rotate([-90, 0, 0])
translate([0, 0, -1])
cylinder(r=inner_radius, h=cyllength *2 + 5);
}
}
}
} else {
translate ([0,0,- wheel_angle * 2.2])
rotate (a=wheel_angle, v=[1,0,0])
difference(){
rotate(a=120, v=[0,0,1])
union() {
if (dog_bar) {
// lower arm
rotate([0, 0, angle_1])
translate([bend_radius + outer_radius, 0.02, 0])
rotate([90, 90, 0])
difference() {
cylinder(r=outer_radius, h=cyllength, $fn=6);
translate([0, 0, -1])
cylinder(r=inner_radius, h=cyllength +5);
}
}
// upper arm
rotate([0, 0, angle_2])
translate([bend_radius + outer_radius, -43, 0])
rotate([-90, 90, 0])
difference() {
cylinder(r=outer_radius, h=cyllength * 1.75 + 25.4, $fn=6);
translate([0, 0, -1])
cylinder(r=inner_radius, h=cyllength * 2 + 5);
// start wheel hole
translate([0, 50, 60])
rotate(a=90, v=[1,0,0])
cylinder(r=screwsize, h= 205);
}
//end wheel hole
difference(){
if (dog_bar) {
bend2();
}
//glitch that makes no sense but needs to exist (sorry)
cylinder(r=0, h=0);
//end glitch
rotate([0, 0, angle_2])
translate([bend_radius + outer_radius, -40, 0])
rotate([-90, 0, 0])
translate([0, 0, -1])
cylinder(r=inner_radius, h=cyllength *2 + 5);
}
}
}
}
}
//
/* Render */
module print_part(_part = undef) {
echo("print_part", _part);
if (_part == 99) {
union(){
//partA
translate([outer_radius,-outer_radius,0])
rotate(a=120, v=[0,0,1])
color("Yellow")
partA();
mirror(){
translate([-chairwidth + outer_radius,-outer_radius,0])
rotate(a=120, v=[0,0,1])
color("Yellow")
partA();
}
//partB
translate([ 0, -chairwheeldistance - outer_radius , -outer_radius])
rotate(a=90, v=[0,1,0])
color("Chartreuse")
partB();
mirror(){
translate([ -chairwidth, -chairwheeldistance - outer_radius , -outer_radius])
rotate(a=90, v=[0,1,0])
color("Chartreuse")
partB();
}
//partC
translate([outer_radius , -chairwheeldistance - 80 , 0])
rotate(a=90, v=[0,0,1])
color("Magenta")
partC();
mirror(){
translate([-chairwidth + outer_radius , -chairwheeldistance - 80 , 0])
rotate(a=90, v=[0,0,1])
color("Magenta")
partC();
}
//partD
translate([outer_radius , -chairlength , 0])
rotate(a=90, v=[0,0,1])
color("Cyan")
partD();
mirror(){
translate([-chairwidth + outer_radius , -chairlength , 0])
rotate(a=90, v=[0,0,1])
color("Cyan")
partD();
}
//partE
translate([outer_radius , -chairwheeldistance , -chairheight - outer_radius])
rotate(a=90, v=[1,0,0])
color("Blue")
partE();
mirror(){
translate([ - chairwidth + outer_radius , -chairwheeldistance , -chairheight - outer_radius])
rotate(a=90, v=[1,0,0])
color("Blue")
partE();
}
//wheelchair
translate([ 0, 0 ,0])
color("LightGrey")
wheelchair();
}
} else if (_part == 10) {
rotate(a=-90, v=[1,0,0])
translate([ -80,-30 , 25])
rotate(a=120, v=[0,0,1])
color("Yellow")
partA();
} else if (_part == 20) {
translate([ -90, -20 , 13])
rotate(a=180, v=[1,0,0])
color("Chartreuse")
partB();
} else if (_part == 21) {
translate([ -90, -20 , 13])
rotate(a=180, v=[1,0,0])
color("Green")
partB2();
} else if (_part == 30) {
translate([-40 , 10 , -3])
rotate(a=90, v=[1,0,0])
color("Magenta")
partC();
} else if (_part == 40) {
translate([30 , -35 , -3])
rotate(a=90, v=[1,0,0])
color("Cyan")
partD();
} else if (_part == 50) {
translate([ -10, -35 , 29])
rotate(a=90, v=[0,0,1])
rotate(a=-90, v=[0,1,0])
color("Blue")
partE();
} else if (_part == 1) {
union() {
//partA
rotate(a=-90, v=[1,0,0])
translate([-70, -30, 25])
rotate(a=120, v=[0,0,1])
color("Yellow")
partA();
//partB
translate([0, 30, 13])
rotate(a=180, v=[1,0,0])
color("Chartreuse")
partB();
//partB2
// TODO check
translate([60, 30, 13])
rotate(a=180, v=[1,0,0])
color("Green")
partB2();
//partC
translate([-70, -30, -3])
rotate(a=90, v=[1,0,0])
color("Magenta")
partC();
//partD
translate([40, -30, -3])
rotate(a=90, v=[1,0,0])
color("Cyan")
partD();
//partE
translate([0, -30, 29])
rotate(a=90, v=[0,0,1])
rotate(a=-90, v=[0,1,0])
color("Blue")
partE();
}
} else {
echo("skipping unknown part", _part);
}
}
print_part(DEFAULT_PART);
#/bin/sh
#
"/Applications/OpenSCAD.app/Contents/MacOS/OpenSCAD" -D "DEFAULT_PART=undef;print_part(10);" -o figo_part_a.stl figo.scad
"/Applications/OpenSCAD.app/Contents/MacOS/OpenSCAD" -D "DEFAULT_PART=undef;print_part(20);" -o figo_part_b.stl figo.scad
"/Applications/OpenSCAD.app/Contents/MacOS/OpenSCAD" -D "DEFAULT_PART=undef;print_part(21);" -o figo_part_b2.stl figo.scad
"/Applications/OpenSCAD.app/Contents/MacOS/OpenSCAD" -D "DEFAULT_PART=undef;print_part(30);" -o figo_part_c.stl figo.scad
"/Applications/OpenSCAD.app/Contents/MacOS/OpenSCAD" -D "DEFAULT_PART=undef;print_part(40);" -o figo_part_d.stl figo.scad
"/Applications/OpenSCAD.app/Contents/MacOS/OpenSCAD" -D "DEFAULT_PART=undef;print_part(50);" -o figo_part_e.stl figo.scad
"/Applications/OpenSCAD.app/Contents/MacOS/OpenSCAD" -D "DEFAULT_PART=undef;print_part(01);" -o figo_parts.stl figo.scad
"/Applications/OpenSCAD.app/Contents/MacOS/OpenSCAD" -D "DEFAULT_PART=undef;print_part(99);" -o figo_simul.png figo.scad
"/Applications/OpenSCAD.app/Contents/MacOS/OpenSCAD" -D "DEFAULT_PART=undef;print_part(10);print_part(20);print_part(21);print_part(30);print_part(40);print_part(50);" -o figo_part_all.stl figo.scad
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment