thick = 1.5;
size_x = 35;
size_y = 57.5;
size_z = 6.5 + thick;
size_block = 6;
// Radius of rotary encoder + radius of filament
rad_rot = 13.75;
rot_z = 4;
rad_fil = 1;
mount_x_dist = 7.5;
mount_y_dist = 17.5;
mount_hole = 1.5;

conn_x = 16;
conn_y_dist = 12;
conn_y = size_y - size_block/2 - rad_rot - mount_y_dist - conn_y_dist;

difference()
{
	union()
	{
		difference()
		{
			// Main Block
			cube([size_x, size_y, size_z], center = true);
		
			// Hollow
			translate([0, -(size_block - thick)/2, thick])
			{
				cube([size_x - 2 * thick, size_y - thick - size_block, size_z], center = true);
			}
		
			// Rotary Encoder
			translate([0, size_y/2 - size_block/2 - rad_rot, thick])
			{
				cylinder(size_z, rad_rot, rad_rot, $fn = 360, center = true);
			}
		
			// Filament Hole
			translate([0, size_y/2 - size_block/2, size_z/2 - rot_z])
			{
				rotate([0, 90, 0])
				cylinder(size_x + 1, rad_fil, rad_fil, $fn = 360, center = true);
			}

			// Connector
			translate([0, conn_y/2 - size_y/2 - 0.5, 0])
			{
				cube([conn_x, conn_y + 1, size_z + 1], center = true);
			}
		}

		// Mounts
		for (x = [-1:2:1])
		{
			translate([x * mount_x_dist, size_y/2 - size_block/2 - rad_rot - mount_y_dist, 0])
			{
				cylinder(size_z, mount_hole + 1, mount_hole + 1, $fn = 360, center = true);
			}
		}
	}

	// Mounting Holes
	for (x = [-1:2:1])
	{
		translate([x * mount_x_dist, size_y/2 - size_block/2 - rad_rot - mount_y_dist, 0])
		{
			cylinder(size_z + 1, mount_hole, mount_hole, $fn = 360, center = true);
		}
	}
}