linked the OpenSCAD file into the tree, as well

$fs=0.05;
$fa=5;
eps=0.001;

mot_rad=3.02;
mot_suppthick=1.6;
mot_suppaddw=0.8;
mot_suppoff=2;
mot_supphwdth=mot_rad+mot_suppaddw;
mot_len=10.1;
mot_shaft=6;
mot_wires=1.7;
mot_total_len=mot_len+mot_shaft+mot_wires;

brd_bthick=1.5;
brd_topthick=5.5;
brd_botthick=2;
brd_lx=27.53;
brd_ly=18.8;
brd_slack=0.5;
brd_vslack=0.2;

brd_hrad=0.5;
brd_hox=1;
brd_hoy=1;
brd_hlx=25.5;
brd_hly=16.75;

brd_rheo_offset=[4.72,8.31,3.38];
brd_rheo_rad=7;
brd_rheo_thick=1.2;
brd_rheo_slack=0.5;

brd_batt_dia=12.5;
brd_batt_thick=3.5;//incl. wire
brd_batt_x=21.25;
brd_batt_y=9.25;

brd_sw_w=2.7;
brd_sw_h=1.64;
brd_sw_d=1;
brd_sw_offset=[19.05,1,0];

sw_hole_h=1.2;
sw_hole_w=2;
sw_hole_skirt=0.4;

case_thick=0.8;
case_pin_skirt=0.5;

nut_hole_add=0.2;
nut_sz=nut_hole_add+5.5;
nut_thk=2.4;
nut_depth=2.5;

bolt_hole_add=0.15;
bolt_dia=bolt_hole_add+3;
bolt_len=8;
bolt_head_len=2;
bolt_head_td=bolt_hole_add+5.52;
bolt_depth=1;
nb_mass_thk=1.2;

lid_skirt_h=1;
lid_skirt_w=0.8;
lid_bh_base=1.5;
lid_bh_foot=0.8;
lid_bh_x=20;

strap_pindst=2;
strap_pindia=1;
strap_tabdia=3;
strap_tabthick=1.2;

module mynut() { nut(nut_sz,nut_thk); }
module mybolt() { bolt(bolt_dia,bolt_len,bolt_head_len,bolt_head_td,bolt_dia); }

int_box=[
    brd_lx+brd_slack*2,
    brd_ly+brd_slack*2+mot_supphwdth*2,
    brd_topthick+brd_botthick+brd_vslack*2
    ];
int_box_off=[
    -brd_slack,
    -brd_slack,
    -brd_vslack-brd_botthick
    ];

ext_box=int_box+[2,2,1]*case_thick;//keep the top open
ext_box_off=int_box_off-[1,1,1]*case_thick;

case_lid_slack=0.25;//min distance between lid & everything else

motor_off=[brd_slack+mot_total_len+0.5,
          brd_ly+brd_slack+eps,
          -brd_botthick-brd_vslack-eps
          ];

bn_hoff=[
    (motor_off[0]+int_box[0]+int_box_off[0])/2,
    brd_ly+brd_slack+mot_supphwdth,
    0
    ];

//------------------

module nut(sz,thickn){
    intersection() {
        cube([sz,sz*2,thickn],true);
        rotate([0,0,60]) cube([sz,sz*2,thickn],true);
        rotate([0,0,-60])cube([sz,sz*2,thickn],true);
    }
}

module hnut(sz,thk,hole){
    difference(){
        nut(sz,thk);
        translate([0,0,-thk/2-eps])
            cylinder(thk+2*eps,hole/2,hole/2);
    }
}

module bolt(dia,tlen,hlen,htop,hbot) {
    union() {
        cylinder(tlen,dia/2,dia/2);
        translate([0,0,-eps])
            cylinder(hlen+eps,htop/2,hbot/2);
    }
}

module motcube(transl) {
    translate([0,0,transl])
    cube([mot_supphwdth*2,mot_supphwdth*2,mot_suppthick],true);
};

module motrings(){
    difference() {
        union() {
            motcube(mot_suppoff);
            motcube(mot_len-mot_suppoff);
        }
        #cylinder(mot_len, mot_rad, mot_rad, false);
    }
    translate([0,0,-mot_wires])
        %cylinder(mot_total_len,mot_rad-0.1,mot_rad-0.1);
}

module rmotrings(){
    translate([0,mot_supphwdth,mot_supphwdth])
        rotate(-90,[0,1,0])
            translate([0,0,mot_wires])
                motrings();
}

module rmotkeepout(slack){
    translate([0,mot_supphwdth,mot_supphwdth])
        rotate(-90,[0,1,0])
            translate([0,0,mot_total_len/2])
                cube([2,2,0]*(mot_supphwdth+slack) + [0,0,mot_total_len], true);
}

module brdhole(x,y,rad,top,bot) {
    translate(
      [brd_hox+brd_hlx*x,
       brd_hoy+brd_hly*y,
       bot]
    )
        cylinder(top-bot,rad,rad);
}

module mainbrd(slack, rslack) {
    union() {
        difference() {//the board
            translate([-slack,-slack,0])
                cube([brd_lx+slack*2,brd_ly+slack*2,brd_bthick],false);
            brdhole(0,0,brd_hrad,brd_bthick+0.1,-0.1);
            brdhole(0,1,brd_hrad,brd_bthick+0.1,-0.1);
            brdhole(1,0,brd_hrad,brd_bthick+0.1,-0.1);
            brdhole(1,1,brd_hrad,brd_bthick+0.1,-0.1);
        }
        //rheo
        translate(brd_rheo_offset-[0,0,rslack]) {
            cylinder(brd_rheo_thick+rslack*2,brd_rheo_rad+rslack,brd_rheo_rad+rslack);
        }
        //button
        translate(brd_sw_offset+[-brd_sw_w/2, 0, -brd_sw_h]) {
            cube([brd_sw_w,brd_sw_d,brd_sw_h],false);
        }
        //batt
        batt_off=[brd_batt_x,brd_batt_y,brd_bthick];
        translate(batt_off)
            cylinder(brd_batt_thick,brd_batt_dia/2,brd_batt_dia/2);
    }
}

module cbox(){
    pin_brad = brd_hrad+case_pin_skirt;
    pin_trad = brd_hrad;
    pin_top = brd_bthick+0.1;
    pin_bot = int_box_off[2]-0.01;

    slit_dim = [case_thick,
                brd_hly,
                brd_bthick+case_thick-int_box_off[2]
                ];
    slit_off = int_box_off+[0,brd_hoy-int_box_off[1],0];

    llip_dim = [case_thick+2*eps,
                int_box[1]+2*eps,
                case_thick];
    llip_off = int_box_off+[-eps,-eps,int_box[2]-llip_dim[2]];

    union() {
        difference() {
            //outer shell
            translate(ext_box_off)
                cube(ext_box);
            //main cavity
            translate(int_box_off)
                cube(int_box+[0,0,0.01]);
        }

        //pins
        brdhole(1,0,pin_brad,0,pin_bot);
        brdhole(1,0,pin_trad,pin_top,-0.1);
        brdhole(1,1,pin_brad,0,pin_bot);
        brdhole(1,1,pin_trad,pin_top,-0.1);

        //potside slit mass
        translate(slit_off)
            cube(slit_dim);

        //lid grip
        translate(llip_off)
            cube(llip_dim);

        //screw mass
        bm_orad = bolt_head_td/2+nb_mass_thk;
        bm_srad = bolt_dia/2+nb_mass_thk;
        translate(bn_hoff+[0,0,ext_box_off[2]+eps]){
            cylinder(bolt_depth,bm_orad,bm_orad);
                translate([0,0,bolt_depth-eps])
                    cylinder(bolt_head_len,bm_orad,bm_srad);
        }
    }
}

module case(){
    union(){
        difference() {
            cbox();

            //hole for rheo
            mainbrd(brd_slack,brd_rheo_slack);

            //hole for button
            translate(brd_sw_offset+[0,0,-sw_hole_h/2-sw_hole_skirt])
                cube([sw_hole_w,8,sw_hole_h],true);

            //hole for screw
            translate(bn_hoff+[0,0,ext_box_off[2]-eps]){
                cylinder(bolt_depth+2*eps,bolt_head_td/2,bolt_head_td/2);
                translate([0,0,bolt_depth+eps])
                    #mybolt();
            }
        }

        //motor
        translate(motor_off){
            rmotrings();
        }

        translate(ext_box_off+[0,0,strap_tabdia/2])
            rotate (-90,[0,1,0])
                strappair(
                  ext_box[1],
                  strap_tabdia,
                  strap_pindst,
                  strap_pindia,
                  strap_tabthick
                );

         translate(ext_box_off+[ext_box[0],0,strap_tabdia/2])
            rotate (90,[0,1,0])
                strappair(
                  ext_box[1],
                  strap_tabdia,
                  strap_pindst,
                  strap_pindia,
                  strap_tabthick
                );
    }
}

module lid(){
    lid_dim = [ext_box[0]-eps,ext_box[1]-eps,case_thick+lid_skirt_h];
    lid_off = ext_box_off+[eps/2,eps/2,(ext_box[2]-lid_skirt_h)];
    lsksub_dim = lid_dim-[2,2,0]*(lid_skirt_w+case_thick)+[0,0,-case_thick+eps];
    lsksub_off = lid_off+[1,1,0]*(lid_skirt_w+case_thick)+[0,0,-eps];
    lidgrip_dim = [4*case_thick,lid_dim[1],lid_dim[2]+case_thick];
    lidgrip_off = lid_off + [0,0,-1]*case_thick;

    nut_off = bn_hoff+[0,0,lid_off[2]+case_thick+lid_skirt_h];

    bh_hght = lid_off[2]+lid_skirt_h-brd_bthick;
    bh_z = lid_off[2]+lid_skirt_h-bh_hght;

    difference(){
        union(){
            difference(){ //basic lid w/skirt
                translate(lid_off) cube(lid_dim);
                translate(lsksub_off) cube(lsksub_dim);
            }
            difference(){ //lip-grip
                translate(lidgrip_off) cube(lidgrip_dim);
                translate(brd_rheo_offset) cube(brd_rheo_rad*2,true);
            }

            intersection(){
                translate(int_box_off)
                    cube(int_box);
                union(){
                    //board-holders
                    translate([lid_bh_x,0,bh_z])
                        cylinder(bh_hght+eps,lid_bh_foot,lid_bh_base);
                    translate([lid_bh_x,brd_ly,bh_z])
                        cylinder(bh_hght+eps,lid_bh_foot,lid_bh_base);

                            //nut mass
                    translate(nut_off)
                        nut(nut_sz+nb_mass_thk, (nut_depth+nb_mass_thk)*2);
                }

            }

        }

        case();

        translate(motor_off){
            rmotkeepout(case_lid_slack);
        }

        translate(nut_off){
            nut(nut_sz,nut_depth*2);
            translate([0,0,-bolt_len])
                mybolt();
            translate([0,0,nut_thk/2-nut_depth])
                %hnut(nut_sz,nut_thk,bolt_dia);
        }

    }
}

module straptab(wid,dist,holedia,thickn) {
    translate([-wid/2,-thickn/2,-eps])
        difference() {
            union() {
                cube([wid,thickn,dist+eps]);
                translate([wid/2,0,dist+eps]){
                    rotate(-90,[1,0,0]) {
                            cylinder(thickn,wid/2,wid/2);
                    }
                }
            }

            translate([wid/2,-eps,dist+eps]){
                rotate(-90,[1,0,0]) {
                        cylinder(thickn+eps*2,holedia/2,holedia/2);
                }
            }
        }
}

module strappair(pwidth,twidth,pdist,pindia,tthick) {
    union() {
        translate([0,tthick/2,0]) straptab(twidth,pdist,pindia,tthick);
        translate([0,pwidth-tthick/2,0]) straptab(twidth,pdist,pindia,tthick);
    }
}

translate(-ext_box_off){
    *lid();
    case();
    %mainbrd(0.4,0);
}

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


main: fix wierd rendering artifact on x rods

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

include <MCAD/stepper.scad>
include <MCAD/motors.scad>

include <misc.scad>
/*include <extruder-direct.scad>*/
include <x-axis-end.scad>
include <x-carriage.scad>
include <y-axis-motor-mount.scad>
include <y-axis-carriage-bearing-mount.scad>
include <y-axis-carriage-belt-clamp.scad>
include <y-axis-idler.scad>
include <z-axis-motor-mount.scad>
include <z-axis-upper-gantry-connector.scad>
include <psu.scad>
use <rod-clamps.scad>

use <scad-utils/trajectory.scad>
use <scad-utils/trajectory_path.scad>
use <scad-utils/transformations.scad>
use <scad-utils/shapes.scad>
use <list-comprehension-demos/skin.scad>

axis_pos_x = -213/2*mm;
axis_pos_y = 0*mm;
axis_range_z=[98*mm,353*mm];
axis_pos_z = axis_range_z[0];

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

module x_axis()
{
    // x axis
    translate([0,0,axis_pos_z])
    {
        if(!preview_mode)
        {
            zrod_offset = zmotor_mount_rod_offset_x;
            translate([-main_width/2-zrod_offset+xaxis_end_motor_offset[0], xaxis_zaxis_distance_y, 0])
                belt_path(main_width+2*(zrod_offset)+xaxis_end_motor_offset[0], 6, xaxis_pulley_inner_d, orient=[1,0,0], align=[1,0,0]);
        }

        translate([axis_pos_x,0,0])
        {
            // x carriage
            attach(xaxis_carriage_conn, [[0,-xaxis_zaxis_distance_y,0],[0,0,0]])
            {
                x_carriage_full();
            }
        }

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

        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])
                xaxis_end(with_motor=x==-1, show_nut=true, show_motor=true, show_nut=true);
            }
        }
    }
}

module y_axis()
{
    // y axis
    attach([[yaxis_belt_path_offset_x,main_depth/2,yaxis_motor_offset_z], [0,-1,0]], 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])
    {
        if(!preview_mode)
        {
            translate([0,main_depth/2-yaxis_motor_offset_x,0])
            {
                /*cubea([10,main_depth-yaxis_motor_offset_x,10], align=[0,-1,0]);*/
                belt_path(main_depth-yaxis_motor_offset_x-yaxis_idler_pulley_offset_y, 6, yaxis_pulley_inner_d, align=[0,-1,0], orient=[0,1,0]);
            }
        }
    }

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

    translate([0,0,yaxis_bearing[0]/2])
    {
        for(i=[-1,1])
        for(j=[-1,1])
        {
            attach([[i*(yaxis_rod_distance/2),j*(main_depth/2+extrusion_size/2),0],[0,0,1]],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=[0,1,0]);
            }
        }

        for(i=[-1,1])
        translate([i*(yaxis_rod_distance/2), 0, 0])
        {
            cylindera(h=yaxis_rod_l,d=yaxis_rod_d, orient=[0,1,0]);

            for(j=[-1,1])
            {
                attach([[0,j*(yaxis_bearing_distance_y/2)-axis_pos_y,0],[0,0,-1]], yaxis_carriage_bearing_mount_conn_bearing)
                {
                    yaxis_carriage_bearing_mount(show_bearing=true, show_zips=true);
                }
            }
        }

        attach(yaxis_carriage_bearing_mount_conn_bearing, [[0,axis_pos_y,0],[0,0,1]])
        {
            /*translate([x*yaxis_carriage_size[0]/2, y*(yaxis_carriage_size[1]-16*mm)/2, 0])*/
            // y axis plate
            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-16*mm), y*(yaxis_carriage_size[1]/2-16*mm), 0])
                {
                    cylindera(d=10*mm, h=yaxis_carriage_size[2], align=[-x,-y,1]);
                }
            }

            cubea([yaxis_carriage_size[0]-16*mm*2,yaxis_carriage_size[1]-16*mm*2, yaxis_carriage_size[2]], align=[0,0,1]);

            translate([0,0,10*mm])
                cubea(yaxis_carriage_size, align=[0,0,1]);
        }
    }

}

module z_axis()
{
    // z axis
    for(i=[-1,1])
    {
        translate([i*(main_width/2),0,main_height])
        {
            mirror([i==-1?1:0,0,0])
            {
                zaxis_upper_gantry_zrod_connector();

                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);
            }
        }

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

                    translate([zmotor_mount_rod_offset_x, 0, 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
            translate([i*(zmotor_mount_rod_offset_x),0,0])
            {
                // z rods
                translate([0,0,zaxis_motor_offset_z-50])
                    cylindera(h=zaxis_rod_l,d=zaxis_rod_d, align=[0,0,1]);

                for(j=[-1,1])
                    translate([0,0,axis_pos_z-j*xaxis_rod_distance/2])
                        bearing(zaxis_bearing);

            }
        }
    }

}

module main()
{
    color(extrusion_color)
    gantry_lower();

    color(extrusion_color)
    translate([0,0,-main_lower_dist_z])
    gantry_lower();

    color(extrusion_color)
    for(i=[-1,1])
    translate([0,i*(main_upper_dist_y/2),0])
    gantry_upper();

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

    if(!preview_mode)
    {
        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");
    }
}

module gantry_upper()
{
    for(i=[-1,1])
    translate([i*(main_width/2), 0, 0])
    {
        if(preview_mode)
        {
            cubea(size=[extrusion_size, extrusion_size, main_height], align=[-i,0,1]);
        }
        else
        {
            linear_extrusion(h=main_height, align=[-i,0,1], orient=[0,0,1]);
        }
    }

    translate([0, 0, main_height])
    {
        if(preview_mode)
        {
            cubea(size=[main_upper_width, extrusion_size, extrusion_size], align=[0,0,1]);
        }
        else
        {
            linear_extrusion(h=main_upper_width, align=[0,0,1], orient=[1,0,0]);
        }
    }
}

module gantry_lower()
{
    for(i=[-1,1])
    translate([0,  i*(main_depth/2), 0])
    {
        if(preview_mode)
        {
            cubea([main_width, extrusion_size, extrusion_size], align=[0,i,-1]);
        }
        else
        {
            linear_extrusion(h=main_width, align=[0,i,-1], orient=[1,0,0]);
        }
    }

    for(i=[-1,1])
    translate([i*(main_width/2), 0, 0])
    {
        if(preview_mode)
        {
            cubea([extrusion_size, main_depth, extrusion_size], align=[-i,0,-1]);
        }
        else
        {
            linear_extrusion(h=main_depth, align=[-i,0,-1], orient=[0,1,0]);
        }
    }
}

module enclosure()
{
    w=60*cm;
    h=60*cm;
    d=60*cm;
    wallthick=2*cm;
    backthick=0.5*cm;

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

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

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

translate([0, 0, main_lower_dist_z+extrusion_size*2])
main();

/*psu();*/

/*%enclosure();*/

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

include <MCAD/stepper.scad>
include <MCAD/motors.scad>

include <misc.scad>
/*include <extruder-direct.scad>*/
include <x-axis-end.scad>
include <x-carriage.scad>
include <y-axis-motor-mount.scad>
include <y-axis-carriage-bearing-mount.scad>
include <y-axis-carriage-belt-clamp.scad>
include <y-axis-idler.scad>
include <z-axis-motor-mount.scad>
include <z-axis-upper-gantry-connector.scad>
include <psu.scad>
use <rod-clamps.scad>

use <scad-utils/trajectory.scad>
use <scad-utils/trajectory_path.scad>
use <scad-utils/transformations.scad>
use <scad-utils/shapes.scad>
use <list-comprehension-demos/skin.scad>

axis_pos_x = -213/2*mm;
axis_pos_y = 0*mm;
axis_range_z=[98*mm,353*mm];
axis_pos_z = axis_range_z[0];

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

module x_axis()
{
    // x axis
    translate([0,0,axis_pos_z])
    {
        if(!preview_mode)
        {
            zrod_offset = zmotor_mount_rod_offset_x;
            translate([-main_width/2-zrod_offset+xaxis_end_motor_offset[0], xaxis_zaxis_distance_y, 0])
                belt_path(main_width+2*(zrod_offset)+xaxis_end_motor_offset[0], 6, xaxis_pulley_inner_d, orient=[1,0,0], align=[1,0,0]);
        }

        translate([axis_pos_x,0,0])
        {
            // x carriage
            attach(xaxis_carriage_conn, [[0,-xaxis_zaxis_distance_y,0],[0,0,0]])
            {
                x_carriage_full();
            }
        }

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

        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])
                xaxis_end(with_motor=x==-1, show_nut=true, show_motor=true, show_nut=true);
            }
        }
    }
}

module y_axis()
{
    // y axis
    attach([[yaxis_belt_path_offset_x,main_depth/2,yaxis_motor_offset_z], [0,-1,0]], 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])
    {
        if(!preview_mode)
        {
            translate([0,main_depth/2-yaxis_motor_offset_x,0])
            {
                /*cubea([10,main_depth-yaxis_motor_offset_x,10], align=[0,-1,0]);*/
                belt_path(main_depth-yaxis_motor_offset_x-yaxis_idler_pulley_offset_y, 6, yaxis_pulley_inner_d, align=[0,-1,0], orient=[0,1,0]);
            }
        }
    }

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

    translate([0,0,yaxis_bearing[0]/2])
    {
        for(i=[-1,1])
        for(j=[-1,1])
        {
            attach([[i*(yaxis_rod_distance/2),j*(main_depth/2+extrusion_size/2),0],[0,0,1]],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=[0,1,0]);
            }
        }

        for(i=[-1,1])
        translate([i*(yaxis_rod_distance/2), 0, 0])
        {
            cylindera(h=yaxis_rod_l,d=yaxis_rod_d, orient=[0,1,0]);

            for(j=[-1,1])
            {
                attach([[0,j*(yaxis_bearing_distance_y/2)-axis_pos_y,0],[0,0,-1]], yaxis_carriage_bearing_mount_conn_bearing)
                {
                    yaxis_carriage_bearing_mount(show_bearing=true, show_zips=true);
                }
            }
        }

        attach(yaxis_carriage_bearing_mount_conn_bearing, [[0,axis_pos_y,0],[0,0,1]])
        {
            /*translate([x*yaxis_carriage_size[0]/2, y*(yaxis_carriage_size[1]-16*mm)/2, 0])*/
            // y axis plate
            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-16*mm), y*(yaxis_carriage_size[1]/2-16*mm), 0])
                {
                    cylindera(d=10*mm, h=yaxis_carriage_size[2], align=[-x,-y,1]);
                }
            }

            cubea([yaxis_carriage_size[0]-16*mm*2,yaxis_carriage_size[1]-16*mm*2, yaxis_carriage_size[2]], align=[0,0,1]);

            translate([0,0,10*mm])
                cubea(yaxis_carriage_size, align=[0,0,1]);
        }
    }

}

module z_axis()
{
    // z axis
    for(i=[-1,1])
    {
        translate([i*(main_width/2),0,main_height])
        {
            mirror([i==-1?1:0,0,0])
            {
                zaxis_upper_gantry_zrod_connector();

                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);
            }
        }

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

                    translate([zmotor_mount_rod_offset_x, 0, 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
            translate([i*(zmotor_mount_rod_offset_x),0,0])
            {
                // z rods
                translate([0,0,zaxis_motor_offset_z-50])
                    cylindera(h=zaxis_rod_l,d=zaxis_rod_d, align=[0,0,1]);

                for(j=[-1,1])
                    translate([0,0,axis_pos_z-j*xaxis_rod_distance/2])
                        bearing(zaxis_bearing);

            }
        }
    }

}

module main()
{
    color(extrusion_color)
    gantry_lower();

    color(extrusion_color)
    translate([0,0,-main_lower_dist_z])
    gantry_lower();

    color(extrusion_color)
    for(i=[-1,1])
    translate([0,i*(main_upper_dist_y/2),0])
    gantry_upper();

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

    if(!preview_mode)
    {
        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");
    }
}

module gantry_upper()
{
    for(i=[-1,1])
    translate([i*(main_width/2), 0, 0])
    {
        if(preview_mode)
        {
            cubea(size=[extrusion_size, extrusion_size, main_height], align=[-i,0,1]);
        }
        else
        {
            linear_extrusion(h=main_height, align=[-i,0,1], orient=[0,0,1]);
        }
    }

    translate([0, 0, main_height])
    {
        if(preview_mode)
        {
            cubea(size=[main_upper_width, extrusion_size, extrusion_size], align=[0,0,1]);
        }
        else
        {
            linear_extrusion(h=main_upper_width, align=[0,0,1], orient=[1,0,0]);
        }
    }
}

module gantry_lower()
{
    for(i=[-1,1])
    translate([0,  i*(main_depth/2), 0])
    {
        if(preview_mode)
        {
            cubea([main_width, extrusion_size, extrusion_size], align=[0,i,-1]);
        }
        else
        {
            linear_extrusion(h=main_width, align=[0,i,-1], orient=[1,0,0]);
        }
    }

    for(i=[-1,1])
    translate([i*(main_width/2), 0, 0])
    {
        if(preview_mode)
        {
            cubea([extrusion_size, main_depth, extrusion_size], align=[-i,0,-1]);
        }
        else
        {
            linear_extrusion(h=main_depth, align=[-i,0,-1], orient=[0,1,0]);
        }
    }
}

module enclosure()
{
    w=60*cm;
    h=60*cm;
    d=60*cm;
    wallthick=2*cm;
    backthick=0.5*cm;

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

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

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

translate([0, 0, main_lower_dist_z+extrusion_size*2])
main();

/*psu();*/

/*%enclosure();*/


fixing up diameters

fixing up diameters

$fn = 64;

// interference fit adjustment for 3D printer
iFitAdjust = .4;
iFitAdjust_d = .25;

// latch buttons
latchButtonDiameter = 13;
latchButtonHeight = 30;
module latch_button() {
    cylinder(h = latchButtonHeight, d = latchButtonDiameter, center = false);
}

// led momentary buttons
ledButtonDiameter = 24;
ledButtonHeight = 33;
module momentary_button() {
    cylinder(h = ledButtonHeight, d = ledButtonDiameter, center = false);
}

// encoders
encoderShaftDiameter = 7;
encoderShaftHeight = 18;
encoderWidth = 18;
encoderLength = 31;
encoderDepth = 8.2;
module encoder() {
    // encoder shaft
    cylinder(h = encoderShaftHeight, d = encoderShaftDiameter, center=false);
    // encoder base
    translate([-encoderWidth/2, -encoderLength/2, -encoderDepth/2])
        cube([encoderWidth, encoderLength, encoderDepth]);
}

// string
stringWallThickness = 1;
stringRecess = 5;
stringLength = 60;
photoresistorWidth = 5.5 + iFitAdjust_d;
photoresistorLength = photoresistorWidth;
photoresistorWireSep = 3.5;
ledLaserDiameter = 6.5 + iFitAdjust_d;
ledLaserLength = 10;
wireCasingDepth = 3;
module photoresistor_holder() {
    difference() {
        cylinder(h = stringRecess + stringWallThickness * 2, d = 2 * stringWallThickness + photoresistorWidth + iFitAdjust_d, center = false);
        translate([0,0,-.1])
            cylinder(h = stringRecess + stringWallThickness * 2 + 1, d = photoresistorWidth + iFitAdjust_d, center = false);
        /*
        for (i = [-1,1])
            translate([i * photoresistorWireSep / 2, 0, -1])
                cylinder(h = 20, d = 1, center = false);
        */
    }
    rotate([0, 0, 180])
        translate([-(ledLaserDiameter + iFitAdjust_d + 2 * stringWallThickness)/2, -(ledLaserDiameter )/2 - 1, -(wireCasingDepth + stringWallThickness * 2)])
        difference() {
            cube([ledLaserDiameter + iFitAdjust_d + 2 * stringWallThickness, ledLaserDiameter + ledLaserDiameter / 2 + 1, wireCasingDepth + stringWallThickness * 2], center=false);
            translate([stringWallThickness, stringWallThickness * 2 + 1, stringWallThickness])
                cube([ledLaserDiameter + iFitAdjust_d , ledLaserDiameter + ledLaserDiameter / 2 - stringWallThickness, wireCasingDepth], center=false);
            translate([ledLaserDiameter / 2 + stringWallThickness, ledLaserDiameter / 2 + stringWallThickness, stringWallThickness])
                cylinder(h=wireCasingDepth + 2 * stringWallThickness, d = ledLaserDiameter + iFitAdjust, center=false);
        }
}
module led_holder() {
    difference() {
        cylinder(h = ledLaserLength + stringWallThickness * 2, d = 2 * stringWallThickness + ledLaserDiameter + iFitAdjust_d, center = false);
        translate([0,0,-.1])
            cylinder(h = ledLaserLength + stringWallThickness * 2 + 1, d = ledLaserDiameter + iFitAdjust_d, center = false);
        /*
        for (i = [-1,1])
            translate([i * photoresistorWireSep / 2, 0, -1])
                cylinder(h = 20, d = 1, center = false);
        */
    }
    translate([-(ledLaserDiameter + iFitAdjust_d + 2 * stringWallThickness)/2, -(ledLaserDiameter )/2 - 1, -(wireCasingDepth + stringWallThickness * 2)])
        difference() {
            cube([ledLaserDiameter + iFitAdjust_d + 2 * stringWallThickness, ledLaserDiameter + ledLaserDiameter / 2 + 1, wireCasingDepth + stringWallThickness * 2], center=false);
            translate([stringWallThickness, stringWallThickness * 2 + 1, stringWallThickness])
                cube([ledLaserDiameter + iFitAdjust_d , ledLaserDiameter + ledLaserDiameter / 2 - stringWallThickness, wireCasingDepth], center=false);
            translate([ledLaserDiameter / 2 + stringWallThickness, ledLaserDiameter / 2 + stringWallThickness, stringWallThickness])
                cylinder(h=wireCasingDepth + 2 * stringWallThickness, d = ledLaserDiameter + iFitAdjust, center=false);
        }
}
module string() {
    photoresistor_holder();
    translate([0, 0, stringLength])
        rotate([180, 0, 0])
            led_holder();
    difference() {
        translate([-(ledLaserDiameter + 2 * stringWallThickness + iFitAdjust_d)/2, - ledLaserDiameter, 0])
            cube([ledLaserDiameter + iFitAdjust_d + 2 * stringWallThickness, ledLaserDiameter / 2, stringLength ], center = false);
        cylinder(h=100, d = ledLaserDiameter + iFitAdjust, center=false);
    }
}

// display
i2cOLEDWidth = 27;
i2cOLEDHeight = 16;
i2cOLEDScrewWidth = 20;
i2cOLEDScrewHeight = 22;
module display() {
}

module lid() {
    string();
}

lid();

$fn = 64;

// interference fit adjustment for 3D printer
iFitAdjust = .4;
iFitAdjust_d = .25;

// latch buttons
latchButtonDiameter = 13;
latchButtonHeight = 30;
module latch_button() {
    cylinder(h = latchButtonHeight, d = latchButtonDiameter, center = false);
}

// led momentary buttons
ledButtonDiameter = 24;
ledButtonHeight = 33;
module momentary_button() {
    cylinder(h = ledButtonHeight, d = ledButtonDiameter, center = false);
}

// encoders
encoderShaftDiameter = 7;
encoderShaftHeight = 18;
encoderWidth = 18;
encoderLength = 31;
encoderDepth = 8.2;
module encoder() {
    // encoder shaft
    cylinder(h = encoderShaftHeight, d = encoderShaftDiameter, center=false);
    // encoder base
    translate([-encoderWidth/2, -encoderLength/2, -encoderDepth/2])
        cube([encoderWidth, encoderLength, encoderDepth]);
}

// string
stringWallThickness = 1;
stringRecess = 5;
stringLength = 60;
photoresistorWidth = 6.5;
photoresistorLength = 6.5;
photoresistorWireSep = 3.5;
ledLaserDiameter = 8;
ledLaserLength = 10;
wireCasingDepth = 3;
module photoresistor_holder() {
    difference() {
        cylinder(h = stringRecess + stringWallThickness * 2, d = 2 * stringWallThickness + photoresistorWidth + iFitAdjust_d, center = false);
        translate([0,0,-.1])
            cylinder(h = stringRecess + stringWallThickness * 2 + 1, d = photoresistorWidth + iFitAdjust_d, center = false);
        /*
        for (i = [-1,1])
            translate([i * photoresistorWireSep / 2, 0, -1])
                cylinder(h = 20, d = 1, center = false);
        */
    }
    rotate([0, 0, 180])
        translate([-(ledLaserDiameter + iFitAdjust_d + 2 * stringWallThickness)/2, -(ledLaserDiameter )/2 - 1, -(wireCasingDepth + stringWallThickness * 2)])
        difference() {
            cube([ledLaserDiameter + iFitAdjust_d + 2 * stringWallThickness, ledLaserDiameter + ledLaserDiameter / 2 + 1, wireCasingDepth + stringWallThickness * 2], center=false);
            translate([stringWallThickness, stringWallThickness * 2 + 1, stringWallThickness])
                cube([ledLaserDiameter + iFitAdjust_d , ledLaserDiameter + ledLaserDiameter / 2 - stringWallThickness, wireCasingDepth], center=false);
            translate([ledLaserDiameter / 2 + stringWallThickness, ledLaserDiameter / 2 + stringWallThickness, stringWallThickness])
                cylinder(h=wireCasingDepth + 2 * stringWallThickness, d = ledLaserDiameter + iFitAdjust, center=false);
        }
}
module led_holder() {
    difference() {
        cylinder(h = ledLaserLength + stringWallThickness * 2, d = 2 * stringWallThickness + ledLaserDiameter + iFitAdjust_d, center = false);
        translate([0,0,-.1])
            cylinder(h = ledLaserLength + stringWallThickness * 2 + 1, d = ledLaserDiameter + iFitAdjust_d, center = false);
        /*
        for (i = [-1,1])
            translate([i * photoresistorWireSep / 2, 0, -1])
                cylinder(h = 20, d = 1, center = false);
        */
    }
    translate([-(ledLaserDiameter + iFitAdjust_d + 2 * stringWallThickness)/2, -(ledLaserDiameter )/2 - 1, -(wireCasingDepth + stringWallThickness * 2)])
        difference() {
            cube([ledLaserDiameter + iFitAdjust_d + 2 * stringWallThickness, ledLaserDiameter + ledLaserDiameter / 2 + 1, wireCasingDepth + stringWallThickness * 2], center=false);
            translate([stringWallThickness, stringWallThickness * 2 + 1, stringWallThickness])
                cube([ledLaserDiameter + iFitAdjust_d , ledLaserDiameter + ledLaserDiameter / 2 - stringWallThickness, wireCasingDepth], center=false);
            translate([ledLaserDiameter / 2 + stringWallThickness, ledLaserDiameter / 2 + stringWallThickness, stringWallThickness])
                cylinder(h=wireCasingDepth + 2 * stringWallThickness, d = ledLaserDiameter + iFitAdjust, center=false);
        }
}
module string() {
    photoresistor_holder();
    translate([0, 0, stringLength])
        rotate([180, 0, 0])
            led_holder();
    difference() {
        translate([-(ledLaserDiameter + 2 * stringWallThickness + iFitAdjust_d)/2, - ledLaserDiameter, 0])
            cube([ledLaserDiameter + iFitAdjust_d + 2 * stringWallThickness, ledLaserDiameter / 2, stringLength ], center = false);
        cylinder(h=100, d = ledLaserDiameter + iFitAdjust, center=false);
    }
}

// display
i2cOLEDWidth = 27;
i2cOLEDHeight = 16;
i2cOLEDScrewWidth = 20;
i2cOLEDScrewHeight = 22;
module display() {
}

module lid() {
    string();
}

lid();


Fix typo in annotation (negativeExtrude)

/**
 * @license
 * MIT License
 *
 * Copyright (c) 2017 Jean-Sebastien CONAN
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in all
 * copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */

/**
 * Part of the camelSCAD library.
 *
 * Operators that extrude children modules with respect to particular rules.
 *
 * @package operator/extrude
 * @author jsconan
 */

/**
 * Extrudes linearly the children modules, and applies a wall adjustment to ensure
 * the final object will not produce artifacts after a `difference()` operation.
 *
 * @param Number [height] - The height of the extrusion. If the value is negative,
 *                          the extrusion will be made top to bottom (below the origin).
 * @param Number|String [direction] - Tells on what sides adjust the height to make sure
 *                                    the difference won't produce dummy walls.
 * @param Boolean [center] - Whether or not center the extrusion on the vertical axis.
 * @param Number [convexity] - If the extrusion fails for a non-trivial 2D shape,
 *                             try setting the convexity parameter.
 * @param Number [twist] - The number of degrees of through which the shape is extruded.
 * @param Number [slices] - Defines the number of intermediate points along the Z axis
 *                          of the extrusion.
 * @param Number|Vector [scale] - Scales the 2D shape by this value over the height of
 *                                the extrusion.
 */
module negativeExtrude(height, direction, center, convexity, twist, slices, scale) {
    center = boolean(center);
    convexity = numberOr(convexity, 10);
    height = align(value=height, direction=direction, center=center);

    translateZ(height[1]) {
        linear_extrude(height=height[0], center=center, convexity=convexity, twist=twist, slices=slices, scale=scale) {
            children();
        }
    }
}

/**
 * @license
 * MIT License
 *
 * Copyright (c) 2017 Jean-Sebastien CONAN
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in all
 * copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */

/**
 * Part of the camelSCAD library.
 *
 * Operators that extrude children modules with respect to particular rules.
 *
 * @package operator/extrude
 * @author jsconan
 */

/**
 * Extrudes linearly the children modules, and apply a wall adjustment to ensure
 * the final object will not produce artifacts after a `difference()` operation.
 *
 * @param Number [height] - The height of the extrusion. If the value is negative,
 *                          the extrusion will be made top to bottom (below the origin).
 * @param Number|String [direction] - Tells on what sides adjust the height to make sure
 *                                    the difference won't produce dummy walls.
 * @param Boolean [center] - Whether or not center the extrusion on the vertical axis.
 * @param Number [convexity] - If the extrusion fails for a non-trivial 2D shape,
 *                             try setting the convexity parameter.
 * @param Number [twist] - The number of degrees of through which the shape is extruded.
 * @param Number [slices] - Defines the number of intermediate points along the Z axis
 *                          of the extrusion.
 * @param Number|Vector [scale] - Scales the 2D shape by this value over the height of
 *                                the extrusion.
 */
module negativeExtrude(height, direction, center, convexity, twist, slices, scale) {
    center = boolean(center);
    convexity = numberOr(convexity, 10);
    height = align(value=height, direction=direction, center=center);

    translateZ(height[1]) {
        linear_extrude(height=height[0], center=center, convexity=convexity, twist=twist, slices=slices, scale=scale) {
            children();
        }
    }
}


units: add basic definition of units (mm, cm etc)

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


Add a piece to link two potentiometer to make "gimbal measurement"

use <MCAD/nuts_and_bolts.scad>

guiding_length = 10;
x = 2;
space = 15;

difference(){
union(){
	hull(){
	translate([space +guiding_length/2,0,0]) cube(size=[15,10,guiding_length], center = true);
	translate([x, 0, x]) sphere(3);
	}

	hull(){
		translate([0,0,space+guiding_length/2]) rotate([0,90,0])cube(size=[15,10,guiding_length], center = true);
		translate([x, 0, x]) sphere(3);
	}
}

	translate([space +guiding_length/2,0,0]) cylinder(r=3.25, h=10*guiding_length, center = true);
	translate([0,0,space+guiding_length/2]) rotate([0,90,0])cylinder(r=3.25, h=10*guiding_length, center = true);

//space for nut
	rotate([0,-90,0])
union(){translate([space +guiding_length/2+4.5,0, 0]) rotate([0,90,0]) translate([0,0,-1.25])  nutHole(3);
 translate([space +guiding_length/2+2.5,0, 0]) rotate([0,90,0]) translate([0,0,-1.25]) nutHole(3);

	translate([space +guiding_length/2+5,0, 0]) rotate([0,90,0]) cylinder(r=1.5, h=15, center=true);}

	translate([space +guiding_length/2+4.5,0, 0]) rotate([0,90,0]) translate([0,0,-1.25])  nutHole(3);
	translate([space +guiding_length/2+2.5,0, 0]) rotate([0,90,0]) translate([0,0,-1.25])  nutHole(3);
	translate([space +guiding_length/2+5,0, 0]) rotate([0,90,0]) cylinder(r=1.5, h=15, center=true);

//Cube to visualize
	//cube(space +guiding_length/2+7);

}

//cube(size=[sqrt(guiding_length

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


The trooper icon was added.

The trooper icon was added.

// ************* Credits part *************

//  This was origianllay named uploads-b4-df-a6-25-4b-AnyNameSign.scad and came from
//
//		http://www.thingiverse.com/thing:16193
//
//  Programmed by Fryns - March 2014

// Adapted by Roberto Marquez - onebeartoe - 2015

// Uses Write.scad by HarlanDMii, published on Thingiverse 18-Jan-2012 (thing:16193)

// ************* Declaration part *************

/* [General] */
textColor = "red"; // [pink, red, black, white, yellow, blue]
letterThickness = 2; // [1 : 15]

/* [Top Text] */
topText = "Roberto";
topTextYOffset = 5; // [0 : 30]
topLetterSize = 14; // [2 : 25]

/* [Sub Text] */
subText = "Rebel Scum";
bottomLetterSize = 8; // [2 : 25]

/* [Border] */
showBorder = "Yes"; // [Yes, No]
borderColor = "red"; // [pink, red, black, white, yellow, blue]

/* [Base] */
// This determines how wide the name tag is.
baseWidth=228;	// [228:600]

// This determines the hieght of the nametag.
baseHeight=54;	// [54:150]

// This parameter is all about that base color.
baseColor = "black"; // [pink, red, black, white, yellow, blue]

/* [Icons] */
iconType = "Rebel"; // [Rebel, Trooper]
// This is the X,Y scale of the icons.
iconXyScale = 0.12; // [0.1 : 0.05 : 5]
iconHeight = 1.5; // [0.1: 0.1 :5]
xOffset = 80; // [10:200]
iconColor = "red"; // [pink, red, black, white, yellow, blue]

/* [Hidden] */

resolution=50; 	// Use 20 for draft 100 for nice

baseThickness=2;

borderWidth=2;
borderradius=8;
borderdistance=5;	// Distance from edge

holediameter=3;
countersink=2;
holes=4; 			// Choose 0,2 or 4 (others=0)

font="write/orbitron.dxf"; 		// BlackRose.dxf, orbitron.dxf, Letters.dxf

namematrix =
[					 	  // Matrix with place and names - add as many rows as you like
	[ 5, topText,     topLetterSize],	      //[Y-placement, "Name"],      note: Y-placement of center of text
	[-10, subText,  bottomLetterSize],	  //[Y-placement, "Name"]      note: Y-placement of center of text
];

// ************* Executable part *************
use <write/Write.scad>	// remember to download write.scad and fonts

union()
{
    nametag_assembly();

    icons();
}

// *************  Nametag Modules *************

module nametag_assembly()
{
	color(textColor)
	writing();

	if(showBorder == "Yes")
	{
		color(borderColor)
		nametagBorder();
	}

	if (holes==2)
	{
		base2holes();
	}
	else
	{
		if (holes==4) base4holes();
		else nametagBase();
	}
}

module writing()
{
	// max 100 names
	for ( i = [0 : 99] )
	{
		if (namematrix[i][0]==undef)
		{
			;	// then do nothing
		}
		else
		{

			translate([0,namematrix[i][0],baseThickness+letterThickness/2])
			write(namematrix[i][1],
			      t = letterThickness,
			      h = namematrix[i][2],
			      center = true,
			      font = font);
		}
	}
}

module base2holes()
{
	difference()
	{
		nametagBase();
		translate([-(baseWidth/2-borderdistance*2-borderWidth-countersink-holediameter),0,0])
			nametagHole();
		translate([(baseWidth/2-borderdistance*2-borderWidth-countersink-holediameter),(0),0])
			nametagHole();
	}
}

module base4holes()
{
	difference()
	{
		nametagBase();
		translate([(baseWidth/2-borderdistance),(baseHeight/2-borderdistance),0])
			nametagHole();
		translate([(baseWidth/2-borderdistance),-(baseHeight/2-borderdistance),0])
			nametagHole();
		translate([-(baseWidth/2-borderdistance),(baseHeight/2-borderdistance),0])
			nametagHole();
		translate([-(baseWidth/2-borderdistance),-(baseHeight/2-borderdistance),0])
			nametagHole();
	}
}

module oneIcon(xOffset)
{
    color(iconColor)
    translate([xOffset, 0, 0])
    scale([iconXyScale, iconXyScale, iconHeight])
    if(iconType == "Rebel")
    {
        rebelAlliance(6);
    }
    else if(iconType == "Trooper")
    {
        scrumtrooper(2);
    }

}

module icons()
{
    // left icon
    oneIcon(xOffset=-xOffset);

    // right icon
    oneIcon(xOffset=xOffset);
}

module nametagBase()
{
    color(baseColor)
	translate([0,0,baseThickness/2])
		cube(size = [baseWidth,baseHeight,baseThickness], center = true);
}

module nametagBorder()
{
	translate([0,0,baseThickness+letterThickness/2])
	linear_extrude(height = letterThickness, center = true, convexity = 10, twist = 0){
		translate([0,baseHeight/2-borderdistance,0])
			square ([baseWidth-borderdistance*2-borderradius*2+borderWidth*2,borderWidth],center = true);
		translate([0,-(baseHeight/2-borderdistance),0])
			square ([baseWidth-borderdistance*2-borderradius*2+borderWidth*2,borderWidth],center = true);
		translate([baseWidth/2-borderdistance,0,0])
			square ([borderWidth, baseHeight-borderdistance*2-borderradius*2+borderWidth*2,],center = true);
		translate([-(baseWidth/2-borderdistance),0,0])
			square ([borderWidth, baseHeight-borderdistance*2-borderradius*2+borderWidth*2,],center = true);

		translate([-(baseWidth/2-borderdistance),-(baseHeight/2-borderdistance),0])
			rotate(a=[0,0,0])
				nametagQuarter();
		translate([(baseWidth/2-borderdistance),(baseHeight/2-borderdistance),0])
			rotate(a=[0,0,180])
				nametagQuarter();
		translate([(baseWidth/2-borderdistance),-(baseHeight/2-borderdistance),0])
			rotate(a=[0,0,90])
				nametagQuarter();
		translate([-(baseWidth/2-borderdistance),(baseHeight/2-borderdistance),0])
			rotate(a=[0,0,270])
				nametagQuarter();
	}
}

module nametagQuarter()
{
	intersection()
	{
		difference()
		{
			circle(r = borderradius, center=true, $fn=resolution);
			circle(r = borderradius-borderWidth, center=true, $fn=resolution);
		}
		square ([borderradius+1, borderradius+1],center = false);
	}
}

module nametagHole()
{
	translate([0,0,baseThickness/2])
		cylinder(h = baseThickness+0.1, r = holediameter/2, $fn=resolution, center = true);
	translate([0,0,baseThickness-countersink])
		cylinder(h = countersink+0.1, r1 = holediameter/2, r2 = (holediameter+2*countersink)/2, $fn=resolution, center = false);
}

// *************  External Modules *************

module rebelAlliancePolySelection(h)
{
  scale([25.4/90, -25.4/90, 1]) union()
  {
    linear_extrude(height=h)
      polygon([[-140.090000,-711.580000],[-168.890000,-761.580000],[-175.158750,-770.355000],[-177.866094,-775.380938],[-178.460449,-777.642539],[-178.300000,-779.580000],[-176.323281,-782.664844],[-172.671250,-787.076250],[-165.910000,-794.580000],[-141.260000,-822.580000],[-46.120000,-930.580000],[-15.260000,-965.580000],[-9.823750,-971.838750],[-6.461094,-975.014531],[-3.750000,-976.380000],[-0.790781,-975.056719],[2.591250,-971.951250],[8.160000,-965.580000],[37.210000,-932.580000],[132.310000,-824.580000],[159.580000,-793.580000],[165.318750,-787.233750],[168.227031,-783.560469],[169.760000,-780.580000],[168.965313,-776.953438],[166.357500,-772.050000],[160.840000,-763.580000],[137.270000,-720.580000],[122.320000,-687.783281],[109.305000,-654.188750],[103.666094,-637.090254],[98.682500,-619.789844],[94.411406,-602.286699],[90.910000,-584.580000],[86.740000,-555.580000],[85.621250,-545.956250],[85.526406,-540.967656],[86.160000,-536.580000],[91.107500,-545.540938],[98.770000,-556.030000],[114.080000,-574.580000],[124.538477,-586.564258],[135.531562,-598.184063],[158.867500,-620.312500],[183.579687,-640.929688],[209.160000,-660.000000],[242.160000,-681.180000],[249.055000,-685.315000],[253.030312,-687.173438],[256.160000,-687.710000],[258.689531,-686.539531],[261.163750,-684.353750],[265.320000,-679.580000],[285.000000,-657.580000],[339.230000,-596.580000],[356.160000,-577.580000],[362.718750,-570.368750],[365.836406,-566.427031],[368.160000,-562.580000],[357.375859,-558.414766],[346.266875,-553.353750],[323.815000,-541.187500],[302.285625,-527.367500],[283.160000,-513.180000],[269.431836,-501.715566],[256.181563,-489.647031],[243.460508,-476.992793],[231.320000,-463.771250],[219.811367,-450.000801],[208.985937,-435.699844],[198.895039,-420.886777],[189.590000,-405.580000],[179.976875,-387.207969],[171.365000,-367.893750],[163.675625,-348.172656],[156.830000,-328.580000],[148.449844,-301.275781],[141.373750,-273.661250],[135.540781,-245.756094],[130.890000,-217.580000],[126.070000,-169.580000],[125.160000,-157.580000],[125.160000,-112.580000],[126.070000,-100.580000],[130.910000,-56.580000],[134.238149,-38.871221],[138.342695,-21.206797],[143.251909,-3.690850],[148.994063,13.572500],[155.597427,30.479131],[163.090273,46.924922],[171.500874,62.805752],[180.857500,78.017500],[191.188423,92.456045],[202.521914,106.017266],[214.886245,118.597041],[228.309688,130.091250],[242.820513,140.395771],[258.446992,149.406484],[275.217397,157.019268],[293.160000,163.130000],[315.028750,167.990000],[326.818594,169.694375],[337.160000,170.420000],[359.307383,169.551621],[380.936562,166.534844],[402.035586,161.539707],[422.592500,154.736250],[442.595352,146.294512],[462.032188,136.384531],[480.891055,125.176348],[499.160000,112.840000],[520.271250,96.973750],[531.499531,87.964844],[540.160000,80.380000],[553.044219,67.199219],[566.126250,52.401250],[578.692656,37.102656],[590.030000,22.420000],[610.259473,-6.374434],[628.792656,-36.459219],[645.531699,-67.682832],[660.378750,-99.893750],[673.235957,-132.940449],[684.005469,-166.671406],[692.589434,-200.935098],[698.890000,-235.580000],[703.250000,-278.580000],[704.160000,-290.580000],[704.160000,-339.580000],[703.250000,-349.580000],[698.430000,-395.580000],[695.232402,-415.143770],[691.295469,-434.775156],[686.665488,-454.395527],[681.388750,-473.926250],[675.511543,-493.288691],[669.080156,-512.404219],[654.740000,-549.580000],[637.470000,-587.580000],[626.562285,-609.956113],[614.280781,-632.755156],[600.879199,-655.711934],[586.611250,-678.561250],[571.730645,-701.037910],[556.491094,-722.876719],[525.950000,-763.580000],[493.070000,-803.580000],[490.134844,-806.846719],[486.733750,-811.518750],[485.844902,-813.644355],[486.023281,-815.236406],[487.663457,-815.999941],[491.160000,-815.640000],[496.848750,-813.647813],[502.207500,-810.622500],[512.160000,-803.430000],[545.160000,-778.950000],[578.029844,-753.726875],[610.261250,-727.675000],[641.692031,-700.678125],[672.160000,-672.620000],[701.120000,-644.580000],[720.731309,-623.489277],[739.709219,-601.861719],[758.018457,-579.692988],[775.623750,-556.978750],[792.489824,-533.714668],[808.581406,-509.896406],[823.863223,-485.519629],[838.300000,-460.580000],[856.918223,-424.955527],[873.757656,-388.501719],[888.874199,-351.311738],[902.323750,-313.478750],[914.162207,-275.095918],[924.445469,-236.256406],[933.229434,-197.053379],[940.570000,-157.580000],[944.501562,-132.125000],[947.842500,-106.677500],[953.330000,-55.580000],[956.840000,-4.580000],[956.160000,5.420000],[956.160000,20.420000],[955.160000,34.420000],[953.250000,66.420000],[951.004844,94.030625],[948.068750,121.555000],[944.470781,149.011875],[940.240000,176.420000],[933.811047,211.725286],[926.243691,246.805410],[917.533435,281.612400],[907.675781,316.098281],[896.666233,350.215081],[884.500293,383.914824],[871.173464,417.149539],[856.681250,449.871250],[841.019153,482.031985],[824.182676,513.583770],[806.167322,544.478630],[786.968594,574.668594],[766.581995,604.105686],[745.003027,632.741934],[722.227195,660.529363],[698.250000,687.420000],[656.160000,730.330000],[633.958083,750.351604],[611.220137,769.549395],[587.957864,787.918464],[564.182969,805.453906],[539.907156,822.150813],[515.142129,838.004277],[489.899592,853.009392],[464.191250,867.161250],[438.028806,880.454944],[411.423965,892.885566],[384.388430,904.448210],[356.933906,915.137969],[329.072097,924.949934],[300.814707,933.879199],[272.173440,941.920857],[243.160000,949.070000],[210.345781,956.090156],[178.001250,961.948750],[145.486094,966.747969],[112.160000,970.590000],[74.160000,973.510000],[64.160000,974.420000],[46.160000,975.420000],[26.160000,975.420000],[9.160000,976.380000],[-7.840000,976.380000],[-17.840000,975.420000],[-36.840000,975.420000],[-55.840000,974.420000],[-65.840000,973.510000],[-109.941250,969.558750],[-153.840000,963.500000],[-181.026191,958.615820],[-208.065781,952.980938],[-234.934043,946.588086],[-261.606250,939.430000],[-288.057676,931.499414],[-314.263594,922.789062],[-340.199277,913.291680],[-365.840000,903.000000],[-390.045730,892.449340],[-413.868069,881.279253],[-437.298800,869.500076],[-460.329707,857.122148],[-482.952575,844.155807],[-505.159187,830.611392],[-526.941328,816.499239],[-548.290781,801.829687],[-569.199331,786.613076],[-589.658762,770.859741],[-609.660858,754.580023],[-629.197402,737.784258],[-648.260180,720.482785],[-666.840974,702.685942],[-684.931570,684.404068],[-702.523750,665.647500],[-719.609300,646.426577],[-736.180002,626.751636],[-752.227643,606.633016],[-767.744004,586.081055],[-782.720871,565.106091],[-797.150027,543.718462],[-811.023257,521.928506],[-824.332344,499.746562],[-837.069073,477.182968],[-849.225227,454.248062],[-860.792591,430.952181],[-871.762949,407.305664],[-882.128085,383.318849],[-891.879783,359.002075],[-901.009826,334.365679],[-909.510000,309.420000],[-922.527812,266.043437],[-933.425000,222.342500],[-942.267188,178.180313],[-949.120000,133.420000],[-954.880000,73.420000],[-955.840000,62.420000],[-956.840000,42.420000],[-956.840000,-27.580000],[-955.840000,-47.580000],[-954.930000,-57.580000],[-951.086250,-100.166250],[-945.420000,-142.580000],[-940.506765,-171.172578],[-934.683027,-199.589375],[-927.963362,-227.806484],[-920.362344,-255.800000],[-911.894548,-283.546016],[-902.574551,-311.020625],[-892.416926,-338.199922],[-881.436250,-365.060000],[-869.647097,-391.576953],[-857.064043,-417.726875],[-843.701663,-443.485859],[-829.574531,-468.830000],[-814.697224,-493.735391],[-799.084316,-518.178125],[-782.750383,-542.134297],[-765.710000,-565.580000],[-746.478594,-590.558750],[-726.466250,-615.035000],[-705.608281,-638.783750],[-683.840000,-661.580000],[-649.840000,-695.490000],[-624.482969,-718.357344],[-598.513750,-740.383750],[-571.957656,-761.703281],[-544.840000,-782.450000],[-509.840000,-806.910000],[-505.204844,-810.186719],[-500.958750,-812.821250],[-496.403281,-814.167656],[-490.840000,-813.580000],[-493.135937,-808.834063],[-496.292500,-804.547500],[-503.410000,-796.580000],[-527.370000,-766.580000],[-545.513594,-741.598750],[-562.906250,-716.077500],[-579.543281,-690.057500],[-595.420000,-663.580000],[-613.111660,-631.683555],[-629.933906,-598.377813],[-645.653887,-563.941914],[-660.038750,-528.655000],[-672.855645,-492.796211],[-683.871719,-456.644688],[-692.854121,-420.479570],[-699.570000,-384.580000],[-705.930000,-326.580000],[-706.840000,-314.580000],[-706.840000,-266.580000],[-705.930000,-256.580000],[-702.110000,-218.580000],[-698.663379,-197.623223],[-694.453281,-177.287656],[-689.460605,-157.452949],[-683.666250,-137.998750],[-677.051113,-118.804707],[-669.596094,-99.750469],[-661.282090,-80.715684],[-652.090000,-61.580000],[-643.329219,-45.053594],[-633.836250,-28.833750],[-623.730156,-12.987031],[-613.130000,2.420000],[-600.017656,20.202812],[-586.298750,37.507500],[-571.925469,54.268438],[-556.850000,70.420000],[-547.800000,80.250000],[-537.114375,89.716094],[-525.562500,98.911250],[-501.840000,115.750000],[-479.450332,129.625664],[-455.821406,142.040937],[-431.182090,152.569492],[-418.555056,156.993022],[-405.761250,160.785000],[-392.829280,163.892134],[-379.787754,166.261133],[-366.665281,167.838706],[-353.490469,168.571562],[-340.291926,168.406411],[-327.098262,167.289961],[-313.938083,165.168921],[-300.840000,161.990000],[-286.895781,157.404219],[-273.391250,151.748750],[-260.361094,145.071406],[-247.840000,137.420000],[-233.948125,127.287500],[-219.745000,115.242500],[-206.411875,102.286250],[-195.130000,89.420000],[-187.927129,79.332539],[-180.885156,67.705938],[-174.107793,54.965117],[-167.698750,41.535000],[-156.400469,14.306563],[-147.820000,-10.580000],[-141.899351,-31.653450],[-137.075898,-52.750410],[-133.323013,-73.860173],[-130.614063,-94.972031],[-128.922417,-116.075276],[-128.221445,-137.159199],[-128.484517,-158.213093],[-129.685000,-179.226250],[-131.796265,-200.187961],[-134.791680,-221.087520],[-138.644614,-241.914216],[-143.328438,-262.657344],[-148.816519,-283.306194],[-155.082227,-303.850059],[-162.098931,-324.278230],[-169.840000,-344.580000],[-192.590000,-394.580000],[-200.620000,-411.580000],[-207.818438,-424.276250],[-216.110000,-436.987500],[-225.069063,-449.245000],[-234.270000,-460.580000],[-249.188574,-476.868008],[-265.131719,-492.146563],[-282.001816,-506.414961],[-299.701250,-519.672500],[-318.132402,-531.918477],[-337.197656,-543.152188],[-356.799395,-553.372930],[-376.840000,-562.580000],[-372.461406,-569.012500],[-365.481250,-577.110000],[-352.120000,-591.580000],[-291.560000,-658.580000],[-271.560000,-680.580000],[-267.217500,-685.145000],[-264.576563,-687.048750],[-261.840000,-687.880000],[-258.625781,-687.084844],[-254.306250,-685.111250],[-246.840000,-681.000000],[-212.840000,-659.860000],[-188.704687,-641.748750],[-165.842500,-622.092500],[-144.296563,-601.000000],[-124.110000,-578.580000],[-93.840000,-538.580000],[-94.814219,-559.930605],[-97.593125,-582.091094],[-101.961094,-604.695723],[-107.702500,-627.378750],[-114.601719,-649.774434],[-122.443125,-671.517031],[-131.011094,-692.240801],[-140.090000,-711.580000]]);
  }
}

module rebelAlliance(h)
{
    scale(0.4, 0.4, 1)
    rebelAlliancePolySelection(h);
}

module scrumtrooper_poly_Selection(h)
{
  scale([25.4/90, -25.4/90, 1]) union()
  {
    linear_extrude(height=h)
      polygon([[-33.094424,-44.902344],[-25.219053,-51.135742],[-16.283955,-55.413281],[-6.691904,-57.734727],[3.154326,-58.099844],[12.851963,-56.508398],[21.998232,-52.960156],[30.190361,-47.454883],[33.802756,-43.968286],[37.025576,-39.992344],[40.318232,-33.900469],[42.396826,-27.062344],[43.487295,-19.939219],[43.815576,-12.992344],[16.815576,-20.552344],[0.885889,-21.888125],[-14.321924,-20.821094],[-29.210986,-17.479687],[-44.184424,-11.992344],[-43.358643,-21.146563],[-41.830674,-29.628594],[-38.707080,-37.520000],[-36.267725,-41.269707],[-33.094424,-44.902344]]);
    linear_extrude(height=h)
      polygon([[20.815576,1.937656],[26.856826,4.863906],[31.825576,7.707656],[33.005947,10.129336],[33.292295,12.911719],[32.819971,15.867070],[31.724326,18.807656],[28.204482,23.893594],[26.050986,25.663477],[23.815576,26.667656],[21.526357,26.542969],[19.391826,25.355156],[15.815576,22.017656],[8.953076,15.842656],[4.950889,13.324219],[0.815576,12.157656],[-3.940049,12.919531],[-8.414424,15.305156],[-12.453799,18.587031],[-15.904424,22.037656],[-19.470674,25.787656],[-21.637705,26.959531],[-24.184424,26.837656],[-26.283604,25.711230],[-28.302861,23.918125],[-31.631924,18.983906],[-33.232236,13.339062],[-33.090557,10.657676],[-32.164424,8.287656],[-30.441924,6.566250],[-28.126924,5.458906],[-22.184424,2.877656],[-17.192236,-0.728125],[-13.071924,-4.518594],[-9.007861,-8.145938],[-4.184424,-11.262344],[0.224365,-11.826777],[3.853389,-11.335938],[6.909131,-10.001113],[9.598076,-8.033594],[14.701514,-3.045625],[20.815576,1.937656]]);
    difference()
    {
       linear_extrude(height=h)
         polygon([[-52.144424,33.007656],[-52.736143,30.722500],[-52.565674,28.496406],[-51.404424,24.007656],[-49.066924,16.367656],[-47.044424,11.007656],[-45.736924,1.875156],[-44.136299,-1.848281],[-42.534893,-3.493555],[-40.184424,-4.992344],[-37.836924,-0.649844],[-36.947236,1.749219],[-36.704424,4.007656],[-37.693018,6.902031],[-39.513174,9.507656],[-41.323955,12.113281],[-42.284424,15.007656],[-41.150518,19.141719],[-38.050674,24.012656],[-31.094424,31.817656],[-27.954424,34.111406],[-26.180986,34.620312],[-24.184424,34.417656],[-21.906201,33.335020],[-19.520518,31.569063],[-14.300674,26.958906],[-8.272705,22.530625],[-4.876865,20.992012],[-1.184424,20.227656],[4.007451,20.756719],[8.648076,22.802656],[12.872451,25.793594],[16.815576,29.157656],[20.948076,32.712656],[23.360264,34.135781],[25.815576,34.617656],[28.609639,33.526875],[31.660576,31.163906],[36.605576,26.007656],[39.459326,22.172656],[41.705576,18.007656],[42.146260,15.846992],[41.961045,13.993594],[40.344326,10.900156],[38.118232,8.110469],[36.545576,5.007656],[36.600889,2.622500],[37.475576,-0.048594],[39.815576,-4.992344],[42.963076,-3.616094],[45.075576,-0.882344],[47.075576,12.007656],[51.106826,22.205156],[52.628857,27.723906],[52.736143,30.363516],[52.205576,32.837656],[50.927139,34.908281],[48.983076,36.915156],[44.905576,40.437656],[40.598076,44.997656],[36.815576,50.007656],[37.815576,51.007656],[47.815576,43.007656],[41.753076,51.403906],[37.898701,55.201250],[33.815576,57.497656],[28.674014,58.062031],[23.643076,57.137656],[13.815576,53.927656],[2.815576,52.177656],[-6.266924,52.541406],[-15.184424,54.367656],[-25.053174,57.572656],[-30.134268,58.099844],[-35.184424,56.847656],[-38.693486,54.471562],[-41.904424,51.196406],[-47.184424,44.007656],[-37.184424,50.007656],[-42.448330,43.177656],[-46.723174,38.950156],[-49.968643,36.001406],[-52.144424,33.007656]]);
       translate([0, 0, -fudge])
         linear_extrude(height=h+2*fudge)
           polygon([[-46.184424,24.007656],[-39.184424,34.007656],[-34.184424,33.007656],[-36.198643,29.399219],[-38.838174,26.370156],[-42.150830,24.409844],[-46.184424,24.007656]]);
       translate([0, 0, -fudge])
         linear_extrude(height=h+2*fudge)
           polygon([[33.815576,33.007656],[38.815576,34.007656],[46.815576,24.007656],[42.582139,24.176406],[39.033076,26.152656],[36.125264,29.306406],[33.815576,33.007656]]);
       translate([0, 0, -fudge])
         linear_extrude(height=h+2*fudge)
           polygon([[31.595576,51.217656],[33.840889,49.183906],[34.460576,46.062656],[34.007881,44.499687],[32.965264,43.151406],[31.271553,42.180000],[28.865576,41.747656],[26.638838,43.402676],[25.479795,45.194687],[25.221455,46.987871],[25.696826,48.646406],[28.180732,51.016250],[29.855283,51.455918],[31.595576,51.217656]]);
    }
    linear_extrude(height=h)
      polygon([[-47.184424,43.007656],[-50.184424,40.007656],[-47.184424,43.007656]]);
  }
}

module scrumtrooper(h)
{
    scrumtrooper_poly_Selection(h);
}

// ************* Credits part *************

//  This was origianllay named uploads-b4-df-a6-25-4b-AnyNameSign.scad and came from
//
//		http://www.thingiverse.com/thing:16193
//
//  Programmed by Fryns - March 2014

// Adapted by Roberto Marquez - onebeartoe - 2015

// Uses Write.scad by HarlanDMii, published on Thingiverse 18-Jan-2012 (thing:16193)

// ************* Declaration part *************

/* [General] */
textColor = "red"; // [pink, red, yellow, black, blue]
letterThickness = 2; // [1 : 15]

/* [Top Text] */
topText = "Roberto";
topTextYOffset = 5; // [0 : 30]
topLetterSize = 14; // [2 : 25]

/* [Sub Text] */
subText = "Rebel Scum";
bottomLetterSize = 8; // [2 : 25]

/* [Border] */
showBorder = "Yes"; // [Yes, No]
borderColor = "red"; // [red, black, white, yellow, blue]

/* [Base] */
// This determines how wide the name tag is.
baseWidth=228;	// [228:600]

// This determines the hieght of the nametag.
baseHeight=54;	// [54:150]

// This parameter is all about that base color.
baseColor = "black"; // [pink, red, yellow, black, blue]

/* [Icons] */
// This is the X,Y scale of the icons.
iconXyScale = 0.12; // [0.1 : 0.05 : 5]
iconHeight = 1.5; // [0.1: 0.1 :5]
xOffset = 80; // [10:200]
iconColor = "red"; // [red, black, white, yellow, blue, pink]

/* [Hidden] */

resolution=50; 	// Use 20 for draft 100 for nice

baseThickness=2;

borderWidth=2;
borderradius=8;
borderdistance=5;	// Distance from edge

holediameter=3;
countersink=2;
holes=4; 			// Choose 0,2 or 4 (others=0)

font="write/orbitron.dxf"; 		// BlackRose.dxf, orbitron.dxf, Letters.dxf

namematrix =
[					 	  // Matrix with place and names - add as many rows as you like
	[ 5, topText,     topLetterSize],	      //[Y-placement, "Name"],      note: Y-placement of center of text
	[-10, subText,  bottomLetterSize],	  //[Y-placement, "Name"]      note: Y-placement of center of text
];

// ************* Executable part *************
use <write/Write.scad>	// remember to download write.scad and fonts

union()
{
    nametag_assembly();

    icons();
}

// *************  Nametag Modules *************

module nametag_assembly()
{
	color(textColor)
	writing();

	if(showBorder == "Yes")
	{
		color(borderColor)
		nametagBorder();
	}

	if (holes==2)
	{
		base2holes();
	}
	else
	{
		if (holes==4) base4holes();
		else nametagBase();
	}
}

module writing()
{
	// max 100 names
	for ( i = [0 : 99] )
	{
		if (namematrix[i][0]==undef)
		{
			;	// then do nothing
		}
		else
		{

			translate([0,namematrix[i][0],baseThickness+letterThickness/2])
			write(namematrix[i][1],
			      t = letterThickness,
			      h = namematrix[i][2],
			      center = true,
			      font = font);
		}
	}
}

module base2holes()
{
	difference()
	{
		nametagBase();
		translate([-(baseWidth/2-borderdistance*2-borderWidth-countersink-holediameter),0,0])
			nametagHole();
		translate([(baseWidth/2-borderdistance*2-borderWidth-countersink-holediameter),(0),0])
			nametagHole();
	}
}

module base4holes()
{
	difference()
	{
		nametagBase();
		translate([(baseWidth/2-borderdistance),(baseHeight/2-borderdistance),0])
			nametagHole();
		translate([(baseWidth/2-borderdistance),-(baseHeight/2-borderdistance),0])
			nametagHole();
		translate([-(baseWidth/2-borderdistance),(baseHeight/2-borderdistance),0])
			nametagHole();
		translate([-(baseWidth/2-borderdistance),-(baseHeight/2-borderdistance),0])
			nametagHole();
	}
}

module oneIcon(xOffset)
{
    color(iconColor)
    translate([xOffset, 0, 0])
    scale([iconXyScale, iconXyScale, iconHeight])
    rebelAlliance(6);
}

module icons()
{
    // left icon
    oneIcon(xOffset=-xOffset);

    // right icon
    oneIcon(xOffset=xOffset);
}

module nametagBase()
{
    color(baseColor)
	translate([0,0,baseThickness/2])
		cube(size = [baseWidth,baseHeight,baseThickness], center = true);
}

module nametagBorder()
{
	translate([0,0,baseThickness+letterThickness/2])
	linear_extrude(height = letterThickness, center = true, convexity = 10, twist = 0){
		translate([0,baseHeight/2-borderdistance,0])
			square ([baseWidth-borderdistance*2-borderradius*2+borderWidth*2,borderWidth],center = true);
		translate([0,-(baseHeight/2-borderdistance),0])
			square ([baseWidth-borderdistance*2-borderradius*2+borderWidth*2,borderWidth],center = true);
		translate([baseWidth/2-borderdistance,0,0])
			square ([borderWidth, baseHeight-borderdistance*2-borderradius*2+borderWidth*2,],center = true);
		translate([-(baseWidth/2-borderdistance),0,0])
			square ([borderWidth, baseHeight-borderdistance*2-borderradius*2+borderWidth*2,],center = true);

		translate([-(baseWidth/2-borderdistance),-(baseHeight/2-borderdistance),0])
			rotate(a=[0,0,0])
				nametagQuarter();
		translate([(baseWidth/2-borderdistance),(baseHeight/2-borderdistance),0])
			rotate(a=[0,0,180])
				nametagQuarter();
		translate([(baseWidth/2-borderdistance),-(baseHeight/2-borderdistance),0])
			rotate(a=[0,0,90])
				nametagQuarter();
		translate([-(baseWidth/2-borderdistance),(baseHeight/2-borderdistance),0])
			rotate(a=[0,0,270])
				nametagQuarter();
	}
}

module nametagQuarter()
{
	intersection()
	{
		difference()
		{
			circle(r = borderradius, center=true, $fn=resolution);
			circle(r = borderradius-borderWidth, center=true, $fn=resolution);
		}
		square ([borderradius+1, borderradius+1],center = false);
	}
}

module nametagHole()
{
	translate([0,0,baseThickness/2])
		cylinder(h = baseThickness+0.1, r = holediameter/2, $fn=resolution, center = true);
	translate([0,0,baseThickness-countersink])
		cylinder(h = countersink+0.1, r1 = holediameter/2, r2 = (holediameter+2*countersink)/2, $fn=resolution, center = false);
}

// *************  External Modules *************

module rebelAlliancePolySelection(h)
{
  scale([25.4/90, -25.4/90, 1]) union()
  {
    linear_extrude(height=h)
      polygon([[-140.090000,-711.580000],[-168.890000,-761.580000],[-175.158750,-770.355000],[-177.866094,-775.380938],[-178.460449,-777.642539],[-178.300000,-779.580000],[-176.323281,-782.664844],[-172.671250,-787.076250],[-165.910000,-794.580000],[-141.260000,-822.580000],[-46.120000,-930.580000],[-15.260000,-965.580000],[-9.823750,-971.838750],[-6.461094,-975.014531],[-3.750000,-976.380000],[-0.790781,-975.056719],[2.591250,-971.951250],[8.160000,-965.580000],[37.210000,-932.580000],[132.310000,-824.580000],[159.580000,-793.580000],[165.318750,-787.233750],[168.227031,-783.560469],[169.760000,-780.580000],[168.965313,-776.953438],[166.357500,-772.050000],[160.840000,-763.580000],[137.270000,-720.580000],[122.320000,-687.783281],[109.305000,-654.188750],[103.666094,-637.090254],[98.682500,-619.789844],[94.411406,-602.286699],[90.910000,-584.580000],[86.740000,-555.580000],[85.621250,-545.956250],[85.526406,-540.967656],[86.160000,-536.580000],[91.107500,-545.540938],[98.770000,-556.030000],[114.080000,-574.580000],[124.538477,-586.564258],[135.531562,-598.184063],[158.867500,-620.312500],[183.579687,-640.929688],[209.160000,-660.000000],[242.160000,-681.180000],[249.055000,-685.315000],[253.030312,-687.173438],[256.160000,-687.710000],[258.689531,-686.539531],[261.163750,-684.353750],[265.320000,-679.580000],[285.000000,-657.580000],[339.230000,-596.580000],[356.160000,-577.580000],[362.718750,-570.368750],[365.836406,-566.427031],[368.160000,-562.580000],[357.375859,-558.414766],[346.266875,-553.353750],[323.815000,-541.187500],[302.285625,-527.367500],[283.160000,-513.180000],[269.431836,-501.715566],[256.181563,-489.647031],[243.460508,-476.992793],[231.320000,-463.771250],[219.811367,-450.000801],[208.985937,-435.699844],[198.895039,-420.886777],[189.590000,-405.580000],[179.976875,-387.207969],[171.365000,-367.893750],[163.675625,-348.172656],[156.830000,-328.580000],[148.449844,-301.275781],[141.373750,-273.661250],[135.540781,-245.756094],[130.890000,-217.580000],[126.070000,-169.580000],[125.160000,-157.580000],[125.160000,-112.580000],[126.070000,-100.580000],[130.910000,-56.580000],[134.238149,-38.871221],[138.342695,-21.206797],[143.251909,-3.690850],[148.994063,13.572500],[155.597427,30.479131],[163.090273,46.924922],[171.500874,62.805752],[180.857500,78.017500],[191.188423,92.456045],[202.521914,106.017266],[214.886245,118.597041],[228.309688,130.091250],[242.820513,140.395771],[258.446992,149.406484],[275.217397,157.019268],[293.160000,163.130000],[315.028750,167.990000],[326.818594,169.694375],[337.160000,170.420000],[359.307383,169.551621],[380.936562,166.534844],[402.035586,161.539707],[422.592500,154.736250],[442.595352,146.294512],[462.032188,136.384531],[480.891055,125.176348],[499.160000,112.840000],[520.271250,96.973750],[531.499531,87.964844],[540.160000,80.380000],[553.044219,67.199219],[566.126250,52.401250],[578.692656,37.102656],[590.030000,22.420000],[610.259473,-6.374434],[628.792656,-36.459219],[645.531699,-67.682832],[660.378750,-99.893750],[673.235957,-132.940449],[684.005469,-166.671406],[692.589434,-200.935098],[698.890000,-235.580000],[703.250000,-278.580000],[704.160000,-290.580000],[704.160000,-339.580000],[703.250000,-349.580000],[698.430000,-395.580000],[695.232402,-415.143770],[691.295469,-434.775156],[686.665488,-454.395527],[681.388750,-473.926250],[675.511543,-493.288691],[669.080156,-512.404219],[654.740000,-549.580000],[637.470000,-587.580000],[626.562285,-609.956113],[614.280781,-632.755156],[600.879199,-655.711934],[586.611250,-678.561250],[571.730645,-701.037910],[556.491094,-722.876719],[525.950000,-763.580000],[493.070000,-803.580000],[490.134844,-806.846719],[486.733750,-811.518750],[485.844902,-813.644355],[486.023281,-815.236406],[487.663457,-815.999941],[491.160000,-815.640000],[496.848750,-813.647813],[502.207500,-810.622500],[512.160000,-803.430000],[545.160000,-778.950000],[578.029844,-753.726875],[610.261250,-727.675000],[641.692031,-700.678125],[672.160000,-672.620000],[701.120000,-644.580000],[720.731309,-623.489277],[739.709219,-601.861719],[758.018457,-579.692988],[775.623750,-556.978750],[792.489824,-533.714668],[808.581406,-509.896406],[823.863223,-485.519629],[838.300000,-460.580000],[856.918223,-424.955527],[873.757656,-388.501719],[888.874199,-351.311738],[902.323750,-313.478750],[914.162207,-275.095918],[924.445469,-236.256406],[933.229434,-197.053379],[940.570000,-157.580000],[944.501562,-132.125000],[947.842500,-106.677500],[953.330000,-55.580000],[956.840000,-4.580000],[956.160000,5.420000],[956.160000,20.420000],[955.160000,34.420000],[953.250000,66.420000],[951.004844,94.030625],[948.068750,121.555000],[944.470781,149.011875],[940.240000,176.420000],[933.811047,211.725286],[926.243691,246.805410],[917.533435,281.612400],[907.675781,316.098281],[896.666233,350.215081],[884.500293,383.914824],[871.173464,417.149539],[856.681250,449.871250],[841.019153,482.031985],[824.182676,513.583770],[806.167322,544.478630],[786.968594,574.668594],[766.581995,604.105686],[745.003027,632.741934],[722.227195,660.529363],[698.250000,687.420000],[656.160000,730.330000],[633.958083,750.351604],[611.220137,769.549395],[587.957864,787.918464],[564.182969,805.453906],[539.907156,822.150813],[515.142129,838.004277],[489.899592,853.009392],[464.191250,867.161250],[438.028806,880.454944],[411.423965,892.885566],[384.388430,904.448210],[356.933906,915.137969],[329.072097,924.949934],[300.814707,933.879199],[272.173440,941.920857],[243.160000,949.070000],[210.345781,956.090156],[178.001250,961.948750],[145.486094,966.747969],[112.160000,970.590000],[74.160000,973.510000],[64.160000,974.420000],[46.160000,975.420000],[26.160000,975.420000],[9.160000,976.380000],[-7.840000,976.380000],[-17.840000,975.420000],[-36.840000,975.420000],[-55.840000,974.420000],[-65.840000,973.510000],[-109.941250,969.558750],[-153.840000,963.500000],[-181.026191,958.615820],[-208.065781,952.980938],[-234.934043,946.588086],[-261.606250,939.430000],[-288.057676,931.499414],[-314.263594,922.789062],[-340.199277,913.291680],[-365.840000,903.000000],[-390.045730,892.449340],[-413.868069,881.279253],[-437.298800,869.500076],[-460.329707,857.122148],[-482.952575,844.155807],[-505.159187,830.611392],[-526.941328,816.499239],[-548.290781,801.829687],[-569.199331,786.613076],[-589.658762,770.859741],[-609.660858,754.580023],[-629.197402,737.784258],[-648.260180,720.482785],[-666.840974,702.685942],[-684.931570,684.404068],[-702.523750,665.647500],[-719.609300,646.426577],[-736.180002,626.751636],[-752.227643,606.633016],[-767.744004,586.081055],[-782.720871,565.106091],[-797.150027,543.718462],[-811.023257,521.928506],[-824.332344,499.746562],[-837.069073,477.182968],[-849.225227,454.248062],[-860.792591,430.952181],[-871.762949,407.305664],[-882.128085,383.318849],[-891.879783,359.002075],[-901.009826,334.365679],[-909.510000,309.420000],[-922.527812,266.043437],[-933.425000,222.342500],[-942.267188,178.180313],[-949.120000,133.420000],[-954.880000,73.420000],[-955.840000,62.420000],[-956.840000,42.420000],[-956.840000,-27.580000],[-955.840000,-47.580000],[-954.930000,-57.580000],[-951.086250,-100.166250],[-945.420000,-142.580000],[-940.506765,-171.172578],[-934.683027,-199.589375],[-927.963362,-227.806484],[-920.362344,-255.800000],[-911.894548,-283.546016],[-902.574551,-311.020625],[-892.416926,-338.199922],[-881.436250,-365.060000],[-869.647097,-391.576953],[-857.064043,-417.726875],[-843.701663,-443.485859],[-829.574531,-468.830000],[-814.697224,-493.735391],[-799.084316,-518.178125],[-782.750383,-542.134297],[-765.710000,-565.580000],[-746.478594,-590.558750],[-726.466250,-615.035000],[-705.608281,-638.783750],[-683.840000,-661.580000],[-649.840000,-695.490000],[-624.482969,-718.357344],[-598.513750,-740.383750],[-571.957656,-761.703281],[-544.840000,-782.450000],[-509.840000,-806.910000],[-505.204844,-810.186719],[-500.958750,-812.821250],[-496.403281,-814.167656],[-490.840000,-813.580000],[-493.135937,-808.834063],[-496.292500,-804.547500],[-503.410000,-796.580000],[-527.370000,-766.580000],[-545.513594,-741.598750],[-562.906250,-716.077500],[-579.543281,-690.057500],[-595.420000,-663.580000],[-613.111660,-631.683555],[-629.933906,-598.377813],[-645.653887,-563.941914],[-660.038750,-528.655000],[-672.855645,-492.796211],[-683.871719,-456.644688],[-692.854121,-420.479570],[-699.570000,-384.580000],[-705.930000,-326.580000],[-706.840000,-314.580000],[-706.840000,-266.580000],[-705.930000,-256.580000],[-702.110000,-218.580000],[-698.663379,-197.623223],[-694.453281,-177.287656],[-689.460605,-157.452949],[-683.666250,-137.998750],[-677.051113,-118.804707],[-669.596094,-99.750469],[-661.282090,-80.715684],[-652.090000,-61.580000],[-643.329219,-45.053594],[-633.836250,-28.833750],[-623.730156,-12.987031],[-613.130000,2.420000],[-600.017656,20.202812],[-586.298750,37.507500],[-571.925469,54.268438],[-556.850000,70.420000],[-547.800000,80.250000],[-537.114375,89.716094],[-525.562500,98.911250],[-501.840000,115.750000],[-479.450332,129.625664],[-455.821406,142.040937],[-431.182090,152.569492],[-418.555056,156.993022],[-405.761250,160.785000],[-392.829280,163.892134],[-379.787754,166.261133],[-366.665281,167.838706],[-353.490469,168.571562],[-340.291926,168.406411],[-327.098262,167.289961],[-313.938083,165.168921],[-300.840000,161.990000],[-286.895781,157.404219],[-273.391250,151.748750],[-260.361094,145.071406],[-247.840000,137.420000],[-233.948125,127.287500],[-219.745000,115.242500],[-206.411875,102.286250],[-195.130000,89.420000],[-187.927129,79.332539],[-180.885156,67.705938],[-174.107793,54.965117],[-167.698750,41.535000],[-156.400469,14.306563],[-147.820000,-10.580000],[-141.899351,-31.653450],[-137.075898,-52.750410],[-133.323013,-73.860173],[-130.614063,-94.972031],[-128.922417,-116.075276],[-128.221445,-137.159199],[-128.484517,-158.213093],[-129.685000,-179.226250],[-131.796265,-200.187961],[-134.791680,-221.087520],[-138.644614,-241.914216],[-143.328438,-262.657344],[-148.816519,-283.306194],[-155.082227,-303.850059],[-162.098931,-324.278230],[-169.840000,-344.580000],[-192.590000,-394.580000],[-200.620000,-411.580000],[-207.818438,-424.276250],[-216.110000,-436.987500],[-225.069063,-449.245000],[-234.270000,-460.580000],[-249.188574,-476.868008],[-265.131719,-492.146563],[-282.001816,-506.414961],[-299.701250,-519.672500],[-318.132402,-531.918477],[-337.197656,-543.152188],[-356.799395,-553.372930],[-376.840000,-562.580000],[-372.461406,-569.012500],[-365.481250,-577.110000],[-352.120000,-591.580000],[-291.560000,-658.580000],[-271.560000,-680.580000],[-267.217500,-685.145000],[-264.576563,-687.048750],[-261.840000,-687.880000],[-258.625781,-687.084844],[-254.306250,-685.111250],[-246.840000,-681.000000],[-212.840000,-659.860000],[-188.704687,-641.748750],[-165.842500,-622.092500],[-144.296563,-601.000000],[-124.110000,-578.580000],[-93.840000,-538.580000],[-94.814219,-559.930605],[-97.593125,-582.091094],[-101.961094,-604.695723],[-107.702500,-627.378750],[-114.601719,-649.774434],[-122.443125,-671.517031],[-131.011094,-692.240801],[-140.090000,-711.580000]]);
  }
}

module rebelAlliance(h)
{
    scale(0.4, 0.4, 1)
    rebelAlliancePolySelection(h);
}