manifold working! with cosine!

manifold working! with cosine!

$fn=32;
sleeve_height=35;
sleeve_inside=30;
sleeve_wall=5;

// burrower is to be used 6 times, one on each section to make a circle-groove
module burrower (degrees=360/6,
					section_num=0,		// passed in for echo debug
					upndown=0, 			// ie -20, 0, 20 - relative rise / fall
					currentline=20, 		// starting z-level
					radius=30, 				// of can
					quant=40, 				// how many cuts/section
					bulge=4,				// radius of cutter-sphere
					huck=24,				// fine-ness of cutter '$fn'
					){
		echo("currentline = ", currentline, " section = ", section_num);
		for (i=[0:degrees/quant:degrees- (degrees/quant)*.5]){
			rotate([0, 0, i])
			translate([radius, 0, currentline - upndown*cos(i/degrees*180)*.5 + upndown/2])
				sphere(r=bulge, center=true, $fn=huck);
		}
}

s=11;
lvl1 = 30;
digmap = [[1,lvl1,0], [2, lvl1, 0], [3, lvl1, -s], [4, lvl1-s , -s], [5, lvl1-s-s ,s], [6, lvl1-s, s]];

digmap = [[1,lvl1,0], [2, lvl1, 0], [3, lvl1, -s], [4, lvl1-s , -s], [5, lvl1-s-s ,s], [6, lvl1-s, s]];

module digdug (sections=6, instructions=digmap){
	for (shovel=instructions){
	rotate([0,0,(shovel[0]-1)*(360/sections)]){
		if (shovel[0] < 3){
			#burrower(currentline=shovel[1],
						section_num=shovel[0], upndown=shovel[2]);
			echo("section ",shovel[0]," is done");
		}
		else {
			%burrower(currentline=shovel[1],
						section_num=shovel[0], upndown=shovel[2]);
		}
	}
	}
}

//difference(){
//	translate([0,0,sleeve_height/2])
//		sleeve(outside_r=sleeve_inside+sleeve_wall, inside_r=sleeve_inside, ht=sleeve_height);
	digdug();
//}

module sleeve(outside_r=sleeve_inside+sleeve_wall,
				inside_r=sleeve_inside,
				ht=sleeve_height){
	echo("outside_r=",outside_r,
				"inside_r=",inside_r,
				"ht=",ht);
	difference(){
		cylinder(r=outside_r, h=ht, center=true, $fn=128);
		cylinder(r=inside_r, h=ht+.1, center=true, $fn=128);
	}
}

/*
translate([0,0,sleeve_height/2])
	sleeve(outside_r=sleeve_inside, inside_r=sleeve_inside-2, ht=sleeve_height);
*/
module strude(angle=45, xtilt=1, ytilt=1, cylinder_rad=sleeve_inside, cutter_rad=5){
	multmatrix(m = [ [cos(angle), sin(angle), 0, 0],
	                [-sin(angle), cos(angle), 0, 0],
	                [xtilt, ytilt, 1, 0],
	                [0, 1, 0,  1]
	              ]) union() {
	   //cylinder(r=cylinder_rad,h=cutter_rad*2,center=false);
		rotate_extrude(twist=90){
			translate([cylinder_rad, cutter_rad, cutter_rad])
				circle(r=cutter_rad);
		}
	}
}

//strude();
module score (steptheta=25, ht=sleeve_height){
	for (theta=[0:steptheta:360-(360%steptheta)]){
	translate([0,0,theta/360*ht - ht/2])
		strude(angle=theta, xtilt=.61, ytilt=.61, cylinder_rad=sleeve_inside, cutter_rad=5);
	}
}

module groove(){
	difference(){
		sleeve(outside_r=sleeve_inside+sleeve_wall,
				inside_r=sleeve_inside,
				ht=sleeve_height);
		score(steptheta=180);
	}
}

$fn=32;
sleeve_height=35;
sleeve_inside=30;
sleeve_wall=5;

// burrower is to be used 6 times, one on each section to make a circle-groove
module burrower (degrees=360/6,
					section_num=0,		// passed in for echo debug
					upndown=0, 			// ie -20, 0, 20 - relative rise / fall
					currentline=20, 		// starting z-level
					radius=30, 				// of can
					quant=40, 				// how many cuts/section
					bulge=4,				// radius of cutter-sphere
					huck=24,				// fine-ness of cutter '$fn'
					){
		echo("currentline = ", currentline, " section = ", section_num);
		for (i=[0:degrees/quant:degrees]){
			rotate([0, 0, i])
			translate([radius, 0, currentline + upndown*sin(i/degrees*90)])
				sphere(r=bulge, center=true, $fn=huck);
		}
}
//currentline=50
s=11;
lvl = 30;
digmap = [[1, lvl, 0], [2, lvl, -s], [3, lvl-s , -s], [4, lvl-s-s ,s], [5, lvl-s, s], [6,lvl,0]];
module digdug (sections=6, instructions=digmap){
	for (shovel=instructions){
	rotate([0,0,(shovel[0]-1)*(360/sections)]){
		if (shovel[0] <= 3){
			burrower(currentline=shovel[1],
						section_num=shovel[0], upndown=shovel[2]);
		}
		if (shovel[0] >= 4){
			burrower(currentline=shovel[1],
						section_num=shovel[0], upndown=shovel[2]);
		}
	}
	}
}
difference(){
	translate([0,0,sleeve_height/2])
		sleeve(outside_r=sleeve_inside+sleeve_wall, inside_r=sleeve_inside, ht=sleeve_height);
	digdug();
}
/*
translate([0,0,sleeve_height/2])
	sleeve(outside_r=sleeve_inside, inside_r=sleeve_inside-2, ht=sleeve_height);
*/
module strude(angle=45, xtilt=1, ytilt=1, cylinder_rad=sleeve_inside, cutter_rad=5){
	multmatrix(m = [ [cos(angle), sin(angle), 0, 0],
	                [-sin(angle), cos(angle), 0, 0],
	                [xtilt, ytilt, 1, 0],
	                [0, 1, 0,  1]
	              ]) union() {
	   //cylinder(r=cylinder_rad,h=cutter_rad*2,center=false);
		rotate_extrude(twist=90){
			translate([cylinder_rad, cutter_rad, cutter_rad])
				circle(r=cutter_rad);
		}
	}
}

//strude();

module sleeve(outside_r=sleeve_inside+sleeve_wall,
				inside_r=sleeve_inside,
				ht=sleeve_height){
	echo("outside_r=",outside_r,
				"inside_r=",inside_r,
				"ht=",ht);
	difference(){
		cylinder(r=outside_r, h=ht, center=true, $fn=128);
		cylinder(r=inside_r, h=ht+.1, center=true, $fn=128);
	}
}

module score (steptheta=25, ht=sleeve_height){
	for (theta=[0:steptheta:360-(360%steptheta)]){
	translate([0,0,theta/360*ht - ht/2])
		strude(angle=theta, xtilt=.61, ytilt=.61, cylinder_rad=sleeve_inside, cutter_rad=5);
	}
}

module groove(){
	difference(){
		sleeve(outside_r=sleeve_inside+sleeve_wall,
				inside_r=sleeve_inside,
				ht=sleeve_height);
		score(steptheta=180);
	}
}


Common extrusions

Common extrusions

O (and U) and T extrusions.

//
// Common extrusions
// Author: Joseph M. Joy FTC 12598 mentor
//
EPSILON = 0.001; // For moving things to properly punch out holes

// Makes a flat (horizontal) "T":
//
// --------------
// |wtXht     --|
// ----\     /---
//      |wbX|
//      |hb |
//      -----
//<xoff>
//
// It could also be an inverted L shape
// if the lower (vertical) bar is wide enough to extend beyond the right
// hand side of the upper (horizontal) bar.
//
// {xoff} is horizontal distance to the start of the bar.
// {r} is the radius of the
// curve shown as diagonals above.
// t is the thickness of the plate - in
// the z direction.
// Origin is the left hand corner
// of the bounding rectangle.
//
module T_channel(wb, hb, wt, ht, xoff, r, t) {
    ow = 10*wb;
    oh = 10*hb;

    difference() {
        cube([wt, hb+ht, t]);
        translate([xoff-ow,hb-oh,-EPSILON]) oblong(ow, oh, r, t+2*EPSILON);
        translate([xoff+wb,hb-oh,-EPSILON]) oblong(ow, oh, r, t+2*EPSILON);
    }
}

// Makes a flat (horizontal) "O":
//
// /-------------\
// |             |
// | /--------\  |
// | |         | |
// | |         | |
// | |         | |
// | \         / |
// |  ---------  |
// \------------/
//
//
// It could also be a U or L
// if the oblong hole extends outside the outer
// boundary.
//
// ({xoff},{yoff} is origin of bounding-rectangle of the oblong hole
// {(wo}, {ho}) is the bounding box of the outer oblong.
// {(wi}, {hi}) is the bounding box of the inner (hole) oblong.
// {r} is the radius of the
// curve shown as diagonals above.
// t is the thickness of the plate - in
// the z direction.
// Origin is the left hand corner
// of the bounding rectangle.
//
module O_channel(wo, ho, wi, hi, xoff, yoff, r, t) {
    difference() {
        oblong(wo, ho, r, t);
        translate([xoff, yoff, -EPSILON]) oblong(wi, hi, r, t+2*EPSILON);
    }
}

// A rectangular prism that fits within {w} x {h} and
// has rounded corners with radius {r} on all 4 sides.
// The actual radius may be reduced so keep the oblong
// viable. {t} is the thickness (in z).
module oblong(w, h, r, t) {
    r = min(r, w/2-EPSILON, h/2-EPSILON);
    translate([r, r, 0])
    minkowski() {
        cube([w-2*r, h-2*r, t]);
        cylinder(2*t, r, r);
    }
}

wb = 5;
hb = 20;
wt = 40;
ht = 30;
t = 2;
r = 5;
ri = 5;
xoff = 10;
//T_channel(wb, hb, wt, ht, xoff, r, t);
O_channel(wt, hb+ht, wb, hb+ht, xoff, xoff, ri, t);
//oblong(11, 40, 5, 2);

error: pathspec 'openscad/common/extrusions.scad' did not match any file(s) known to git


Added experimental cable gland

Added experimental cable gland

//dependency:http://dkprojects.net/openscad-threads/threads.scad
include <.dependencies/threads.scad>

FFF=[false,false,false];FFT=[false,false,true];
FTF=[false,true,false];FTT=[false,true,true];
TFF=[true,false,false];TFT=[true,false,true];
TTF=[true,true,false];TTT=[true,true,true];
module cube2(size, center) {
  translate([
    center[0] ? -size[0]/2 : 0,
    center[1] ? -size[1]/2 : 0,
    center[2] ? -size[2]/2 : 0]) cube(size);
}
module mirror_x() {
  for(a=[0,1])mirror([a,0,0])children();
}
module mirror_y() {
  for(a=[0,1])mirror([0,a,0])children();
}
module mirror_z() {
  for(a=[0,1])mirror([0,0,a])children();
}

module switch_bracket() {
    dist_x=141/2;
    hook_x=34;
    points1=[[dist_x,hook_x],[dist_x,hook_x+47.5],[-dist_x,hook_x],[-dist_x,hook_x+47.5]];
    holes1=[[dist_x,hook_x],[-dist_x,hook_x+36.8],[-dist_x,hook_x],[dist_x,hook_x+47.5]];
    holes2=[[50,0],[0,0],[-50,0]];
    points=concat(points1,holes2);
    module joint(array, i1, i2) {
        hull() {
            translate(array[i1]) cylinder(d=12,h=4);
            translate(array[i2]) cylinder(d=12,h=4);
        }
    }
    difference() {
        union() {
            joint(points, 0, 1);
            joint(points, 1, 3);
            joint(points, 3, 2);
            joint(points, 2, 6);
            joint(points, 6, 5);
            joint(points, 5, 4);
            joint(points, 4, 0);
        }

        for(xy=holes2)translate(xy)cylinder(d=3.2,h=20,center=true,$fn=24);
        for(xy=holes1)translate(xy) {
            cylinder(d=3.2,h=20,center=true,$fn=24);
            translate([0,0,-0.01])cylinder(d1=6.2,d2=3.2,h=3,$fn=24);
        }
    }
}

module realsense_bracket() {
    distance_x=62.25/2;
    difference() {
        union() {
            cube2([72,6,50-6],TFF);
            mirror_x()translate([25,-12.5])cube2([12,13,25-6-2],TFF);

            mirror_x()translate([distance_x,0])cube2([12,35,5],TFF);
            mirror_x()translate([distance_x+6,0])hull() {
                cube2([3,35,5],TFF);
                cube2([3,6,50-6],TFF);
            }
        }
        mirror_x()translate([50/2,0,12.5-6]) {
            rotate([90,0])cylinder(d=3.2,h=100,center=true,$fn=24);
            translate([0,25-12.5+6])rotate([90,0])cylinder(d=6,h=25,$fn=36);
        }
        mirror_x()translate([45/2,0,25+12.5-6]) {
            rotate([90,0])cylinder(d=3.2,h=100,center=true,$fn=24);
        }
        mirror_x() for(a=[10,20,30])translate([distance_x,a])cylinder(d=3.2,h=30,$fn=24,center=true);
    }
}

module cable_gland_25() {
    difference() {
        union() {
            intersection() {
                cylinder(d=32,h=5,$fn=6);
                rotate([0,0,30])cylinder(d=36,h=20,center=true,$fn=6);
            }
            translate([0,0,5])metric_thread(diameter=24, pitch=1.5, length=15);
        }
        cylinder(d=20,h=50,center=true,$fn=72);
        translate([0,0,])cylinder(d1=20,d2=24,h=10,$fn=72);
    }
}
cable_gland_25();
//switch_bracket();
//realsense_bracket();

FFF=[false,false,false];FFT=[false,false,true];
FTF=[false,true,false];FTT=[false,true,true];
TFF=[true,false,false];TFT=[true,false,true];
TTF=[true,true,false];TTT=[true,true,true];
module cube2(size, center) {
  translate([
    center[0] ? -size[0]/2 : 0,
    center[1] ? -size[1]/2 : 0,
    center[2] ? -size[2]/2 : 0]) cube(size);
}
module mirror_x() {
  for(a=[0,1])mirror([a,0,0])children();
}
module mirror_y() {
  for(a=[0,1])mirror([0,a,0])children();
}
module mirror_z() {
  for(a=[0,1])mirror([0,0,a])children();
}

module switch_bracket() {
    dist_x=141/2;
    hook_x=34;
    points1=[[dist_x,hook_x],[dist_x,hook_x+47.5],[-dist_x,hook_x],[-dist_x,hook_x+47.5]];
    holes1=[[dist_x,hook_x],[-dist_x,hook_x+36.8],[-dist_x,hook_x],[dist_x,hook_x+47.5]];
    holes2=[[50,0],[0,0],[-50,0]];
    points=concat(points1,holes2);
    module joint(array, i1, i2) {
        hull() {
            translate(array[i1]) cylinder(d=12,h=4);
            translate(array[i2]) cylinder(d=12,h=4);
        }
    }
    difference() {
        union() {
            joint(points, 0, 1);
            joint(points, 1, 3);
            joint(points, 3, 2);
            joint(points, 2, 6);
            joint(points, 6, 5);
            joint(points, 5, 4);
            joint(points, 4, 0);
        }

        for(xy=holes2)translate(xy)cylinder(d=3.2,h=20,center=true,$fn=24);
        for(xy=holes1)translate(xy) {
            cylinder(d=3.2,h=20,center=true,$fn=24);
            translate([0,0,-0.01])cylinder(d1=6.2,d2=3.2,h=3,$fn=24);
        }
    }
}

module realsense_bracket() {
    distance_x=62.25/2;
    difference() {
        union() {
            cube2([72,6,50-6],TFF);
            mirror_x()translate([25,-12.5])cube2([12,13,25-6-2],TFF);

            mirror_x()translate([distance_x,0])cube2([12,35,5],TFF);
            mirror_x()translate([distance_x+6,0])hull() {
                cube2([3,35,5],TFF);
                cube2([3,6,50-6],TFF);
            }
        }
        mirror_x()translate([50/2,0,12.5-6]) {
            rotate([90,0])cylinder(d=3.2,h=100,center=true,$fn=24);
            translate([0,25-12.5+6])rotate([90,0])cylinder(d=6,h=25,$fn=36);
        }
        mirror_x()translate([45/2,0,25+12.5-6]) {
            rotate([90,0])cylinder(d=3.2,h=100,center=true,$fn=24);
        }
        mirror_x() for(a=[10,20,30])translate([distance_x,a])cylinder(d=3.2,h=30,$fn=24,center=true);
    }
}

switch_bracket();
//realsense_bracket();


/ ‘Impression 3D/2016 - Trocar/trocar-test1.scad’


update scad model

update scad model

$fn = 250;

R = 50;
ballShell = 3;
supportX = 35;
supportY = 8;
supportZ = 60;
mik = 2;
sThickness = 5;
supportBaseHeight = 5;
baseHeight = 31;

module box(Xdim, Ydim, Zdim, thickness, application)
//Creates a box, dimensions are internal
{
	difference() {
		//translate([10,0,-thickness])
		cube([Xdim + thickness, Ydim + thickness, Zdim], center = true);
		translate([0, 0, thickness / 2]) cube([Xdim, Ydim, Zdim], center = true);
		if(application == "servo")
	{
		translate([-Xdim/2,0,-0.5*Zdim])cube([5,Ydim+2*thickness,Zdim/2+thickness], center=true);
		translate([+Xdim/2,0,-0.5*Zdim])cube([5,Ydim+2*thickness,Zdim/2+thickness], center=true);
		translate([+Xdim/2,0,0])cube([thickness/2,0.3*Ydim,Zdim], center=true);
		translate([-Xdim/2,0,0])cube([thickness/2,0.3*Ydim,Zdim], center=true);
	}
	}
}

module support() {
	difference() {
		union() {
			intersection() {
				sphere(R);
				translate([-R, -R+(supportY+sThickness)/2, 0])  cube([500, 25, 200], center = true);
			}

		}
	}

	translate([0, -R+(supportY+sThickness/2), -supportZ/2]) {
		minkowski() {
			box(supportX, supportY, supportZ, sThickness , "none");
			cylinder(r = mik, h = 1);
			//rotate([90,0,0])cylinder(r = mik, h = 1);
		}
	}
}

module base() {
translate([0, 0, -supportZ])
		minkowski() {
			cylinder(r= R+mik, h= supportBaseHeight);
		rotate([90,0,0])cylinder(r = mik, h = 1);
}
}

sphere(R);
support();
mirror([0, 10, 0]) support();
//need to understnad -2 in  2*R-5-mik-2
base();

translate([0, 0, -supportZ-supportBaseHeight-baseHeight])
difference(){
{difference(){
	minkowski() {
cylinder(r= R+6, h = baseHeight);
rotate([90,0,0])cylinder(r = mik, h = 1);
}

translate([0, 0, 5])cylinder(r= (R+mik)/2, h = 10*baseHeight);
}
translate([0, 0, 5])cylinder(r= R+mik+2, h = 10*baseHeight);

}

translate([0, 0, 17-3])	box(24.5, 13, 17, 3,"servo");}

$fn = 250;

R = 50;
ballShell = 3;
supportX = 35;
supportY = 8;
supportZ = 60;
mik = 2;
sThickness = 5;
supportBaseHeight = 5;
baseHeight = 31;

module box(Xdim, Ydim, Zdim, thickness, application)
//Creates a box, dimensions are internal
{
	difference() {
		//translate([10,0,-thickness])
		cube([Xdim + thickness, Ydim + thickness, Zdim], center = true);
		translate([0, 0, thickness / 2]) cube([Xdim, Ydim, Zdim], center = true);
		if(application == "servo")
	{
		translate([-Xdim/2,0,-0.5*Zdim])cube([5,Ydim+2*thickness,Zdim/2+thickness], center=true);
		translate([+Xdim/2,0,-0.5*Zdim])cube([5,Ydim+2*thickness,Zdim/2+thickness], center=true);
		translate([+Xdim/2,0,0])cube([thickness/2,0.3*Ydim,Zdim], center=true);
		translate([-Xdim/2,0,0])cube([thickness/2,0.3*Ydim,Zdim], center=true);
	}
	}
}

module support() {
	difference() {
		union() {
			intersection() {
				sphere(R);
				translate([-R, -R+(supportY+sThickness)/2, 0])  cube([500, 25, 200], center = true);
			}

		}
	}

	translate([0, -R+(supportY+sThickness/2), -supportZ/2]) {
		minkowski() {
			box(supportX, supportY, supportZ, sThickness , "none");
			cylinder(r = mik, h = 1);
			//rotate([90,0,0])cylinder(r = mik, h = 1);
		}
	}
}

module base() {
translate([0, 0, -supportZ])
		minkowski() {
			cylinder(r= R+mik, h= supportBaseHeight);
		rotate([90,0,0])cylinder(r = mik, h = 1);
}
}

sphere(R);
support();
mirror([0, 10, 0]) support();
//need to understnad -2 in  2*R-5-mik-2
base();

translate([0, 0, -supportZ-supportBaseHeight-baseHeight])
{difference(){
	minkowski() {
cylinder(r= R+mik, h = baseHeight);
rotate([90,0,0])cylinder(r = mik, h = 1);
}

translate([0, 0, 5])cylinder(r= (R+mik)/2, h = 10*baseHeight);
}
translate([0, 0, 17-3])	box(24.5, 13, 17, 3,"servo");}


print-ready version

print-ready version

use <support.scad>
use <wallMount.scad>

module bothElements()
{
  translate([0, 55, 0])
    support();
  wallMount();
}

module closedPosition()
{
  wallMount();
  translate([150, 0, 14.5])
    rotate([0, 180, 0])
      support();
}

module openPosition()
{
  wallMount();
  translate([150, -4, 4])
    rotate([-90, 180, 0])
      support();
}

//%closedPosition();
//%openPosition();

bothElements();

use <support.scad>
use <wallMount.scad>

module bothElements()
{
  support();
  wallMount();
}

module closedPosition()
{
  wallMount();
  translate([150, 0, 14.5])
    rotate([0, 180, 0])
      support();
}

module openPosition()
{
  wallMount();
  translate([150, -4, 4])
    rotate([-90, 180, 0])
      support();
}

//%closedPosition();
%openPosition();

//bothElements();