summaryrefslogtreecommitdiff
path: root/v1.0/x-bar-clamp-m4.scad
blob: 59044d3ee8087e414448dbed09afb9db198bb685 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
// x-bar-clamp-m4 remake in OpenSCAD
// by tonokip
// License GPL
// May 29, 2010

clamp_vM8=8;
hM4=4;

length=30;
width=14;
height=11;

$fn=20;

module xhole(diameter) rotate(a=90,v=[0,1,0]) zhole(diameter); 
module yhole(diameter) rotate(a=90,v=[1,0,0]) zhole(diameter); 
module zhole(diameter) cylinder(h=200,r=(diameter/2),center=true); 

module xteardrop(diameter,length) rotate(a=-90,v=[0,1,0]) rotate(a=-90,v=[0,0,1]) zteardrop(diameter,length);

module yteardrop(diameter,length) rotate(a=90,v=[1,0,0]) zteardrop(diameter,length);

module zteardrop(diameter,height)
{
	rotate(a=45, v=[0,0,1]) union()
	{
		translate([0,0,-height/2]) cube(size=[diameter/2,diameter/2,height],center=false);
		cylinder(r=diameter/2, h = height,center=true);
	}
}

translate([0,0,height/2])  //Start part at Z=0
difference()
{
	//Main block
	round_cube(length,width,height,radius=1,FN=3);

	//Indent
	translate([0,-width/2+3/2-0.001,0]) round_indent(10,3,11+1,radius=1,FN=3);
	//translate([0,-width/2,0]) cube([10,3*2,11+1],center=true); //Non rounded indent

	// Horizontal M4
	translate([-9.5,0,0]) yteardrop(hM4,100);
	translate([ 9.5,0,0]) yteardrop(hM4,100);

	// Clamp hole
	translate([0,width/2,0]) zhole(clamp_vM8);
}



module round_cube(length,width,height,radius,FN=10)
{
	difference()
	{
		cube([length,width,height],center=true);
		translate([ length/2, width/2,0]) round_corner(radius=radius,height=height+1,FN=FN);
		translate([-length/2, width/2,0]) zrot(90) round_corner(radius=radius,height=height+1,FN=FN);
		translate([-length/2,-width/2,0]) zrot(90*2) round_corner(radius=radius,height=height+1,FN=FN);
		translate([ length/2,-width/2,0]) zrot(90*3) round_corner(radius=radius,height=height+1,FN=FN);
	}
}

module round_indent(length,width,height,radius,FN=10)
{
	difference()
	{
		cube([length,width,height],center=true);
		translate([ length/2, width/2,0]) round_corner(radius=radius,height=height+1,FN=FN);
		translate([-length/2, width/2,0]) zrot(90) round_corner(radius=radius,height=height+1,FN=FN);
	}
	translate([ length/2,-width/2,0]) zrot(90*2) round_corner(radius=radius,height=height,FN=FN);
	translate([-length/2,-width/2,0]) zrot(90*3) round_corner(radius=radius,height=height,FN=FN);
}

module round_corner(radius,height,FN=10)
{
	if(FN > 0)
	{
		difference()
		{
			translate([-radius/2+0.001,-radius/2+0.001,0]) cube([radius,radius,height],center=true);
			translate([-radius,-radius,0]) cylinder(r=radius,h=height+1,center=true,$fn=FN*4);
		}
	}
}

module zrot(deg)
{
	rotate(a=deg,v=[0,0,1]) child(0);
}