zvodd
9/3/2016 - 10:04 AM

opjscad.org ecigboxmod

opjscad.org ecigboxmod

// title      : Rectangular Extrude
// author     : Rene K. Mueller
// license    : MIT License
// description: testing rectangular_extrude() function
// file       : boxmod.jscad

function main() {
    var batD = 19,
        batL = 35,
        fitD = 14,
        fitDT = fitD + 1,
        fith = 12,
        wallthick = 1,
        boxdepth = batD + (wallthick * 2),
        boxh = 50,
        boxw = 45;

    var boxY_Center = boxdepth / 2;

    var boxmain = CSG.cube({ // define two opposite corners
        corner1: [0, 0, 0],
        corner2: [boxw, boxdepth, boxh]
    });
    var atm_cutout = CSG.cube({ // define two opposite corners
        corner1: [0, 0, 0],
        corner2: [18, boxdepth, boxh - 5]
    }).translate([0, 0, boxh - (boxh - 15)]);


    var mainbody = difference(
                boxmain,
                atm_cutout)
    var fitting = cylinder({
                r: fitDT / 2,
                h: fith
            }).translate(
            [wallthick + (fitDT / 2),
                boxY_Center,
                wallthick + fith
            ])
    

    var battery = cylinder({
            r: batD / 2,
            h: batL
        })
        .translate(
            [(boxw - batD / 2) - wallthick,
                boxY_Center,
                wallthick *3
            ])
    return [
        battery.setColor([.2, .2, 88, .2]),
        fitting,
        mainbody.setColor([.7, .1, .1, 0.4]),
        
    ];
}