first version of box (ugly)

first version of box (ugly)

include <arduino/arduino.scad>

module roundedCase(dimensions, wallThickness=3, mountingHoleDepth = 10, mountingHoleR = 1.25) {
    outherDimensions = [dimensions[0] + wallThickness * 4, dimensions[1] + wallThickness * 4, dimensions[2] + wallThickness];
    boardBase = [wallThickness * 2, wallThickness * 2, wallThickness];

  difference() {
    // case
    roundedCube(dimensions = outherDimensions, cornerRadius = wallThickness);
    translate([wallThickness * 2, wallThickness, wallThickness]) cube(size=[dimensions[0], dimensions[1] + wallThickness * 2, dimensions[2] + 1], center=false);
    translate([wallThickness, wallThickness * 2, wallThickness]) cube(size=[dimensions[0] + wallThickness * 2, dimensions[1], dimensions[2] + 1], center=false);
    // lid mounting holes
    translate([wallThickness, wallThickness, outherDimensions[2] - mountingHoleDepth]) cylinder(r = mountingHoleR, $fn = 32, h = mountingHoleDepth + 1);
    translate([wallThickness, dimensions[1] + wallThickness * 3, outherDimensions[2] - mountingHoleDepth]) cylinder(r = mountingHoleR, $fn = 32, h = mountingHoleDepth + 1);
    translate([dimensions[0] + wallThickness * 3, wallThickness, outherDimensions[2] - mountingHoleDepth]) cylinder(r = mountingHoleR, $fn = 32, h = mountingHoleDepth + 1);
    translate([dimensions[0] + wallThickness * 3, dimensions[1] + wallThickness * 3, outherDimensions[2] - mountingHoleDepth]) cylinder(r = mountingHoleR, $fn = 32, h = mountingHoleDepth + 1);
    // USB and power jack holes
    translate(boardBase) components(boardType = UNO, component = USB, extension = wallThickness * 2 + 1);
    translate(boardBase) components(boardType = UNO, component = POWER, extension = wallThickness * 2 + 1);
  }
  // pillars
  translate(boardBase) standoffs(boardType=UNO, height=height, bottomRadius=1.5, topRadius=1.5, holeRadius=0.75);
}

module roundedCover(dimensions, wallThickness=3, mountingHoleR = 1.25) {
  outherDimensions = [dimensions[0] + wallThickness * 4, dimensions[1] + wallThickness * 4, wallThickness];
  boardBase = [wallThickness * 2, wallThickness * 2, pcbHeight - dimensions[2]];
  mountingHoleDepth = wallThickness+2;

  difference() {
    // cover
    roundedCube(dimensions = outherDimensions, cornerRadius = wallThickness);
    // mounting holes
    translate([wallThickness, wallThickness, outherDimensions[2] - mountingHoleDepth])
      cylinder(r = mountingHoleR, $fn = 32, h = mountingHoleDepth + 1);
    translate([wallThickness, dimensions[1] + wallThickness * 3, outherDimensions[2] - mountingHoleDepth])
      cylinder(r = mountingHoleR, $fn = 32, h = mountingHoleDepth + 1);
    translate([dimensions[0] + wallThickness * 3, wallThickness, outherDimensions[2] - mountingHoleDepth])
      cylinder(r = mountingHoleR, $fn = 32, h = mountingHoleDepth + 1);
    translate([dimensions[0] + wallThickness * 3, dimensions[1] + wallThickness * 3, outherDimensions[2] - mountingHoleDepth])
      cylinder(r = mountingHoleR, $fn = 32, h = mountingHoleDepth + 1);
  }
}

module cylindersCircle(pathRadius, num, r, h) {
  for (i=[1:num])  {
      translate([pathRadius*cos(i*(360/num)),pathRadius*sin(i*(360/num)),0]) cylinder(r=r, h=h, $fn=20);
  }
}

width=53.3;
depth=100;
height=20;
wallThickness=3;

// case
translate([-wallThickness * 2, -wallThickness * 2, -wallThickness]) roundedCase(dimensions = [width, depth, height], wallThickness = wallThickness);

// cover
!translate([-wallThickness * 2, -wallThickness * 2, height]) difference() {
  roundedCover(dimensions = [width, depth, height], wallThickness = wallThickness);
  // button
  translate([28-7/2, 55-7/2, -1])
    cylinder(d=8, h=wallThickness+2);
  // 3 LEDs
  translate([38-22, 69-5/2, -1])
    roundedCube(dimensions = [23, 6, wallThickness+2], cornerRadius = 3);
  // 2 alarm LEDs
  translate([10, 90, -1])
    cylinder(d=5, h=wallThickness+2);
  translate([width  + wallThickness * 4 - 10, 90, -1])
    cylinder(d=5, h=wallThickness+2);
  // speaker
  translate([width /2  + wallThickness * 2, 85 + wallThickness * 2, -1]) {
    cylindersCircle(pathRadius = 12.5, num = 8, r = 0.5, h = wallThickness + 2);
    cylindersCircle(pathRadius = 7.5, num = 8, r = 0.5, h = wallThickness + 2);
    cylindersCircle(pathRadius = 2.5, num = 4, r = 0.5, h = wallThickness + 2);
  }
}

// sample arduino
%arduino();

// sample speaker
%translate([width / 2, 85, height]) rotate([0,180,0]) union() {
    color("DarkGray") {
        cylinder(h=4, d = 30);
        translate([0,0,4]) cylinder(h=4, d = 15);
    }
}

error: pathspec 'LaserAlarm/Hardware/Box.scad' did not match any file(s) known to git


screw mounts are now put deeper + internal box size is 3mm wider, to fit the box with the screw passes as well

use <controller.scad>
use <screw.scad>

module side_bruse_impl()
{
  for(sig = [-1, +1])
    for(i = [1, 2, 3])
      translate([0, i*18, -1])
        rotate([sig*20, 0, 0])
          cube([3, 2, 26]);
}

module junction_box_impl()
{
  wall = 2;
  extra_depth = 5;
  int_size = [73, 70, 24+3+extra_depth];

  difference()
  {
    // main box
    cube(int_size + [2,2,1]*wall);
    translate([1,1,1]*wall)
      cube(int_size);
    // place for cables
    cable_cut_in = [20, 10, wall];
    translate([(int_size[0]+2*wall-cable_cut_in[0])/2, wall, 0])
      cube(cable_cut_in);
  }

  // screw holes
  dist_from_center = 59/2;
  for(dx = [-1, +1])
  {
    translate([(int_size[0]+2*wall)/2+dx*dist_from_center,
               wall+int_size[1]/2,
               wall])
    {
      difference()
      {
        // main screw corridor
        union()
        {
          cylinder(r=10/2, h=int_size[2]-4);
          translate([(12/2/2+2)*(dx-1), -10/2, 0])
            cube([12/2+3, 10, int_size[2]-4]);
        }
        cylinder(r=(3+1)/2, h=int_size[2]-2, $fs=1);
        // nut cut-in
        translate([0, 0, int_size[2]-4-13])
          scale(1.1)
            hull()
            {
              screw();
              translate([0, 9, 0])
                screw();
              translate([0, 9, 7])
                screw();
            }
      }
    }
  }

  // side bruses for better mounting - left/right
  for(dx = [-3, int_size[0]+2*wall])
    translate([dx, 0, 0])
      side_bruse_impl();
  // side bruses for better mounting - up/down
  for(dy = [-3, int_size[0]+2*wall])
    translate([75, dy, 0])
      rotate([0, 0, 90])
        side_bruse_impl();
}

module junction_box()
{
  difference()
  {
    junction_box_impl();
    translate([-10, -10, -5])
      cube([100,100,5]);
  }
}

if(false)
  translate([-7, -6, 10*2])
    controller();

junction_box();

use <controller.scad>
use <screw.scad>

module side_bruse_impl()
{
  for(sig = [-1, +1])
    for(i = [1, 2, 3])
      translate([0, i*18, -1])
        rotate([sig*20, 0, 0])
          cube([3, 2, 26]);
}

module junction_box_impl()
{
  wall = 2;
  extra_depth = 5;
  int_size = [70, 70, 24+3+extra_depth];

  difference()
  {
    // main box
    cube(int_size + [2,2,1]*wall);
    translate([1,1,1]*wall)
      cube(int_size);
    // place for cables
    cable_cut_in = [20, 10, wall];
    translate([(int_size[0]+2*wall-cable_cut_in[0])/2, wall, 0])
      cube(cable_cut_in);
  }

  // screw holes
  dist_from_center = 59/2;
  for(dx = [-1, +1])
  {
    translate([(int_size[0]+2*wall)/2+dx*dist_from_center,
               wall+int_size[1]/2,
               wall])
    {
      difference()
      {
        // main screw corridor
        union()
        {
          cylinder(r=10/2, h=int_size[2]-2);
          translate([12/2/2*(dx-1), -10/2, 0])
            cube([12/2, 10, int_size[2]-2]);
        }
        cylinder(r=(3+1)/2, h=int_size[2]-2, $fs=1);
        // nut cut-in
        translate([0, 0, int_size[2]-2-13])
          scale(1.1)
            hull()
            {
              screw();
              translate([0, 9, 0])
                screw();
              translate([0, 9, 7])
                screw();
            }
      }
    }
  }

  // side bruses for better mounting - left/right
  for(dx = [-3, int_size[0]+2*wall])
    translate([dx, 0, 0])
      side_bruse_impl();
  // side bruses for better mounting - up/down
  for(dy = [-3, int_size[0]+2*wall])
    translate([75, dy, 0])
      rotate([0, 0, 90])
        side_bruse_impl();
}

module junction_box()
{
  difference()
  {
    junction_box_impl();
    translate([-10, -10, -5])
      cube([100,100,5]);
  }
}

if(false)
  translate([-7, -6, 10*2])
    controller();

junction_box();


yaxis/bearing_mount: reduce ziptie dist

yaxis/bearing_mount: reduce ziptie dist

use <thing_libutils/bearing.scad>
include <thing_libutils/attach.scad>
include <config.scad>

yaxis_carriage_bearing_mount_bottom_thick = 3;
yaxis_carriage_bearing_mount_conn_bottom = [[0,0,0], [0,0,1]];
yaxis_carriage_bearing_mount_conn_bearing = [[0,0,yaxis_carriage_bearing_mount_bottom_thick+yaxis_bearing[1]/2], [0,0,1]];

module yaxis_carriage_bearing_mount(show_bearing=false, show_zips=false)
{
    // x distance of holes
    screw_dx=28;
    // y distance of holes
    screw_dy=21;

    carriage_plate_thread=ThreadM4;
    carriage_plate_thread_d=lookup(ThreadSize, carriage_plate_thread);

    width = screw_dx+carriage_plate_thread_d*2;
    depth = max(yaxis_bearing[1], screw_dx+carriage_plate_thread_d*2);
    /*height = yaxis_bearing[1]/2+yaxis_carriage_bearing_mount_bottom_thick;*/
    height = 5+yaxis_carriage_bearing_mount_bottom_thick;

    difference()
    {
        union()
        {
            rcubea ([width, depth, height], align=[0,0,1]);
        }

        translate ([+screw_dx/2, +screw_dy/2, -1]) cylindera(d=carriage_plate_thread_d, h=height+2, align=[0,0,1]);
        translate ([+screw_dx/2, -screw_dy/2, -1]) cylindera(d=carriage_plate_thread_d, h=height+2, align=[0,0,1]);
        translate ([-screw_dx/2, +screw_dy/2, -1]) cylindera(d=carriage_plate_thread_d, h=height+2, align=[0,0,1]);
        translate ([-screw_dx/2, -screw_dy/2, -1]) cylindera(d=carriage_plate_thread_d, h=height+2, align=[0,0,1]);

        translate([0,0,yaxis_bearing[1]/2+yaxis_carriage_bearing_mount_bottom_thick])
        bearing_mount_holes(yaxis_bearing, orient=[0,1,0], ziptie_dist=4, show_zips=show_zips);
    }

    %if(show_bearing)
    {
        translate([0,0,yaxis_bearing[1]/2+yaxis_carriage_bearing_mount_bottom_thick])
        bearing(yaxis_bearing, orient=[0,1,0]);
    }
}

/*c1=[[0,0,0],[0,0,1]];*/
/*attach(c1,yaxis_carriage_bearing_mount_conn_bottom)*/
/*{*/
    /*yaxis_carriage_bearing_mount();*/
    /*#connector(yaxis_carriage_bearing_mount_conn_bottom);*/
/*}*/

use <thing_libutils/bearing.scad>
include <thing_libutils/attach.scad>
include <config.scad>

yaxis_carriage_bearing_mount_bottom_thick = 3;
yaxis_carriage_bearing_mount_conn_bottom = [[0,0,0], [0,0,1]];
yaxis_carriage_bearing_mount_conn_bearing = [[0,0,yaxis_carriage_bearing_mount_bottom_thick+yaxis_bearing[1]/2], [0,0,1]];

module yaxis_carriage_bearing_mount(show_bearing=false, show_zips=false)
{
    // x distance of holes
    screw_dx=28;
    // y distance of holes
    screw_dy=21;

    carriage_plate_thread=ThreadM4;
    carriage_plate_thread_d=lookup(ThreadSize, carriage_plate_thread);

    width = screw_dx+carriage_plate_thread_d*2;
    depth = max(yaxis_bearing[1], screw_dx+carriage_plate_thread_d*2);
    /*height = yaxis_bearing[1]/2+yaxis_carriage_bearing_mount_bottom_thick;*/
    height = 5+yaxis_carriage_bearing_mount_bottom_thick;

    difference()
    {
        union()
        {
            rcubea ([width, depth, height], align=[0,0,1]);
        }

        translate ([+screw_dx/2, +screw_dy/2, -1]) cylindera(d=carriage_plate_thread_d, h=height+2, align=[0,0,1]);
        translate ([+screw_dx/2, -screw_dy/2, -1]) cylindera(d=carriage_plate_thread_d, h=height+2, align=[0,0,1]);
        translate ([-screw_dx/2, +screw_dy/2, -1]) cylindera(d=carriage_plate_thread_d, h=height+2, align=[0,0,1]);
        translate ([-screw_dx/2, -screw_dy/2, -1]) cylindera(d=carriage_plate_thread_d, h=height+2, align=[0,0,1]);

        translate([0,0,yaxis_bearing[1]/2+yaxis_carriage_bearing_mount_bottom_thick])
        bearing_mount_holes(yaxis_bearing, orient=[0,1,0], ziptie_dist=5, show_zips=show_zips);
    }

    %if(show_bearing)
    {
        translate([0,0,yaxis_bearing[1]/2+yaxis_carriage_bearing_mount_bottom_thick])
        bearing(yaxis_bearing, orient=[0,1,0]);
    }
}

/*c1=[[0,0,0],[0,0,1]];*/
/*attach(c1,yaxis_carriage_bearing_mount_conn_bottom)*/
/*{*/
    /*yaxis_carriage_bearing_mount();*/
    /*#connector(yaxis_carriage_bearing_mount_conn_bottom);*/
/*}*/


sphere is a weapon

sphere is a weapon

cardthick= 41.18/134;
echo("one card thickness (mm) =", cardthick);
cardsize=	[88.05, 63.19, cardthick];
cardcorner= 5;
scoopheight=29;
cardcenter=	cardsize/2;
cardedge=	[cardsize[0]-cardcorner, cardsize[1]-cardcorner];
echo("cardedge =",cardedge);

module singlecard(){
	minkowski(){
		square(cardedge, center=true);
		circle(cardcorner/2, $fn=36);
	}
}

module squaremm(size, border=3, ht=scoopheight){
	difference(){
		cube([size, size*cardsize[1]/cardsize[0], ht], center=true);
		cube([size-border, size*cardsize[1]/cardsize[0]-border, ht+.1], center=true);
		echo("measurement frame outside is = ",[size,size]);
		echo("thickness of walls of frame: ", border/2);
		echo("measurement frame inside is = ",[size-border, size-border]);
		echo("height is = ", ht);
	}
}

module tray(floorthk=0, scaledif=.05, sideslope=1.4, scooph=scoopheight){
	translate([0,0,0])
	difference(){
		union(){
			linear_extrude (height=scooph, center=true, convexity=10, twist=0, scale=sideslope){
				scale([1+scaledif,1+scaledif,1])
					singlecard();
			}
			for (i=[-cardedge[0]/2, cardedge[0]/2]){
				translate([i,0,0])
					cube([scooph*(sideslope+scaledif) - scooph*sideslope,
						sideslope*cardsize[1]*(1+scaledif),
						scooph], center=true);
			}
		}
		translate([0,0,floorthk])
			linear_extrude (height=scooph*(1+scaledif)+.01,
							center=true,
							convexity=10,
							twist=0, scale=sideslope){
				scale([1,1,1])
					singlecard();
			}
		//singlecard();
	}
}

translate([0,0,0]) minkowski(){ squaremm(cardsize[0]*1.4+3); sphere(r=2, h=3, $fn=36, center=true);}
tray();

cardthick= 41.18/134;
echo("one card thickness (mm) =", cardthick);
cardsize=	[88.05, 63.19, cardthick];
cardcorner= 5;
scoopheight=29;
cardcenter=	cardsize/2;
cardedge=	[cardsize[0]-cardcorner, cardsize[1]-cardcorner];
echo("cardedge =",cardedge);

module singlecard(){
	minkowski(){
		square(cardedge, center=true);
		circle(cardcorner/2, $fn=36);
	}
}

module squaremm(size, border=3, ht=scoopheight){
	difference(){
		cube([size, size*cardsize[1]/cardsize[0], ht], center=true);
		cube([size-border, size*cardsize[1]/cardsize[0]-border, ht+.1], center=true);
		echo("measurement frame outside is = ",[size,size]);
		echo("thickness of walls of frame: ", border/2);
		echo("measurement frame inside is = ",[size-border, size-border]);
		echo("height is = ", ht);
	}
}

module tray(floorthk=0, scaledif=.05, sideslope=1.4, scooph=scoopheight){
	translate([0,0,0])
	difference(){
		union(){
			linear_extrude (height=scooph, center=true, convexity=10, twist=0, scale=sideslope){
				scale([1+scaledif,1+scaledif,1])
					singlecard();
			}
			for (i=[-cardedge[0]/2, cardedge[0]/2]){
				translate([i,0,0])
					cube([scooph*(sideslope+scaledif) - scooph*sideslope,
						sideslope*cardsize[1]*(1+scaledif),
						scooph], center=true);
			}
		}
		translate([0,0,floorthk])
			linear_extrude (height=scooph*(1+scaledif)+.01,
							center=true,
							convexity=10,
							twist=0, scale=sideslope){
				scale([1,1,1])
					singlecard();
			}
		//singlecard();
	}
}

translate([0,0,-scoopheight/2]) squaremm(cardsize[0]);
tray();


screw moved so that it starts at h=0

screw moved so that it starts at h=0

module screw()
{
  size = 6;
  height=3;
  translate([0, 0, height/2])
    intersection()
    {
      cube([size, size, height], center=true);
      rotate([0,0,45])
        cube([size, size, height], center=true);
    }
}

%screw();

module screw()
{
  intersection()
  {
    size = 6;
    height=3;
    cube([size, size, height], center=true);
    rotate([0,0,45])
      cube([size, size, height], center=true);
  }
}

%screw();


transforms: add spread

transforms: add spread

/*include <../scad-utils/transformations.scad>*/

include <system.scad>
use <misc.scad>

module t(dist)
{
    assert(dist!=U, "t(): dist==U");
    assert(is_list(dist), dist);
    assert(len(dist)==3, "t(): len(dist)!=3");
    translate(dist)
    children();
}

module tx(dist)
{
    assert(dist!=U, "tx(): dist==U");
    assert(is_num(dist), "tx(): dist is not a number");
    translate(X*dist)
    children();
}

module ty(dist)
{
    assert(dist!=U, "ty(): dist==U");
    assert(is_num(dist), "ty(): dist is not a number");
    translate(Y*dist)
    children();
}

module tz(dist)
{
    assert(dist!=U, "tz(): dist==U");
    assert(is_num(dist), "tz(): dist is not a number");
    translate(Z*dist)
    children();
}

module txy(off)
{
    assert(off!=U, "txy(): off==U");
    assert(len(off)==3, "txy(): len(off)!=3");
    tx(off.x)
    ty(off.y)
    children();
}

module txz(off)
{
    assert(off!=U, "txz(): off==U");
    assert(len(off)==3, "txz(): len(off)!=3");
    tx(off.x)
    tz(off.z)
    children();
}

module tyz(off)
{
    assert(off!=U, "tyz(): off==U");
    assert(len(off)==3, "tyz(): len(off)!=3");
    ty(off.y)
    tz(off.z)
    children();
}

module r(a, v)
{
    if(is_list(a))
    {
        assert(is_undef(v), v);
        assert_v3n(a);
        rotate(a)
        children();
    }
    else
    {
        assert(is_num(a), a);
        assert_v3n(v);
        rotate(a,v)
        children();
    }
}

module rx(degrees)
{
    rotate(X*degrees)
    children();
}

module ry(degrees)
{
    rotate(Y*degrees)
    children();
}

module rz(degrees)
{
    rotate(Z*degrees)
    children();
}

module mx(m=true)
{
    assert(is_bool(m));
    mirror(X*m)
    children();
}

module my(m=true)
{
    assert(is_bool(m));
    mirror(Y*m)
    children();
}

module mz(m=true)
{
    assert(is_bool(m));
    mirror(Z*m)
    children();
}

// translate children
module position(positions)
{
    assert(positions!=U, "positions==U");
    for(pos=positions)
    translate(pos)
    children();
}

// translate children
module linup(arr=U)
{
    if($children>0)
    {
        for (i = [0 : $children-1])
        translate(arr[i]) children(i);
    }
}

module stack(dist=10, distances=U, axis=Z)
{
    if($children>0)
    {
        if(dist == U && distances != U)
        {
            for (i = [0:len(distances)-1])
            {
                offset = v_sum(distances,i);
                translate(axis*offset)
                    child(i);
            }
        }
        else if(dist != U && distances == U)
        {
            for (i = [0 : $children-1])
                translate(axis*(dist*i))
                    children(i);
        }
    }
}

module spread(axis=N, dist=0, iter=[-1,1])
{
    assert(is_list(axis));
    assert(is_num(dist));
    assert(is_list(iter));

    for(i=iter)
    translate(i*axis*dist)
    children();
}

module spreadx(dist=0)
{
    spread(axis=X,dist=dist)
    children();
}

module spready(dist=0)
{
    spread(axis=Y,dist=dist)
    children();
}

module spreadz(dist=0)
{
    spread(axis=Z,dist=dist)
    children();
}

module orient(axis=U, axis_ref=U, roll=0, extra_roll, extra_roll_orient)
{
    rotate(extra_roll_orient==U||extra_roll==U?0:extra_roll*extra_roll_orient)

    // orient to reference axis
    /*rotate(axis_ref==U?0:_orient_angles(axis_ref))*/
    /*multmatrix(axis_ref==U?0:v_rotate(90, axis_ref))*/
    rotate(axis_ref==U?0:_orient_angles(axis_ref))

    // roll around orient axis
    rotate(axis==U?0:roll*axis)

    // orient to axis
    /*multmatrix(axis==U?0:v_rotate(90, axis))*/
    rotate(axis==U?0:_orient_angles(axis))
    children();
}

module orient_(axis=U, axis_ref=U, roll=0, extra_roll, extra_roll_orient)
{
    rotate(extra_roll_orient==U||extra_roll==U?0:extra_roll*extra_roll_orient)

    // orient to reference axis
    multmatrix(axis_ref==U?0:v_rotate(90, axis_ref))

    // roll around orient axis
    rotate(axis==U?0:roll*axis)

    // orient to axis
    multmatrix(axis_ref==U?0:v_rotate(90, axis))
    children();
}

function _orient_bounds(orient, size) =
    (_rotate_matrix(_orient_angles(orient)) * [size.x,size.y,size.z,1]);

function _orient_t(orient, align, size) =
    let(bounds = _orient_bounds(orient, size))
    (hadamard(align, [abs(bounds.x/2),abs(bounds.y/2),abs(bounds.z/2)]));

module size_align(size=[10,10,10], extra_size=N, align=N, extra_align=N, orient=Z, orient_ref=Z, roll=0, extra_roll, extra_roll_orient)
{
    assert(orient != N);
    assert_v3n(align);
    assert_v3n(orient);
    assert_v3n(size);
    t = orient==U?N:_orient_t(orient, align, size);
    extra_t = (orient==U||extra_size==U||extra_size==[U,U,U]||extra_size==[0,0,0]||extra_align==U) ?
        N : _orient_t(orient, extra_align, extra_size);
    assert_v3n(t);
    assert_v3n(extra_t);
    /*assert(extra_t[0] < 0 && extra_t[0] == 0 && extra_t[0] > 0 || extra_t[);*/
    translate(t+extra_t)
    {
        orient(axis=orient, axis_ref=orient_ref, roll=roll, extra_roll=extra_roll, extra_roll_orient=extra_roll_orient)
        {
            children();
        }
    }
}

module hull_pairwise()
{
    for (i= [1:1:$children-1])
    {
        hull()
        {
            children(i-1);
            children(i);
        }
    }
}

module proj_extrude_axis(axis=Z, h=1, offset=0, cut=false)
{
    translate(-offset*axis)
    hull()
    {
        orient_(axis=axis, axis_ref=Z)
        {
            linear_extrude(h, center=false)
            projection(cut=cut)
            orient_(axis=Z, axis_ref=axis)
            translate(offset*axis)
            children();

            orient_(axis=Z, axis_ref=axis)
            translate(offset*axis)
            children();
        }
    }
}

module all_axes()
{
    for($axis=concat(AXES,-AXES))
    {
        $color = v_abs($axis*.3 + v_clamp(v_sign($axis),0,1)*.7);
        children();
    }
}

// test proj_extruder_axis
if(false)
{
    all_axes()
    color($color)
    translate(5*$axis)
    proj_extrude_axis(axis=$axis)
    translate(20*$axis)
    sphere(d=10);
}

if(false)
{
    translate(Y*10)
    proj_extrude_axis(axis=Y, offset=10)
    {
        sphere(d=10);
    }
}

module proj_extrude_axis_part(axis=Z, h=1, offset=0, cut=false)
{
    translate(-offset*axis)
    {
        orient_(axis=axis, axis_ref=Z)
        {
            hull()
            linear_extrude(offset, center=false)
            projection(cut=cut)
            orient_(axis=Z, axis_ref=axis)
            translate(offset*axis)
            children();

            orient_(axis=Z, axis_ref=axis)
            translate(offset*axis)
            children();
        }
    }
}

if(false)
{
    tz(10)
    proj_extrude_axis_part(axis=Z, offset=10)
    {
        x = 15;
        cylinder(d=5, h=20);

        tx(x)
        cylinder(d=5, h=20);
    }
}

// translate by pos, with extra (depending on the sign of pos)
// an "explode" function
module te(pos, extra=[0,0,0])
{
    assert(len(pos) == 3);
    assert(len(extra) == 3);

    t(pos + v_mul(extra , v_sign(pos)))
    children();
}

/*include <../scad-utils/transformations.scad>*/

include <system.scad>
use <misc.scad>

module t(dist)
{
    assert(dist!=U, "t(): dist==U");
    assert(is_list(dist), dist);
    assert(len(dist)==3, "t(): len(dist)!=3");
    translate(dist)
    children();
}

module tx(dist)
{
    assert(dist!=U, "tx(): dist==U");
    assert(is_num(dist), "tx(): dist is not a number");
    translate(X*dist)
    children();
}

module ty(dist)
{
    assert(dist!=U, "ty(): dist==U");
    assert(is_num(dist), "ty(): dist is not a number");
    translate(Y*dist)
    children();
}

module tz(dist)
{
    assert(dist!=U, "tz(): dist==U");
    assert(is_num(dist), "tz(): dist is not a number");
    translate(Z*dist)
    children();
}

module txy(off)
{
    assert(off!=U, "txy(): off==U");
    assert(len(off)==3, "txy(): len(off)!=3");
    tx(off.x)
    ty(off.y)
    children();
}

module txz(off)
{
    assert(off!=U, "txz(): off==U");
    assert(len(off)==3, "txz(): len(off)!=3");
    tx(off.x)
    tz(off.z)
    children();
}

module tyz(off)
{
    assert(off!=U, "tyz(): off==U");
    assert(len(off)==3, "tyz(): len(off)!=3");
    ty(off.y)
    tz(off.z)
    children();
}

module r(a, v)
{
    if(is_list(a))
    {
        assert(is_undef(v), v);
        assert_v3n(a);
        rotate(a)
        children();
    }
    else
    {
        assert(is_num(a), a);
        assert_v3n(v);
        rotate(a,v)
        children();
    }
}

module rx(degrees)
{
    rotate(X*degrees)
    children();
}

module ry(degrees)
{
    rotate(Y*degrees)
    children();
}

module rz(degrees)
{
    rotate(Z*degrees)
    children();
}

module mx(m=true)
{
    assert(is_bool(m));
    mirror(X*m)
    children();
}

module my(m=true)
{
    assert(is_bool(m));
    mirror(Y*m)
    children();
}

module mz(m=true)
{
    assert(is_bool(m));
    mirror(Z*m)
    children();
}

// translate children
module position(positions)
{
    assert(positions!=U, "positions==U");
    for(pos=positions)
    translate(pos)
    children();
}

// translate children
module linup(arr=U)
{
    if($children>0)
    {
        for (i = [0 : $children-1])
        translate(arr[i]) children(i);
    }
}

module stack(dist=10, distances=U, axis=Z)
{
    if($children>0)
    {
        if(dist == U && distances != U)
        {
            for (i = [0:len(distances)-1])
            {
                offset = v_sum(distances,i);
                translate(axis*offset)
                    child(i);
            }
        }
        else if(dist != U && distances == U)
        {
            for (i = [0 : $children-1])
                translate(axis*(dist*i))
                    children(i);
        }
    }
}

module orient(axis=U, axis_ref=U, roll=0, extra_roll, extra_roll_orient)
{
    rotate(extra_roll_orient==U||extra_roll==U?0:extra_roll*extra_roll_orient)

    // orient to reference axis
    /*rotate(axis_ref==U?0:_orient_angles(axis_ref))*/
    /*multmatrix(axis_ref==U?0:v_rotate(90, axis_ref))*/
    rotate(axis_ref==U?0:_orient_angles(axis_ref))

    // roll around orient axis
    rotate(axis==U?0:roll*axis)

    // orient to axis
    /*multmatrix(axis==U?0:v_rotate(90, axis))*/
    rotate(axis==U?0:_orient_angles(axis))
    children();
}

module orient_(axis=U, axis_ref=U, roll=0, extra_roll, extra_roll_orient)
{
    rotate(extra_roll_orient==U||extra_roll==U?0:extra_roll*extra_roll_orient)

    // orient to reference axis
    multmatrix(axis_ref==U?0:v_rotate(90, axis_ref))

    // roll around orient axis
    rotate(axis==U?0:roll*axis)

    // orient to axis
    multmatrix(axis_ref==U?0:v_rotate(90, axis))
    children();
}

function _orient_bounds(orient, size) =
    (_rotate_matrix(_orient_angles(orient)) * [size.x,size.y,size.z,1]);

function _orient_t(orient, align, size) =
    let(bounds = _orient_bounds(orient, size))
    (hadamard(align, [abs(bounds.x/2),abs(bounds.y/2),abs(bounds.z/2)]));

module size_align(size=[10,10,10], extra_size=N, align=N, extra_align=N, orient=Z, orient_ref=Z, roll=0, extra_roll, extra_roll_orient)
{
    assert(orient != N);
    assert_v3n(align);
    assert_v3n(orient);
    assert_v3n(size);
    t = orient==U?N:_orient_t(orient, align, size);
    extra_t = (orient==U||extra_size==U||extra_size==[U,U,U]||extra_size==[0,0,0]||extra_align==U) ?
        N : _orient_t(orient, extra_align, extra_size);
    assert_v3n(t);
    assert_v3n(extra_t);
    /*assert(extra_t[0] < 0 && extra_t[0] == 0 && extra_t[0] > 0 || extra_t[);*/
    translate(t+extra_t)
    {
        orient(axis=orient, axis_ref=orient_ref, roll=roll, extra_roll=extra_roll, extra_roll_orient=extra_roll_orient)
        {
            children();
        }
    }
}

module hull_pairwise()
{
    for (i= [1:1:$children-1])
    {
        hull()
        {
            children(i-1);
            children(i);
        }
    }
}

module proj_extrude_axis(axis=Z, h=1, offset=0, cut=false)
{
    translate(-offset*axis)
    hull()
    {
        orient_(axis=axis, axis_ref=Z)
        {
            linear_extrude(h, center=false)
            projection(cut=cut)
            orient_(axis=Z, axis_ref=axis)
            translate(offset*axis)
            children();

            orient_(axis=Z, axis_ref=axis)
            translate(offset*axis)
            children();
        }
    }
}

module all_axes()
{
    for($axis=concat(AXES,-AXES))
    {
        $color = v_abs($axis*.3 + v_clamp(v_sign($axis),0,1)*.7);
        children();
    }
}

// test proj_extruder_axis
if(false)
{
    all_axes()
    color($color)
    translate(5*$axis)
    proj_extrude_axis(axis=$axis)
    translate(20*$axis)
    sphere(d=10);
}

if(false)
{
    translate(Y*10)
    proj_extrude_axis(axis=Y, offset=10)
    {
        sphere(d=10);
    }
}

module proj_extrude_axis_part(axis=Z, h=1, offset=0, cut=false)
{
    translate(-offset*axis)
    {
        orient_(axis=axis, axis_ref=Z)
        {
            hull()
            linear_extrude(offset, center=false)
            projection(cut=cut)
            orient_(axis=Z, axis_ref=axis)
            translate(offset*axis)
            children();

            orient_(axis=Z, axis_ref=axis)
            translate(offset*axis)
            children();
        }
    }
}

if(false)
{
    tz(10)
    proj_extrude_axis_part(axis=Z, offset=10)
    {
        x = 15;
        cylinder(d=5, h=20);

        tx(x)
        cylinder(d=5, h=20);
    }
}

// translate by pos, with extra (depending on the sign of pos)
// an "explode" function
module te(pos, extra=[0,0,0])
{
    assert(len(pos) == 3);
    assert(len(extra) == 3);

    t(pos + v_mul(extra , v_sign(pos)))
    children();
}


Fisrt version of a 3D model

Fisrt version of a 3D model

yaw = 90;
roll = 0;
pitch=0;
lineLength=20;
bearing =90;
elevation = 45;
useNED=-1;
 rotate(a=bearing, v=[0,0,1*useNED]) rotate(a=elevation, v=[0,1*useNED,0])  translate(v=[lineLength,0,0])  rotate(a=-1*elevation, v=[0,1*useNED,0]) rotate(a=-1*bearing, v=[0,0,1*useNED])   rotate(a=yaw ,v=[0,0,1*useNED]) rotate(a=pitch, v=[0,1*useNED,0]) rotate(a=roll, v=[1,0,0]) cube(size=[1,3,0.1]);

error: pathspec 'kite.scad' did not match any file(s) known to git


add the top end

add the top end

use <../../../basics/rounded-edges/doughnuts/doughnuts.scad>;

use <../../../basics/rounded-edges/rounded-pyramid/rounded-pyramid.scad>;

use <../../../shapes/geometry/arc/extruded/extruded-arc.scad>;

module halfCirclePhoneStand(height = 19.125,
                            minkowskiSphereRadius = 0.5,
                            arcRadius = 36,
                            arcRadiusExtension = 1.5)
{
    halfCirclePhoneStand_cradle(height = height,
                                minkowskiSphereRadius = minkowskiSphereRadius,
                                radius = arcRadius,
                                radiusExtension = arcRadiusExtension);

    halfCirclePhoneStand_stand(height = height,
                               minkowskiSphereRadius = minkowskiSphereRadius);
}

// sub-modules and functions follow

function halfCirclePhoneStand_cradle_cutout_zLength() = 4.2;

function halfCirclePhoneStand_cradle_cutout_zTranslate(minkowskiSphereRadius,
                                                        bedHeight,
                                                        zLength) = minkowskiSphereRadius + (bedHeight / 2.0) - (zLength / 2.0);

module halfCirclePhoneStand_cradle(height,
                                   minkowskiSphereRadius,
                                   radius,
                                   radiusExtension)
{
    xTranslate = 30;
    yTranslate = 32.7;

    difference()
    {
        halfCirclePhoneStand_cradle_bed(height = height,
                                           minkowskiSphereRadius = minkowskiSphereRadius,
                                           radius = radius,
                                           radiusExtension = radiusExtension,
                                           xTranslate = xTranslate,
                                           yTranslate = yTranslate);

        halfCirclePhoneStand_cradle_cutout(bedHeight = height,
                                        minkowskiSphereRadius = minkowskiSphereRadius,
                                        radius = radius,
                                        radiusExtension = radiusExtension,
                                        bed_xTranslate = xTranslate,
                                        bed_yTranslate = yTranslate);
    }

    halfCirclePhoneStand_cradle_ends(height = height,
                                     minkowskiSphereRadius = minkowskiSphereRadius);
}

module halfCirclePhoneStand_cradle_bed(height,
                                       minkowskiSphereRadius,
                                       radius,
                                       radiusExtension,
                                       xTranslate,
                                       yTranslate)
{
    zTranslate = minkowskiSphereRadius;
    color("magenta")
    translate([xTranslate, yTranslate, zTranslate])
    rotate([0, 0, 213])
    roundedRectangularArc(angle = 150,
                          height = height,
                          minkowskiRadius = minkowskiSphereRadius,
                          radius = radius,
                          radiusExtension = radiusExtension);
}

module halfCirclePhoneStand_cradle_cutout(bedHeight,
                                          minkowskiSphereRadius,
                                          radius,
                                          radiusExtension,
                                          bed_xTranslate,
                                          bed_yTranslate)
{
    zLength = halfCirclePhoneStand_cradle_cutout_zLength();

    cutoutRadiusExtension = radiusExtension + 3;

    xTranslate = bed_xTranslate + 0.2;
    yTranslate = bed_yTranslate + 0.2;
    zTranslate = halfCirclePhoneStand_cradle_cutout_zTranslate(minkowskiSphereRadius = minkowskiSphereRadius,
                                                                bedHeight = bedHeight,
                                                                zLength = zLength);

    color("DarkTurquoise")
    translate([xTranslate, yTranslate, zTranslate])
    rotate([0, 0, 227])
    roundedRectangularArc(angle = 37,
                          height = zLength,
                          minkowskiRadius = minkowskiSphereRadius,
                          radius = radius,
                          radiusExtension = cutoutRadiusExtension);
}

module halfCirclePhoneStand_cradle_ends(height,
                                        minkowskiSphereRadius)
{
    halfCirclePhoneStand_cradle_ends_top(height = height,
                                            minkowskiSphereRadius = minkowskiSphereRadius);

    halfCirclePhoneStand_cradle_ends_bottom(height = height,
                                            minkowskiSphereRadius = minkowskiSphereRadius);
}

module halfCirclePhoneStand_cradle_ends_bottom(height,
                                        minkowskiSphereRadius)
{
    xTranslate = 2.8;
    yTranslate = 56.35;
    zTranslate = minkowskiSphereRadius;

    // bottom end
    color("PaleTurquoise")
    translate([xTranslate, yTranslate, zTranslate])
    halfCirclePhoneStand_cradle_ends_cylinder(height = height,
                                              minkowskiSphereRadius = minkowskiSphereRadius);
}

module halfCirclePhoneStand_cradle_ends_top(height,
                                        minkowskiSphereRadius)
{
    xTranslate = 40.3;
    yTranslate = -2.5;
    zTranslate = minkowskiSphereRadius;

    // bottom end
    color("PaleTurquoise")
    translate([xTranslate, yTranslate, zTranslate])
    halfCirclePhoneStand_cradle_ends_cylinder(height = height,
                                              minkowskiSphereRadius = minkowskiSphereRadius);
}

module halfCirclePhoneStand_cradle_ends_cylinder(height,
                                        minkowskiSphereRadius)
{
    roundedPyramid(h = height,
                   cornerRadius = minkowskiSphereRadius,
                   cylinderFn = 20,
                   r1 = 2.57,
                   r2 = 2.57,
                   sides = 30);
}

module halfCirclePhoneStand_stand(height,
                                  minkowskiSphereRadius)
{
    halfCirclePhoneStand_stand_top(height = height,
                                   minkowskiSphereRadius = minkowskiSphereRadius);

    halfCirclePhoneStand_stand_connectorBar(bedHeight = height,
                                            minkowskiSphereRadius = minkowskiSphereRadius);

    halfCirclePhoneStand_stand_base(height = height,
                                    minkowskiSphereRadius = minkowskiSphereRadius);
}

module halfCirclePhoneStand_stand_base(height,
                                       minkowskiSphereRadius)
{
    color("green")
    translate([0, 0, minkowskiSphereRadius])
    roundDoughnut(height = height,
                innerRadius = 4.9,      // 4.9
                outerRadius = 5.59,     // 5.59
                minkowskiSphereRadius = minkowskiSphereRadius);
}

module halfCirclePhoneStand_stand_connectorBar(minkowskiSphereRadius, bedHeight)
{
    xLength = 5;
    yLength = 3;
    zLength = halfCirclePhoneStand_cradle_cutout_zLength() + minkowskiSphereRadius;

    xTranslate = 5;
    yTranslate = 5;
    zTranslate = halfCirclePhoneStand_cradle_cutout_zTranslate(minkowskiSphereRadius = minkowskiSphereRadius,
                                                                bedHeight = bedHeight,
                                                                zLength = zLength)
                    + (zLength / 2.0);

    color("blue")
    translate([xTranslate, yTranslate, zTranslate])
    rotate([0, 0, 45])
    cube([xLength, yLength, zLength], center = true);
}

module halfCirclePhoneStand_stand_top(height,
                                      minkowskiSphereRadius)
{
    xTranslate = 8.105;  // 8.05     // 8.1
    yTranslate = 8.85;  // 8.85     // 8.9

    color("green")
    translate([xTranslate, yTranslate, minkowskiSphereRadius])
    roundDoughnut(height = height,
                innerRadius = 1.9,  // 2.0
                outerRadius = 2.6,  // 2.6
                minkowskiSphereRadius = minkowskiSphereRadius);
}

use <../../../basics/rounded-edges/doughnuts/doughnuts.scad>;

use <../../../basics/rounded-edges/rounded-pyramid/rounded-pyramid.scad>;

use <../../../shapes/geometry/arc/extruded/extruded-arc.scad>;

module halfCirclePhoneStand(height = 19.125,
                            minkowskiSphereRadius = 0.5,
                            arcRadius = 36,
                            arcRadiusExtension = 1.5)
{
    halfCirclePhoneStand_cradle(height = height,
                                minkowskiSphereRadius = minkowskiSphereRadius,
                                radius = arcRadius,
                                radiusExtension = arcRadiusExtension);

    halfCirclePhoneStand_stand(height = height,
                               minkowskiSphereRadius = minkowskiSphereRadius);
}

// sub-modules and functions follow

function halfCirclePhoneStand_cradle_cutout_zLength() = 4.2;

function halfCirclePhoneStand_cradle_cutout_zTranslate(minkowskiSphereRadius,
                                                        bedHeight,
                                                        zLength) = minkowskiSphereRadius + (bedHeight / 2.0) - (zLength / 2.0);

module halfCirclePhoneStand_cradle(height,
                                   minkowskiSphereRadius,
                                   radius,
                                   radiusExtension)
{
    xTranslate = 30;
    yTranslate = 32.7;

    difference()
    {
        halfCirclePhoneStand_cradle_bed(height = height,
                                           minkowskiSphereRadius = minkowskiSphereRadius,
                                           radius = radius,
                                           radiusExtension = radiusExtension,
                                           xTranslate = xTranslate,
                                           yTranslate = yTranslate);

        halfCirclePhoneStand_cradle_cutout(bedHeight = height,
                                        minkowskiSphereRadius = minkowskiSphereRadius,
                                        radius = radius,
                                        radiusExtension = radiusExtension,
                                        bed_xTranslate = xTranslate,
                                        bed_yTranslate = yTranslate);
    }

    halfCirclePhoneStand_cradle_ends(height = height,
                                     minkowskiSphereRadius = minkowskiSphereRadius);
}

module halfCirclePhoneStand_cradle_bed(height,
                                       minkowskiSphereRadius,
                                       radius,
                                       radiusExtension,
                                       xTranslate,
                                       yTranslate)
{
    zTranslate = minkowskiSphereRadius;
    color("magenta")
    translate([xTranslate, yTranslate, zTranslate])
    rotate([0, 0, 213])
    roundedRectangularArc(angle = 150,
                          height = height,
                          minkowskiRadius = minkowskiSphereRadius,
                          radius = radius,
                          radiusExtension = radiusExtension);
}

module halfCirclePhoneStand_cradle_cutout(bedHeight,
                                          minkowskiSphereRadius,
                                          radius,
                                          radiusExtension,
                                          bed_xTranslate,
                                          bed_yTranslate)
{
    zLength = halfCirclePhoneStand_cradle_cutout_zLength();

    cutoutRadiusExtension = radiusExtension + 3;

    xTranslate = bed_xTranslate + 0.2;
    yTranslate = bed_yTranslate + 0.2;
    zTranslate = halfCirclePhoneStand_cradle_cutout_zTranslate(minkowskiSphereRadius = minkowskiSphereRadius,
                                                                bedHeight = bedHeight,
                                                                zLength = zLength);

    color("DarkTurquoise")
    translate([xTranslate, yTranslate, zTranslate])
    rotate([0, 0, 227])
    roundedRectangularArc(angle = 37,
                          height = zLength,
                          minkowskiRadius = minkowskiSphereRadius,
                          radius = radius,
                          radiusExtension = cutoutRadiusExtension);
}

module halfCirclePhoneStand_cradle_ends(height,
                                        minkowskiSphereRadius)
{
    xTranslate = 40.3;
    yTranslate = -2.5;
    zTranslate = minkowskiSphereRadius;

    // bottom end
    color("PaleTurquoise")
    translate([xTranslate, yTranslate, zTranslate])
    roundedPyramid(h = height,
                   cornerRadius = minkowskiSphereRadius,
                   cylinderFn = 20,
                   r1 = 2.57,
                   r2 = 2.57,
                   sides = 30);
}

module halfCirclePhoneStand_stand(height,
                                  minkowskiSphereRadius)
{
    halfCirclePhoneStand_stand_top(height = height,
                                   minkowskiSphereRadius = minkowskiSphereRadius);

    halfCirclePhoneStand_stand_connectorBar(bedHeight = height,
                                            minkowskiSphereRadius = minkowskiSphereRadius);

    halfCirclePhoneStand_stand_base(height = height,
                                    minkowskiSphereRadius = minkowskiSphereRadius);
}

module halfCirclePhoneStand_stand_base(height,
                                       minkowskiSphereRadius)
{
    color("green")
    translate([0, 0, minkowskiSphereRadius])
    roundDoughnut(height = height,
                innerRadius = 4.9,      // 4.9
                outerRadius = 5.59,     // 5.59
                minkowskiSphereRadius = minkowskiSphereRadius);
}

module halfCirclePhoneStand_stand_connectorBar(minkowskiSphereRadius, bedHeight)
{
    xLength = 5;
    yLength = 3;
    zLength = halfCirclePhoneStand_cradle_cutout_zLength() + minkowskiSphereRadius;

    xTranslate = 5;
    yTranslate = 5;
    zTranslate = halfCirclePhoneStand_cradle_cutout_zTranslate(minkowskiSphereRadius = minkowskiSphereRadius,
                                                                bedHeight = bedHeight,
                                                                zLength = zLength)
                    + (zLength / 2.0);

    color("blue")
    translate([xTranslate, yTranslate, zTranslate])
    rotate([0, 0, 45])
    cube([xLength, yLength, zLength], center = true);
}

module halfCirclePhoneStand_stand_top(height,
                                      minkowskiSphereRadius)
{
    xTranslate = 8.105;  // 8.05     // 8.1
    yTranslate = 8.85;  // 8.85     // 8.9

    color("green")
    translate([xTranslate, yTranslate, minkowskiSphereRadius])
    roundDoughnut(height = height,
                innerRadius = 1.9,  // 2.0
                outerRadius = 2.6,  // 2.6
                minkowskiSphereRadius = minkowskiSphereRadius);
}


main: fix x belts

main: fix x belts

include <config.scad>

include <thing_libutils/system.scad>
include <thing_libutils/units.scad>
include <thing_libutils/materials.scad>

use <thing_libutils/screws.scad>
use <thing_libutils/shapes.scad>;
use <thing_libutils/misc.scad>;
use <thing_libutils/transforms.scad>;
use <thing_libutils/attach.scad>;
use <thing_libutils/linear-extrusion.scad>;
use <thing_libutils/timing-belts.scad>;

use <x-end.scad>
include <x-end.h>

use <x-carriage.scad>
include <x-carriage.h>

use <y-motor-mount.scad>
include <y-motor-mount.h>

use <y-carriage-bearing-mount.scad>
include <y-carriage-bearing-mount.h>

use <y-carriage-belt-clamp.scad>
include <y-carriage-belt-clamp.h>

use <y-idler.scad>
include <y-idler.h>

use <z-motor-mount.scad>
include <z-motor-mount.h>

use <gantry-upper-connector.scad>
use <gantry-lower-connector.scad>

use <rod-clamps.scad>
include <rod-clamps.h>

/*use <psu.scad>*/
/*include <psu.h>*/

/*use <lcd2004.scad>*/
/*use <power-panel-iec320.scad>*/

// x carriage
axis_range_x_ = main_width/2 + zmotor_mount_rod_offset_x - xaxis_end_width(true) - x_carriage_w/2 - .5*mm;
axis_range_x = [-1,1] *  axis_range_x_;
axis_printrange_x = [-1/2, 1/2] * printbed_size[0];
axis_x_parked = [false, true];

axis_range_y=[0*mm,200*mm];
axis_pos_y = axis_range_y[0];
axis_range_z=[90*mm,353*mm];
axis_pos_z = axis_range_z[0];

echo(str("Axis range X: " , axis_range_x[0], " ", axis_range_x[1]," mm"));
echo(str("Axis range Y: " , axis_range_y[0], " ", axis_range_y[1]," mm"));
echo(str("Axis range Z: " , axis_range_z[0], " ", axis_range_z[1]," mm"));

echo(str("Build area Z: " , axis_range_z[1]-axis_range_z[0] , " mm"));

home_offset_x0 = axis_range_x[0] - axis_printrange_x[0] + v_x(extruder_filapath_offset)[0];
echo(str("Home offset X0: " , home_offset_x0));
echo(str("Tool offset X: " , axis_range_x_+x_carriage_w/2));

module x_axis()
{
    // x axis
    translate([0,0,axis_pos_z])
    {
        zrod_offset = zmotor_mount_rod_offset_x;
        for(z=xaxis_beltpath_z_offsets)
        tz(z)
        ty(xaxis_zaxis_distance_y)
        tx(-sign(z)*(-main_width/2-zrod_offset+xaxis_end_motor_offset[0]))
        rotate(90*X)
        belt_path(
            len=main_width+xaxis_end_motor_offset[0],
            belt_width=xaxis_belt_width,
            belt=xaxis_belt,
            pulley_d=xaxis_pulley_inner_d,
            orient=X, align=-sign(z)*X);

        for(x=[0:len(axis_range_x)-1])
        {
            /*#cubea(size=[x_carriage_w,10,100]);*/

            pos = axis_x_parked[x] ? axis_range_x[x] : -axis_printrange_x[x];

            translate([pos,0,0])
            mirror([x==0?0:1,0,0])
            attach(xaxis_carriage_conn, [[0,-xaxis_zaxis_distance_y,0],N])
            {
                x_carriage_withmounts(show_vitamins=true, beltpath_offset=x==0?-1:1);

                x_carriage_extruder(show_vitamins=true, with_sensormount=x==0);
            }
        }

        // x smooth rods
        for(z=[-1,1])
        translate([xaxis_rod_offset_x,xaxis_zaxis_distance_y,z*(xaxis_rod_distance/2)])
        material(Mat_Chrome)
        cylindera(h=xaxis_rod_l,d=xaxis_rod_d+.1, orient=X);

        for(x=[-1,1])
        translate([x*(main_width/2), 0, 0])
        translate([0, xaxis_zaxis_distance_y, 0])
        translate([x*zmotor_mount_rod_offset_x, 0, 0])
        mirror([max(0,x),0,0])
        {
            xaxis_end(with_motor=true, beltpath_index=max(0,x), show_nut=true, show_motor=true, show_nut=true);

            xaxis_end_bucket();
        }
    }
}

module y_axis()
{
    // y axis
    attach([[yaxis_belt_path_offset_x,main_depth/2+extrusion_size,yaxis_motor_offset_z], Y], yaxis_motor_mount_conn)
    yaxis_motor_mount(show_motor=true);

    extrusion_idler_conn = [[yaxis_belt_path_offset_x, -main_depth/2-extrusion_size, -extrusion_size+yaxis_idler_offset_z], [0,-1,0]];
    attach(extrusion_idler_conn, yaxis_idler_conn)
    {
        yaxis_idler();

        attach(yaxis_idler_conn_pulleyblock, yaxis_idler_pulleyblock_conn)
        yaxis_idler_pulleyblock(show_pulley=true);
    }

    translate([yaxis_belt_path_offset_x,0,yaxis_belt_path_offset_z])
    translate([0,main_depth/2+extrusion_size+yaxis_motor_offset_x,0])
    rotate(90*Y)
    belt_path(
        len=main_depth+yaxis_motor_offset_x-yaxis_idler_pulley_offset_y+extrusion_size,
        belt_width=yaxis_belt_width,
        pulley_d=yaxis_pulley_inner_d,
        belt=yaxis_belt,
        align=-Y, orient=Y);

    translate([0,-axis_pos_y,get(LinearBearingInnerDiameter, yaxis_bearing)/2])
    attach(yaxis_carriage_bearing_mount_conn_bearing, yaxis_belt_mount_conn)
    yaxis_belt_holder();

    translate([0,0,get(LinearBearingInnerDiameter, yaxis_bearing)/2])
    {
        // y smooth rod clamps to frame
        for(x=[-1,1])
        for(y=[-1,1])
        attach([[x*(yaxis_rod_distance/2),y*(main_depth/2+extrusion_size/2),0],Z],mount_rod_clamp_conn_rod)
        mount_rod_clamp_full(rod_d=zaxis_rod_d, thick=4, width=extrusion_size, thread=zmotor_mount_clamp_thread, orient=Y);

        for(x=[-1,1])
        translate([x*(yaxis_rod_distance/2), 0, 0])
        {
            // y smooth rods
            material(Mat_Chrome)
            cylindera(h=yaxis_rod_l,d=yaxis_rod_d, orient=Y);

            // y bearing mounts
            for(y=[-1,1])
            attach([[0,y*(yaxis_bearing_distance_y/2)-axis_pos_y,0],[0,0,-1]], yaxis_carriage_bearing_mount_conn_bearing)
            {
                yaxis_carriage_bearing_mount();
            }
        }

        attach(yaxis_carriage_bearing_mount_conn_bearing, [[0,axis_pos_y,0],Z])
        {
            yaxis_carriage_size_inner = [32*mm,32*mm,0];

            material(Mat_PrintCarriage)
            {
                // y axis carriage plate "arms"
                for(x=[-1,1])
                for(y=[-1,1])
                hull()
                {
                    translate([x*yaxis_carriage_size[0]/2, y*yaxis_carriage_size[1]/2, 0])
                    cylindera(d=10*mm, h=yaxis_carriage_size[2], align=[-x,-y,1]);

                    translate([x*(yaxis_carriage_size[0]/2-yaxis_carriage_size_inner[0]/2), y*(yaxis_carriage_size[1]/2-yaxis_carriage_size_inner[1]/2*mm), 0])
                    cylindera(d=10*mm, h=yaxis_carriage_size[2], align=[-x,-y,1]);
                }

                // y axis carriage plate
                hull()
                for(x=[-1,1])
                for(y=[-1,1])
                {
                    translate([x*(yaxis_carriage_size[0]/2-yaxis_carriage_size_inner[0]/2), y*(yaxis_carriage_size[1]/2-yaxis_carriage_size_inner[1]/2*mm), 0])
                    cylindera(d=10*mm, h=yaxis_carriage_size[2], align=[-x,-y,1]);
                }
            }

            // y axis plate
            material(Mat_PrintBed)
            translate([0,0,10*mm])
            cubea(printbed_size, align=Z);
        }
    }

}

module z_axis()
{
    // z axis
    for(x=[-1,1])
    {
        translate([x*(main_width/2),0,main_height])
        mirror([x==-1?1:0,0,0])
        translate([zmotor_mount_rod_offset_x, 0, extrusion_size/2])
        mount_rod_clamp_half(
            rod_d=zaxis_rod_d,
            screw_dist=zmotor_mount_clamp_dist,
            thick=5,
            base_thick=5,
            width=zmotor_mount_thickness_h,
            thread=zmotor_mount_clamp_thread);

        tx(x*(main_width/2))
        {
            tz(zaxis_motor_offset_z)
            mirror([x==-1?1:0,0,0])
            {
                zaxis_motor_mount(show_motor=true);

                tx(zmotor_mount_rod_offset_x)
                tz(zmotor_mount_thickness_h/2)
                mount_rod_clamp_half(
                    rod_d=zaxis_rod_d,
                    screw_dist=zmotor_mount_clamp_dist,
                    thick=5,
                    base_thick=5,
                    width=zmotor_mount_thickness_h,
                    thread=zmotor_mount_clamp_thread);
            }

            // z smooth rods
            tx(x*(zmotor_mount_rod_offset_x))
            tz(zaxis_motor_offset_z-80*mm)
            material(Mat_Chrome)
            cylindera(h=zaxis_rod_l,d=zaxis_rod_d, align=Z);
        }
    }

}

module gantry_upper()
{
    for(y=[-1,1])
    translate([0,y*(main_upper_dist_y/2),0])
    {
        for(x=[-1,1])
        translate([x*(main_width/2), 0, 0])
        linear_extrusion(h=main_height, align=[-x,0,1], orient=Z);

        translate([0, 0, main_height])
        linear_extrusion(h=main_upper_width, align=Z, orient=X);
    }

    // upper gantry connectors
    for(x=[-1,1])
    translate([x*(main_width/2),0,main_height])
    mirror([x==-1?1:0,0,0])
    gantry_upper_connector();

}

module gantry_lower()
{
    for(z=[-1,1])
    translate([0,0,z*-main_lower_dist_z/2])
    {
        for(y=[-1,1])
        translate([0, y*(main_depth/2), 0])
        linear_extrusion(h=main_width, align=[0,y,-1], orient=X);

        for(x=[-1,1])
        translate([x*(main_width/2), 0, 0])
        linear_extrusion(h=main_depth, align=-x*X-Z, orient=Y);
    }

    // lower gantry connectors
    for(x=[-1,1])
    for(y=[-1,1])
    translate([x*(main_width/2),y*(main_depth/2),-extrusion_size/2])
    mirror([x==1?0:-1,0,0])
    mirror([0,y==1?1:0,0])
    gantry_lower_connector();

}

module enclosure()
{
    // inner
    w=56*cm;
    h=56*cm;
    d=58*cm;
    wallthick=2*cm;
    backthick=0.5*cm;

    translate([0, 0, h/2+wallthick])
    {
        // left/right walls
        for(x=[-1,1])
        translate([x*w/2,0,0])
        cubea([wallthick,d,h], align=[x, 0, 0]);

        // back plate
        translate([0,d/2,0])
        cubea([w,backthick,h], align=[0,-1, 0]);

        // top/bottom plate
        for(z=[-1,1])
        translate([0,0,z*h/2])
        cubea([w+wallthick*2,d,wallthick], align=[0,0, z]);
    }
}

module main()
{
    translate([0,0,-main_lower_dist_z/2])
    gantry_lower();

    translate(-zaxis_rod_offset)
    gantry_upper();

    x_axis();
    y_axis();
    z_axis();

    translate([-75*mm,0,0])
    translate([0,main_depth/2,0])
    translate([0,extrusion_size,0])
    translate([0,0,-main_lower_dist_z/2-extrusion_size/2])
    power_panel_iec320(orient=[0,-1,0], align=Y);

    if(!$preview_mode)
    {
        translate([0,-main_depth/2,0])
        translate([0,-extrusion_size/2,0])
        translate([0,0,-main_lower_dist_z/2])
        mount_lcd2004(show_gantry=true);

        for(x=[-1,1])
        translate([x*(main_width/2-extrusion_size),main_depth/2,-main_lower_dist_z-extrusion_size])
        translate([-x*psu_a_w/2, -psu_a_d/2, psu_a_h/2])
        {
            psu_a();

            mirror([x==-1?1:0,0,0])
            translate([0, -psu_a_screw_dist_y/2, 0])
            psu_a_extrusion_bracket_side();

            translate([0, psu_a_screw_dist_y/2, 0])
            psu_a_extrusion_bracket_back();
        }

        translate([0,-main_depth/2,-main_lower_dist_z-extrusion_size])
        translate([-100,100,0])
        rotate([0,0,270])
        import("stl/RAMPS1_4.STL");
    }
}

feet_height = 8*mm;
translate([0, 0, main_lower_dist_z+extrusion_size*2+feet_height])
main();

/*psu();*/

/*%enclosure();*/

include <config.scad>

include <thing_libutils/system.scad>
include <thing_libutils/units.scad>
include <thing_libutils/materials.scad>

use <thing_libutils/screws.scad>
use <thing_libutils/shapes.scad>;
use <thing_libutils/misc.scad>;
use <thing_libutils/transforms.scad>;
use <thing_libutils/attach.scad>;
use <thing_libutils/linear-extrusion.scad>;
use <thing_libutils/timing-belts.scad>;

use <x-end.scad>
include <x-end.h>

use <x-carriage.scad>
include <x-carriage.h>

use <y-motor-mount.scad>
include <y-motor-mount.h>

use <y-carriage-bearing-mount.scad>
include <y-carriage-bearing-mount.h>

use <y-carriage-belt-clamp.scad>
include <y-carriage-belt-clamp.h>

use <y-idler.scad>
include <y-idler.h>

use <z-motor-mount.scad>
include <z-motor-mount.h>

use <gantry-upper-connector.scad>
use <gantry-lower-connector.scad>

use <rod-clamps.scad>
include <rod-clamps.h>

/*use <psu.scad>*/
/*include <psu.h>*/

/*use <lcd2004.scad>*/
/*use <power-panel-iec320.scad>*/

// x carriage
axis_range_x_ = main_width/2 + zmotor_mount_rod_offset_x - xaxis_end_width(true) - x_carriage_w/2 - .5*mm;
axis_range_x = [-1,1] *  axis_range_x_;
axis_printrange_x = [-1/2, 1/2] * printbed_size[0];
axis_x_parked = [false, true];

axis_range_y=[0*mm,200*mm];
axis_pos_y = axis_range_y[0];
axis_range_z=[90*mm,353*mm];
axis_pos_z = axis_range_z[0];

echo(str("Axis range X: " , axis_range_x[0], " ", axis_range_x[1]," mm"));
echo(str("Axis range Y: " , axis_range_y[0], " ", axis_range_y[1]," mm"));
echo(str("Axis range Z: " , axis_range_z[0], " ", axis_range_z[1]," mm"));

echo(str("Build area Z: " , axis_range_z[1]-axis_range_z[0] , " mm"));

home_offset_x0 = axis_range_x[0] - axis_printrange_x[0] + v_x(extruder_filapath_offset)[0];
echo(str("Home offset X0: " , home_offset_x0));
echo(str("Tool offset X: " , axis_range_x_+x_carriage_w/2));

module x_axis()
{
    // x axis
    translate([0,0,axis_pos_z])
    {
        zrod_offset = zmotor_mount_rod_offset_x;
        for(z=[-1,1])
        for(z=xaxis_beltpath_z_offsets)
        translate([-main_width/2-zrod_offset+xaxis_end_motor_offset[0], xaxis_zaxis_distance_y, z])
        rotate(90*X)
        belt_path(
            len=main_width+2*(zrod_offset)+xaxis_end_motor_offset[0],
            belt_width=xaxis_belt_width,
            belt=xaxis_belt,
            pulley_d=xaxis_pulley_inner_d,
            orient=X, align=X);

        for(x=[0:len(axis_range_x)-1])
        {
            /*#cubea(size=[x_carriage_w,10,100]);*/

            pos = axis_x_parked[x] ? axis_range_x[x] : -axis_printrange_x[x];

            translate([pos,0,0])
            mirror([x==0?0:1,0,0])
            attach(xaxis_carriage_conn, [[0,-xaxis_zaxis_distance_y,0],N])
            {
                x_carriage_withmounts(show_vitamins=true, beltpath_offset=x==0?-1:1);

                x_carriage_extruder(show_vitamins=true, with_sensormount=x==0);
            }
        }

        // x smooth rods
        for(z=[-1,1])
        translate([xaxis_rod_offset_x,xaxis_zaxis_distance_y,z*(xaxis_rod_distance/2)])
        material(Mat_Chrome)
        cylindera(h=xaxis_rod_l,d=xaxis_rod_d+.1, orient=X);

        for(x=[-1,1])
        translate([x*(main_width/2), 0, 0])
        translate([0, xaxis_zaxis_distance_y, 0])
        translate([x*zmotor_mount_rod_offset_x, 0, 0])
        mirror([max(0,x),0,0])
        {
            xaxis_end(with_motor=true, beltpath_index=max(0,x), show_nut=true, show_motor=true, show_nut=true);

            xaxis_end_bucket();
        }
    }
}

module y_axis()
{
    // y axis
    attach([[yaxis_belt_path_offset_x,main_depth/2+extrusion_size,yaxis_motor_offset_z], Y], yaxis_motor_mount_conn)
    yaxis_motor_mount(show_motor=true);

    extrusion_idler_conn = [[yaxis_belt_path_offset_x, -main_depth/2-extrusion_size, -extrusion_size+yaxis_idler_offset_z], [0,-1,0]];
    attach(extrusion_idler_conn, yaxis_idler_conn)
    {
        yaxis_idler();

        attach(yaxis_idler_conn_pulleyblock, yaxis_idler_pulleyblock_conn)
        yaxis_idler_pulleyblock(show_pulley=true);
    }

    translate([yaxis_belt_path_offset_x,0,yaxis_belt_path_offset_z])
    translate([0,main_depth/2+extrusion_size+yaxis_motor_offset_x,0])
    rotate(90*Y)
    belt_path(
        len=main_depth+yaxis_motor_offset_x-yaxis_idler_pulley_offset_y+extrusion_size,
        belt_width=yaxis_belt_width,
        pulley_d=yaxis_pulley_inner_d,
        belt=yaxis_belt,
        align=-Y, orient=Y);

    translate([0,-axis_pos_y,get(LinearBearingInnerDiameter, yaxis_bearing)/2])
    attach(yaxis_carriage_bearing_mount_conn_bearing, yaxis_belt_mount_conn)
    yaxis_belt_holder();

    translate([0,0,get(LinearBearingInnerDiameter, yaxis_bearing)/2])
    {
        // y smooth rod clamps to frame
        for(x=[-1,1])
        for(y=[-1,1])
        attach([[x*(yaxis_rod_distance/2),y*(main_depth/2+extrusion_size/2),0],Z],mount_rod_clamp_conn_rod)
        mount_rod_clamp_full(rod_d=zaxis_rod_d, thick=4, width=extrusion_size, thread=zmotor_mount_clamp_thread, orient=Y);

        for(x=[-1,1])
        translate([x*(yaxis_rod_distance/2), 0, 0])
        {
            // y smooth rods
            material(Mat_Chrome)
            cylindera(h=yaxis_rod_l,d=yaxis_rod_d, orient=Y);

            // y bearing mounts
            for(y=[-1,1])
            attach([[0,y*(yaxis_bearing_distance_y/2)-axis_pos_y,0],[0,0,-1]], yaxis_carriage_bearing_mount_conn_bearing)
            {
                yaxis_carriage_bearing_mount();
            }
        }

        attach(yaxis_carriage_bearing_mount_conn_bearing, [[0,axis_pos_y,0],Z])
        {
            yaxis_carriage_size_inner = [32*mm,32*mm,0];

            material(Mat_PrintCarriage)
            {
                // y axis carriage plate "arms"
                for(x=[-1,1])
                for(y=[-1,1])
                hull()
                {
                    translate([x*yaxis_carriage_size[0]/2, y*yaxis_carriage_size[1]/2, 0])
                    cylindera(d=10*mm, h=yaxis_carriage_size[2], align=[-x,-y,1]);

                    translate([x*(yaxis_carriage_size[0]/2-yaxis_carriage_size_inner[0]/2), y*(yaxis_carriage_size[1]/2-yaxis_carriage_size_inner[1]/2*mm), 0])
                    cylindera(d=10*mm, h=yaxis_carriage_size[2], align=[-x,-y,1]);
                }

                // y axis carriage plate
                hull()
                for(x=[-1,1])
                for(y=[-1,1])
                {
                    translate([x*(yaxis_carriage_size[0]/2-yaxis_carriage_size_inner[0]/2), y*(yaxis_carriage_size[1]/2-yaxis_carriage_size_inner[1]/2*mm), 0])
                    cylindera(d=10*mm, h=yaxis_carriage_size[2], align=[-x,-y,1]);
                }
            }

            // y axis plate
            material(Mat_PrintBed)
            translate([0,0,10*mm])
            cubea(printbed_size, align=Z);
        }
    }

}

module z_axis()
{
    // z axis
    for(x=[-1,1])
    {
        translate([x*(main_width/2),0,main_height])
        mirror([x==-1?1:0,0,0])
        translate([zmotor_mount_rod_offset_x, 0, extrusion_size/2])
        mount_rod_clamp_half(
            rod_d=zaxis_rod_d,
            screw_dist=zmotor_mount_clamp_dist,
            thick=5,
            base_thick=5,
            width=zmotor_mount_thickness_h,
            thread=zmotor_mount_clamp_thread);

        tx(x*(main_width/2))
        {
            tz(zaxis_motor_offset_z)
            mirror([x==-1?1:0,0,0])
            {
                zaxis_motor_mount(show_motor=true);

                tx(zmotor_mount_rod_offset_x)
                tz(zmotor_mount_thickness_h/2)
                mount_rod_clamp_half(
                    rod_d=zaxis_rod_d,
                    screw_dist=zmotor_mount_clamp_dist,
                    thick=5,
                    base_thick=5,
                    width=zmotor_mount_thickness_h,
                    thread=zmotor_mount_clamp_thread);
            }

            // z smooth rods
            tx(x*(zmotor_mount_rod_offset_x))
            tz(zaxis_motor_offset_z-80*mm)
            material(Mat_Chrome)
            cylindera(h=zaxis_rod_l,d=zaxis_rod_d, align=Z);
        }
    }

}

module gantry_upper()
{
    for(y=[-1,1])
    translate([0,y*(main_upper_dist_y/2),0])
    {
        for(x=[-1,1])
        translate([x*(main_width/2), 0, 0])
        linear_extrusion(h=main_height, align=[-x,0,1], orient=Z);

        translate([0, 0, main_height])
        linear_extrusion(h=main_upper_width, align=Z, orient=X);
    }

    // upper gantry connectors
    for(x=[-1,1])
    translate([x*(main_width/2),0,main_height])
    mirror([x==-1?1:0,0,0])
    gantry_upper_connector();

}

module gantry_lower()
{
    for(z=[-1,1])
    translate([0,0,z*-main_lower_dist_z/2])
    {
        for(y=[-1,1])
        translate([0, y*(main_depth/2), 0])
        linear_extrusion(h=main_width, align=[0,y,-1], orient=X);

        for(x=[-1,1])
        translate([x*(main_width/2), 0, 0])
        linear_extrusion(h=main_depth, align=-x*X-Z, orient=Y);
    }

    // lower gantry connectors
    for(x=[-1,1])
    for(y=[-1,1])
    translate([x*(main_width/2),y*(main_depth/2),-extrusion_size/2])
    mirror([x==1?0:-1,0,0])
    mirror([0,y==1?1:0,0])
    gantry_lower_connector();

}

module enclosure()
{
    // inner
    w=56*cm;
    h=56*cm;
    d=58*cm;
    wallthick=2*cm;
    backthick=0.5*cm;

    translate([0, 0, h/2+wallthick])
    {
        // left/right walls
        for(x=[-1,1])
        translate([x*w/2,0,0])
        cubea([wallthick,d,h], align=[x, 0, 0]);

        // back plate
        translate([0,d/2,0])
        cubea([w,backthick,h], align=[0,-1, 0]);

        // top/bottom plate
        for(z=[-1,1])
        translate([0,0,z*h/2])
        cubea([w+wallthick*2,d,wallthick], align=[0,0, z]);
    }
}

module main()
{
    translate([0,0,-main_lower_dist_z/2])
    gantry_lower();

    translate(-zaxis_rod_offset)
    gantry_upper();

    x_axis();
    y_axis();
    z_axis();

    translate([-75*mm,0,0])
    translate([0,main_depth/2,0])
    translate([0,extrusion_size,0])
    translate([0,0,-main_lower_dist_z/2-extrusion_size/2])
    power_panel_iec320(orient=[0,-1,0], align=Y);

    if(!$preview_mode)
    {
        translate([0,-main_depth/2,0])
        translate([0,-extrusion_size/2,0])
        translate([0,0,-main_lower_dist_z/2])
        mount_lcd2004(show_gantry=true);

        for(x=[-1,1])
        translate([x*(main_width/2-extrusion_size),main_depth/2,-main_lower_dist_z-extrusion_size])
        translate([-x*psu_a_w/2, -psu_a_d/2, psu_a_h/2])
        {
            psu_a();

            mirror([x==-1?1:0,0,0])
            translate([0, -psu_a_screw_dist_y/2, 0])
            psu_a_extrusion_bracket_side();

            translate([0, psu_a_screw_dist_y/2, 0])
            psu_a_extrusion_bracket_back();
        }

        translate([0,-main_depth/2,-main_lower_dist_z-extrusion_size])
        translate([-100,100,0])
        rotate([0,0,270])
        import("stl/RAMPS1_4.STL");
    }
}

feet_height = 8*mm;
translate([0, 0, main_lower_dist_z+extrusion_size*2+feet_height])
main();

/*psu();*/

/*%enclosure();*/


rocket fins added

rocket fins added

error: pathspec 'water_rocket_launcher/fins.scad' did not match any file(s) known to git


Remove rogue echo statement.

Remove rogue echo statement.

include <../config/config.scad>

DebugCoordinateFrames = true;
DebugConnectors = true;
UseSTL = false;

showOtherParts = true;

if (showOtherParts) {
LogoBotBase_STL();
BasicShell_STL();
}

// From MicroSwitch model
datxoffset = -9.6;
datyoffset = -1.25;
width = 6.6;

attach(DefConUp, DefConUp, ExplodeSpacing=20)
    for (x=[0,1], y=[0,1])
        mirror([0,y,0])
        mirror([x,0,0])
        translate([(BaseDiameter/2-10) * cos(45), (BaseDiameter/2-10) * sin(45), -17 ])
        rotate([0,0,-45])
        translate([12.7,8,8]) {
            rotate(a=180, v=[0,0,1]) {
                MicroSwitchHolder_STL();

                translate([-datxoffset + dw + (Bumper_Pin_Width + 1), datyoffset + width, dw])
                mirror([0,1,0])
                    MicroSwitch();
            }
        }

for (i=[0,1])
mirror([0,i,0])
translate([0,0,-7])
    Bumper_STL();

include <../config/config.scad>

DebugCoordinateFrames = true;
DebugConnectors = true;
UseSTL = false;

showOtherParts = true;

if (showOtherParts) {
LogoBotBase_STL();
BasicShell_STL();
}

// From MicroSwitch model
datxoffset = -9.6;
datyoffset = -1.25;
width = 6.6;

attach(DefConUp, DefConUp, ExplodeSpacing=20)
    for (x=[0,1], y=[0,1])
        mirror([0,y,0])
        mirror([x,0,0])
        translate([(BaseDiameter/2-10) * cos(45), (BaseDiameter/2-10) * sin(45), -17 ])
        rotate([0,0,-45])
        translate([12.7,8,8]) {
            rotate(a=180, v=[0,0,1]) {
                MicroSwitchHolder_STL();

                translate([-datxoffset + dw + (Bumper_Pin_Width + 1), datyoffset + width, dw])
                mirror([0,1,0])
                    MicroSwitch();
            }
        }
echo(-datxoffset + dw + (Bumper_Pin_Width + 1));
for (i=[0,1])
mirror([0,i,0])
translate([0,0,-7])
    Bumper_STL();