summaryrefslogtreecommitdiffstats
path: root/cad/assembly.py
blob: c8505323a7f83316966cd28a1e8b0de5225b91ac (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
from solid.solidpython import *
from solid.utils import *

from . import parameters


def motherboard_holes(datum=parameters.motherboard_datum):
    return [
        datum,
        [datum[0] + 45.72, datum[1]],
        [datum[0] + 203.2, datum[1] - 22.86],

        [datum[0] - 20.32, datum[1] - 154.94],
        [datum[0], datum[1] - 154.94],
        [datum[0] + 45.72, datum[1] - 154.94],
        [datum[0] + 203.2, datum[1] - 154.94],

        [datum[0] + 45.72, datum[1] - 227.33],
        [datum[0] + 203.2, datum[1] - 227.33],
    ]


def motherboard_hole_objects(datum=parameters.motherboard_datum):
    return union()([
        translate([h[0], h[1], 0])(cylinder(h=10, r=3.96/2, center=True))
        for h in motherboard_holes(datum)
    ])


def motherboard():
    hole_objects = motherboard_hole_objects()
    mb_size = parameters.motherboard_size
    board = cube(mb_size, center=True)
    return color(parameters.colors.motherboard)(render()(board - hole_objects))


def motherboard_support():
    plan_size = parameters.motherboard_support_size
    support = cube(plan_size, center=True)
    hmount = parameters.motherboard_support_mount_height
    support_mounts = union()([
        translate([h[0], h[1], plan_size[2]/2 + hmount/2])(
            difference()(
                cylinder(h=hmount, r=2.5, center=True),
                cylinder(h=hmount + 1, r=1.5, center=True),
            )
        )
        for h in motherboard_holes()
    ])
    support = support + support_mounts
    return color(parameters.colors.metal)(render()(support))


def main():
    #d = motherboard()
    d = motherboard_support()
    scad_render_to_file(d, 'assembly.scad',
                        include_orig_code=False)