04-card-holder by nicolas heulot

#id {
  use 

cardMarginPer = 0.5;
cardMarginH = 0.5;
cardWidth = 87 + cardMarginPer;
cardLength = 56 + cardMarginPer;
cardHight  = 1 + cardMarginH;

wall = 1.6;

cardHolderW = wall + cardWidth;
cardHolderL = wall + cardLength;
cardHolderH = wall + cardHight;

myText = "CLONE WARS";

holderL = 15;

numSpheres = 8;
diam = 15;
cylinderRad = 1.6;

r = ((cardHolderL)/2 - 12) / 2;

module createSubtractor(h,radius) {
	difference(){ 
		cube([radius+0.1,radius+0.1,h]); 
		cylinder(h=h,r=radius+0.0,$fn = 25); 
	} //+0.1 stops ghost edges
}

module cardZ ( w, l, h )
{	
	r = wall; h = h * 2 + wall;
	difference(){
		cube ( [w, l, h] );
		translate([w-r,l-r]) rotate(0) createSubtractor(h,r); 
		translate([r,l-r]) rotate(90) createSubtractor(h,r);
		translate([r,r]) rotate(180) createSubtractor(h,r);
		translate([w-r,r]) rotate(270) createSubtractor(h,r);
	}
}

module card( w, l, h ) {
	cube ( [w, l, h] );
}

module d1CardStrap ()
{
	difference ()
	{
		translate ( [cardHolderW, 0, 0] )
		{
			card ( holderL, cardHolderL, wall );
			//translate ( [0.6,cardHolderL-9,wall] )
			//	rotate ([0,0,-90])
			//		write(myText,h=6,t=0.6, font="orbitron.dxf");
		}
		//	cutting angles of strap
		translate ( [cardHolderW+holderL, 0, 0] )
		{
			rotate ([0,0,180])
			{
				cylinder ( r=holderL+wall, h=10, $fn=3, center=true );
			}
		}
		translate ( [cardHolderW+holderL, cardHolderL, 0] )
		{
			rotate ([0,0,180])
			{
				cylinder ( r=holderL+wall, h=10, $fn=3, center=true );
			}
		}

		// Strap hole
		translate ( [(cardHolderW+(holderL/2)+1.4), cardHolderL/2-5, -1] )
		{
			card (3, 10, 10);
			translate ([1.5,0,-1])
				cylinder ( r=1.5, h=10, $fn=10 );
			translate ([1.5,10,-1])
				cylinder ( r=1.5, h=10, $fn=10 ); 
			translate ([1.5,5,-5])
				cylinder ( r=3, h=10, , $fn=20 );

		}
	}	
}	

module topStops ()
{
	translate ( [ wall+5, 0, cardHolderH ] )
	{
		union ()
		{
			card ( cardHolderW - 10, 2*wall,  wall );
			// Round the ends
			translate ( [0, wall, 0] )
				cylinder ( r=wall, h=wall, $fn=25 );
			translate ( [cardHolderW - 10, wall, 0] )
				cylinder ( r=wall, h=wall, $fn=25 );
		}
	}
	translate ( [ wall+5, cardHolderL-(2*wall), cardHolderH] )
	{
		union ()
		{
			card ( cardHolderW - 10, 2*wall,  wall );
			// Round the ends
			translate ( [0, wall, 0] )
				cylinder ( r=wall, h=wall, $fn=25 );
			translate ( [cardHolderW-10, wall, 0] )
				cylinder ( r=wall, h=wall, $fn=25 );
		}
	}

}

module d1CardHolder ()
{
	union() {
	difference ()
	{
		difference ()
		{
			union() {
				cardZ (cardHolderW, cardHolderL, cardHolderH);

//				translate ([0, r, (cardHolderH * 2 + wall)/2])
//					cylinder (  h=cardHolderH * 2 + wall, r =r, center=true);

				//difference() {
//				
//					translate ([0, cardHolderL-r, (cardHolderH * 2 + wall)/2])
//						cylinder (  h=cardHolderH * 2 + wall, r =r, center=true);
//
//					translate ([0, cardHolderL-r, (cardHolderH * 2 + wall)/2])
//						cylinder (  h=cardHolderH * 2 + 10, r =r-2, center=true);
//				}

				translate ( [0, 0, (cardHolderH * 2 + wall)/2] )
					rotate ([0,90,0])
						cylinder ( r=(cardHolderH * 2 + wall)/2, h=cardHolderW, $fn=25 );

				translate ( [0, cardHolderL, (cardHolderH * 2 + wall)/2] )
					rotate ([0,90,0])
						cylinder ( r=(cardHolderH * 2 + wall)/2, h=cardHolderW, $fn=25 );

				translate ( [0, cardHolderL, (cardHolderH * 2 + wall)/2] )
						sphere ( r=(cardHolderH * 2 + wall)/2, $fn=25 );
				translate ( [0, 0, (cardHolderH * 2 + wall)/2] )
						sphere ( r=(cardHolderH * 2 + wall)/2, $fn=25 );

				translate ( [0, cardHolderL, (cardHolderH * 2 + wall)/2] )
					rotate ([90,0,0])
						cylinder ( r=(cardHolderH * 2 + wall)/2, h=cardHolderL, $fn=25 );
			}

			translate ([wall,wall,wall])
				card (cardHolderW, cardHolderL-2*wall, wall * 3);

			translate ([cardHolderW/2-12,cardHolderL/2,cardHolderH*2])
				cylinder ( r=12, h=wall, $fn=25 );
			translate ([cardHolderW/2-12,cardHolderL/2-12,cardHolderH*2])
				cube ( 24, wall, wall );
			translate ([cardHolderW/2+12,cardHolderL/2,cardHolderH*2])
				cylinder ( r=12, h=wall, $fn=25 );
		}

//		translate ([0, (cardHolderL)/2, cardHight + cardHolderH])
//		cylinder (  h=10, r = 12, center=true);
	}

	translate ( [10, 14, wall] )
		card ( cardHolderW - 60, 0.5, 0.3 );

	translate ( [10, cardHolderL - 14, wall] )
		card ( cardHolderW - 60, 0.5, 0.3 );

	//top
	translate ( [10, 14, cardHolderH * 2] )
		card ( cardHolderW - 60, 0.5, 0.3 );

	translate ( [10, cardHolderL - 14, cardHolderH*2] )
		card ( cardHolderW - 60, 0.5, 0.3 );

//	// Top overhang
	topStops();
	//d1CardStrap();
	}
}

d1CardHolder();

//translate ([wall, wall, wall])
//{
//	*#card ( 86, 54, 0.8 );
//}

}