Exemple #1
0
def volume():
    base = spu.up(base_height / 2.)(
        sp.cube([width, base_length, base_height], center=True)
    )

    mounting_holes = spu.down(1)(
        place_at_centres(
            [0, mounting_hole_centres],
            sp.cylinder(d=mounting_hole_diameter, h=base_height + 2)
        )
    )

    base -= mounting_holes

    bearing = spu.up(shaft_height)(
        sp.rotate([0, 90, 0])(
            sp.cylinder(d=60, h=width, center=True) -
            sp.cylinder(d=shaft_diameter, h=width + 1, center=True)
        )
    )

    return sp.union()(
        base,
        bearing,
    )
Exemple #2
0
def volume():
    width = light.mount_width + 20.

    body = sp.hull()(
        spu.up(1.)(sp.cube((width, thickness, 2.), center=True)),
        spu.up(height)(
            sp.rotate((0., 90., 0.))(
                sp.cylinder(d=thickness, h=width, center=True)
            )
        ),
    )

    cutout = spu.up(height)(
        sp.rotate((0., 90., 0.))(
            sp.union()(
                sp.cylinder(
                    d=thickness + 1., h=light.mount_width + 1., center=True
                ),
                sp.cylinder(d=light.mount_diameter, h=width + 1., center=True),
            )
        )
    )

    mounting_holes = sp.linear_extrude(15.)(holes())

    return body - cutout - mounting_holes()
Exemple #3
0
def open_top_box(shape, thickness):
    double_thickness = thickness * 2
    outer_shape = thickened_shape(shape, double_thickness)
    inner_shape = raised_shape(shape, double_thickness)
    outer_box = cube(outer_shape, center=True)
    inner_box = up(thickness)(cube(inner_shape, center=True))
    return up(0.5 * outer_shape[2])(outer_box - inner_box)
Exemple #4
0
def spaced_hole_punch(offsets, spacings, diameter, thickness):
    x_offset, y_offset, z_offset = offsets
    x_spacings, z_spacings = spacings
    hole = back(y_offset)(up(z_offset)(right(x_offset)(punch_hole(
        diameter, thickness))))
    return union()(
        [up(z)(right(x)(hole)) for z in z_spacings for x in x_spacings])
def screw(r_head, h_head, r_shaft, length, thick=THICK_WALL):
    """screw
    create a hole so a screw can be screwd into the box

    the center of the screw is aligned with the center of the coordinate system
    the screw is oriented as flipped T, i.e. it is standing on its head.
    screws are generated with an enclosing of THICK_WALL mm
    the interior is ensured via the hole function
    it is assumed that r_head > r_shaft
    The height of the head is h_head, an additional r_head-r_r_shaft is added
    to ensure printablity.

    :param r_head: radius of the head of the screw [mm]
    :param h_head: height of the head of the screw [mm]
    :param r_shaft: radius of the shaft of the screw [mm]
    :param length: desired length of the screw [mm]
    """
    h_shaft = length - h_head - (r_head - r_shaft)
    head = cylinder(h=h_head, r=r_head, segments=30)
    # 45 degrees cone for printability
    cone = up(h_head)(cylinder(h=r_head - r_shaft,
                               r1=r_head,
                               r2=r_shaft,
                               segments=30))
    shaft = up(h_head + (r_head - r_shaft))(cylinder(h=h_shaft,
                                                     r=r_shaft,
                                                     segments=30))
    inner = head + cone + shaft
    screw = cylinder(h=length, r=r_head + thick) - hole()(inner)
    return screw
Exemple #6
0
def slot_peg_with_catch(
        diameter=DEFAULT_PEG_DIAMETER,
        thickness=DEFAULT_HOLDER_THICKNESS,
        clearance=DEFAULT_CLEARANCE,
        overreach=None,
        slot_width=None,
        slot_clearance=DEFAULT_CONTAINER_CLEARANCE
):
    if overreach is None:
        overreach = diameter
    peg = solid_peg(diameter=diameter, thickness=thickness, clearance=clearance, overreach=overreach)
    if slot_width is None:
        slot_width = 0.35 * min(diameter, overreach)
    hole_height = clearance + overreach
    hole_displacement = slot_clearance + thickness + 0.5 * hole_height
    round_hole_bottom = back(0.5 * hole_height)(
        cylinder(r=0.5 * slot_width, h=2 * diameter, center=True, segments=16))
    hole_cutout = cube([slot_width, hole_height, 2 * diameter], center=True)
    hole = up(hole_displacement)(
        rotate([90.0, 0.0, 0.0])(
            hole_cutout + round_hole_bottom))
    catch_height = clearance + thickness + 0.5 * diameter
    catch_offset = 0.5 * diameter
    unscaled_catch = up(catch_height)(
        rotate([90, 0, 0])(
            cylinder(r=0.5 * diameter, h=0.5 * slot_width, center=True, segments=4)))
    catch = scale([0.4, 1.0, 1.0])(unscaled_catch)
    return peg \
           + left(catch_offset)(catch) \
           + right(catch_offset)(catch) \
           - hole
    def slot(r_head, h_head, r_shaft, width, height):
        """slot

        openscad styled vertically oriented printable slot
        origin formed by the center of left circle

        :param r_head: the radius of the top of the screw, [mm]
        :param h_head: the height of the top of the screw, [mm]
        :param r_shaft: the radius of the shaft of the  screw, [mm]
        :param width: the width of the slot, [mm]
        :param height: the height of the slot, [mm]
         """
        h_shaft = height - h_head - (r_head - r_shaft)
        head = cylinder(h=h_head, r=r_head, segments=30)
        # 45 degrees cone for printability
        cone = up(h_head)(cylinder(h=r_head - r_shaft,
                                   r1=r_head,
                                   r2=r_shaft,
                                   segments=30))
        shaft = up(h_head + (r_head - r_shaft))(cylinder(h=h_shaft,
                                                         r=r_shaft,
                                                         segments=30))
        cyl = head + cone + shaft
        inner = hull()(cyl, right(width)(cyl))
        cyl = cylinder(h=height, r=r_head + THICK_WALL)
        outer = hull()(cyl, right(width)(cyl))
        slot = outer - hole()(inner)
        return slot
Exemple #8
0
    def __init__(self, height, **kwargs):
        bt1 = kwargs.get('bodytube1')
        bt2 = kwargs.get('bodytube2')
        self.r1= to_mm(kwargs.get('r1'),safe=True)
        self.r2= to_mm(kwargs.get('r2'),safe=True)
        self.r3= to_mm(kwargs.get('r3'),safe=True)
        self.r4= to_mm(kwargs.get('r4'),safe=True)
        if bt1:
            self.r1=to_mm(bt1.inner_diameter/2.0)
            self.r2=to_mm(bt1.outer_diameter/2.0)
        if bt2:
            self.r4=to_mm(bt2.inner_diameter/2.0)
            self.r3=to_mm(bt2.outer_diameter/2.0)
        self.shoulder= to_mm(kwargs.get('shoulder'),default=0.5)
        self.shoulder1 = to_mm(kwargs.get('shoulder1'),safe=True)
        self.shoulder2 = to_mm(kwargs.get('shoulder2'),safe=True)
        if self.shoulder1 is None:
            self.shoulder1 = self.shoulder
        if self.shoulder2 is None:
            self.shoulder2 = self.shoulder
        self.height = to_mm(height)
        self.shoulder=to_mm(0.5)
        self.thickness = to_mm(kwargs.get('thickness'),safe=True)
        self.transition = cylinder(h=self.shoulder1, r=self.r1)+up(self.shoulder1+self.height)(cylinder(h=self.shoulder2, r=self.r4))+    up(self.shoulder1)(cylinder(h=self.height, r1=self.r2, r2=self.r3))

        if self.thickness:
            subtract =  cylinder(h=self.shoulder1, r=self.r1-self.thickness)+up(self.shoulder1+self.height)(cylinder(h=self.shoulder2, r=self.r4-self.thickness))+    up(self.shoulder1)(cylinder(h=self.height, r1=self.r2-self.thickness, r2=self.r3-self.thickness))
            self.transition -= subtract
Exemple #9
0
def assembly():
    column = tube.volume(diameter=column_diameter, wall_thickness=2., length=column_length)

    return sp.union()(
        spu.up(column_length)(
            spu.up(wheel.plate_thickness / 2.)(
                sp.color('red')(wheel.volume()),
                spu.up(wheel.plate_thickness / 2.)(
                    sp.color('green')(instrument_panel.assembly())
                ),
                sp.translate((150, 80))(
                    sp.rotate((0., 60., 0.))(
                        sp.color('blue')(throttle.assembly())
                    )
                ),
            ),
            sp.rotate((0, 180, 0))(sp.color('cyan')(wheel_mount.volume())),
        ),
        sp.color('magenta')(column),
        spu.up(440.)(sp.color('purple')(column_mount.upper.assembly())),
        spu.up(60.)(sp.color('grey')(column_mount.lower.assembly())),
        sp.rotate((0, 0, 0))(
            sp.color('orange')(arm_mount.volume()),
            sp.color('pink')(spu.down(arm.thickness)(arm.volume())),
        ),
    )
Exemple #10
0
def grid_plane(grid_unit=12, count=10, line_weight=0.1, plane='xz'):

    # Draws a grid of thin lines in the specified plane.  Helpful for
    # reference during debugging.
    elle = count * grid_unit
    t = union()
    t.set_modifier('background')
    for i in range(-count // 2, count // 2 + 1):
        if 'xz' in plane:
            # xz-plane
            h = up(i * grid_unit)(cube([elle, line_weight, line_weight],
                                       center=True))
            v = right(i * grid_unit)(cube([line_weight, line_weight, elle],
                                          center=True))
            t.add([h, v])

        # xy plane
        if 'xy' in plane:
            h = forward(i * grid_unit)(cube([elle, line_weight, line_weight],
                                            center=True))
            v = right(i * grid_unit)(cube([line_weight, elle, line_weight],
                                          center=True))
            t.add([h, v])

        # yz plane
        if 'yz' in plane:
            h = up(i * grid_unit)(cube([line_weight, elle, line_weight],
                                       center=True))
            v = forward(i * grid_unit)(cube([line_weight, line_weight, elle],
                                            center=True))
            t.add([h, v])
    return t
def xulaconnector():
    screw_xuout = 2.5
    screw_xuin = 1.5
    screw_toph = 1
    offset = 5
    length = offset + THICK_WALL
    # XULA2 is attached to the top with two screws
    screw_xula = hscrew(screw_xuout, screw_toph, screw_xuin, length)
    screws_xula = screw_xula + right(58)(screw_xula)
    screws_xula += up(48.8)(screws_xula)
    xula_base = screws_xula
    # Raspberry connector xula2
    rsp_cnctr = cube([58 - 2 * (screw_xuin + THICK_WALL * 0.5), length, 6])
    xula_base += translate([screw_xuin + THICK_WALL * 0.5, -length,
                            -3 + 48.8])(hole()(rsp_cnctr))
    # add stickit connector
    top_height = 4  # top height screw in mm
    top_r = 3.5  # top r screw in mm
    shaft_r = 2
    screw_stick = hscrew(top_r, top_height, shaft_r, length)
    screws_stick = screw_stick + up(15)(screw_stick)
    # stickit length 49.6-1.28-2-2
    # 15.5+1.5+1.2-1.5
    xula_base += translate(
        [-(49.6 - 1.28 - 2 - 2) - 8, 0,
         15.5 + 1.5 + 1.2 - 1.5 - 2.7])(screws_stick)
    xula_base += translate([-60, -2, -8])(cube([123, 2, 61]))
    xula_base = up(THICK_WALL + 11)(xula_base)
    # add down connector
    base_exit = cube([58 + 2 * screw_xuin + THICK_WALL, 16, THICK_WALL])
    base_exit += hole()(translate(
        [screw_xuin + THICK_WALL * 0.5, THICK_WALL,
         0])(cube([58 - 2 * (screw_xuin + THICK_WALL * 0.5), 12, THICK_WALL])))
    xula_base += back(16)(base_exit)
    return xula_base
Exemple #12
0
def volume():
    body = spu.up(2.)(sp.cylinder(d=diameter, h=thickness))
    mount = spu.up(4.)(spu.back(diameter / 2.)(sp.rotate(
        (-60., 0., 0.))(sp.rotate((0., 90., 0.))(sp.hull()(place_at_centres(
            (20.,
             0.), sp.cylinder(d=mount_thickness, h=mount_width, center=True)
        )) - spu.right(10.)(sp.cylinder(
            d=mount_diameter, h=mount_width + 1., center=True))))))
    return body + mount
    def __init__(self, height, **kwargs):
        bt1 = kwargs.get('bodytube1')
        bt2 = kwargs.get('bodytube2')
        bt3 = kwargs.get('bodytube3')
        fudge = to_mm(kwargs.get('fudge'), default=0.0)
        self.open_end = kwargs.get('open_end', False)
        self.r1 = to_mm(kwargs.get('r1'), safe=True)
        self.r2 = to_mm(kwargs.get('r2'), safe=True)
        self.r3 = to_mm(kwargs.get('r3'), safe=True)
        self.r4 = to_mm(kwargs.get('r4'), safe=True)
        if bt1:
            self.r1 = to_mm(bt1.inner_diameter / 2.0)
            self.r2 = to_mm(bt1.outer_diameter / 2.0)
        if bt2:
            self.r4 = to_mm(bt2.inner_diameter / 2.0)
            self.r3 = to_mm(bt2.outer_diameter / 2.0)
        self.shoulder = to_mm(kwargs.get('shoulder'), default=0.5)
        self.shoulder1 = to_mm(kwargs.get('shoulder1'), safe=True)
        self.shoulder2 = to_mm(kwargs.get('shoulder2'), safe=True)
        self.r1 -= fudge
        self.r4 -= fudge
        if self.shoulder1 is None:
            self.shoulder1 = self.shoulder
        if self.shoulder2 is None:
            self.shoulder2 = self.shoulder
        self.height = to_mm(height)
        self.shoulder = to_mm(0.5)
        self.thickness = to_mm(kwargs.get('thickness'), safe=True)
        self.transition = cylinder(
            h=self.shoulder1, r=self.r1) + up(self.shoulder1 + self.height)(
                cylinder(h=self.shoulder2, r=self.r4)) + up(self.shoulder1)(
                    cylinder(h=self.height, r1=self.r2, r2=self.r3))

        if bt3 and not self.thickness:
            self.transtion -= cylinder(h=shoulder1 + height + shoulder2,
                                       r=bt3.outer_diameter / 2.0)

        if self.thickness:
            subtract = cylinder(
                h=self.shoulder1, r=self.r1 -
                self.thickness) + up(self.shoulder1 + self.height)(cylinder(
                    h=self.shoulder2, r=self.r4 - self.thickness)) + up(
                        self.shoulder1)(cylinder(h=self.height,
                                                 r1=self.r2 - self.thickness,
                                                 r2=self.r3 - self.thickness))
            self.transition -= subtract
            if bt3 or not self.open_end:
                self.transition += cylinder(h=self.thickness, r=self.r1) + up(
                    self.shoulder1 + self.height + self.shoulder2 -
                    self.thickness)(cylinder(h=self.thickness, r=self.r4))
                if bt3:
                    self.transition += cylinder(
                        h=self.shoulder1 + self.height + self.shoulder2,
                        r=to_mm(bt3.outer_diameter / 2.0) + self.thickness)
                    self.transition -= cylinder(
                        h=self.shoulder1 + self.height + self.shoulder2,
                        r=to_mm(bt3.outer_diameter / 2.0) + fudge)
    def __init__(self,
                 cone,
                 shoulder=None,
                 thickness=None,
                 upper_tpi=6,
                 lower_tpi=4,
                 offset=None,
                 thread_height=None,
                 thread_diameter=None):
        super(ThreadedBaseOutsetScrewInBase,
              self).__init__(cone, shoulder, thickness)
        shoulder = to_mm(self.shoulder)
        thickness = to_mm(thickness, self.thickness)
        radius = to_mm(cone.inner_diameter / 2.)
        offset = to_mm(offset, to_inch(thickness))
        upper_tooth = to_mm(1. / upper_tpi * sqrt(3) / 2.)
        lower_tooth = to_mm(1. / lower_tpi * sqrt(3) / 2.)
        thread_height = to_mm(thread_height, self.length / 3)
        thread_diameter = to_mm(thread_diameter, cone.inner_diameter / 2.)

        self.cone = difference()(
            union()((cone.cone - cylinder(h=offset, r=3 * radius)),
                    color("red")(self.slice(cone.cone,
                                            thread_height, offset))),
            up(offset - self.epsilon)(self.threaded_female_column(
                length=thread_height + 2 * self.epsilon,
                diameter=thread_diameter,
                threads_per_inch=upper_tpi)),
            cylinder(h=to_mm(0.25), r=radius - thickness))

        core_radius = min(thread_diameter / 2 - thickness - upper_tooth,
                          radius - thickness - lower_tooth)
        lower_thread = down(shoulder)(self.threaded_male_column(
            length=shoulder + offset,
            diameter=radius * 2 - thickness * 2.,
            threads_per_inch=lower_tpi))
        upper_thread = up(offset)(self.threaded_male_column(
            length=thread_height,
            diameter=thread_diameter,
            threads_per_inch=upper_tpi))
        self.center_mate = upper_thread + lower_thread + cylinder(
            h=thickness, r=radius - thickness) - down(shoulder - thickness)(
                cylinder(h=shoulder + offset + thread_height, r=core_radius))

        self.mate = difference()(
            down(shoulder)(cylinder(h=shoulder, r=radius)) +
            self.slice(cone.cone, offset),
            down(shoulder)(self.threaded_female_column(
                length=shoulder + offset,
                diameter=radius * 2 - thickness * 2,
                threads_per_inch=lower_tpi)),
            cylinder(h=thickness, r=radius - thickness))
Exemple #15
0
 def __init__(self, cone, offset, radius):
     super(DerivativeNoseCone,
           self).__init__(length=cone.length,
                          thickness=cone.thickness,
                          outer_diameter=cone.outer_diameter,
                          inner_diameter=cone.inner_diameter)
     offset = to_mm(offset)
     radius = to_mm(radius)
     self.cone = cone.cone - up(offset + radius)(sphere(r=radius))
     if self.thickness:
         thickness = to_mm(self.thickness)
         self.cone = self.cone + hull()(cone.cone) * up(offset + radius)(
             sphere(r=radius + thickness) - sphere(r=radius))
Exemple #16
0
def assembly():
    box = big_box.assembly()
    box = utils.color('blue')(box)
    bottom_drawer = utils.up(1)(utils.right(1)(drawers.assembly()))
    bottom_drawer = utils.color('red')(bottom_drawer)
    top_drawer = utils.right(1)(utils.up((dimensions.box_x / 4) - 1)(
        drawers.assembly()))
    top_drawer = utils.color('green')(top_drawer)
    middle_spacer = solid.cube([dimensions.box_x, 1, 1.5])
    middle_spacer = utils.up((dimensions.box_z / 2) - 0.5)(middle_spacer)
    middle_spacer = utils.right(0.5)(middle_spacer)
    middle_spacer = utils.color('blue')(middle_spacer)
    monitor_stand = box + bottom_drawer + top_drawer + middle_spacer
    return monitor_stand
Exemple #17
0
def arduino():
    usbhole = up(2.5)(cube([2.5, 7.5, 9], True))
    board = up(3.75)(cube([2, x, 7.5], True))
    smds = up(1.25)(cube([1.5, 5, 2.5], True))
    dupont = up(2.5)(cube([2.5, 2.5, 5], True))
    pinhole = cube([39, 1, 1], True)

    return (usbhole) \
    + up(1)(left(3.75)(smds)) \
    + up(1)(left(2)(board)) \
    + left(4.25)(up(3.5)(forward((x/2)-1.25)(dupont))) \
    + left(4.25)(up(3.5)(back((x/2)-1.25)(dupont))) \
    + left(5)(up(2.25)(forward((x/2)-1.25)(pinhole))) \
    + left(5)(up(2.25)(back((x/2)-1.25)(pinhole)))
Exemple #18
0
    def __init__(self, retainer_diameter, height, depth, threads_per_inch, cap_diameter, hole_diameter, cap_thickness,**kwargs):
        r_r = to_mm(retainer_diameter/2.)
        height = to_mm(height)
        h_r = to_mm(hole_diameter/2.)
        c_r = to_mm(cap_diameter/2.)
        c_t = to_mm(cap_thickness)
        threads_per_inch = threads_per_inch
        o_d = kwargs.get('outer_diameter')
        i_d = kwargs.get('inner_diameter')

        if 'bodytube' in kwargs:
            o_d = kwargs['bodytube'].outer_diameter
            i_d = kwargs['bodytube'].inner_diameter

        print i_d
        i_r = to_mm(i_d/2.)
        o_r = to_mm(o_d/2.)

        print retainer_diameter
        flange_d = to_mm(kwargs.get('flange_diameter'), safe=True)
        flange_t = to_mm(kwargs.get('flange_thickness'), safe=True)
        
        spine_diameter = to_mm(kwargs.get('spine_diameter'), safe=True)

        round_radius = to_mm(kwargs.get('round_radius',0))

        if flange_d and flange_t:
            flange = cylinder(h=flange_t, r=flange_d/2.)
        else:
            flange = cylinder(h=height, r=o_r/2.)  # HACK because this will be removed

        self.retainer = difference() (self.threaded_male_column(height, to_mm(retainer_diameter), threads_per_inch) + flange,
                                      cylinder(h=height, r=o_r),
                                      up(height-depth), cylinder(h=depth, r=i_r))
        
        self.cap = difference()(cylinder(h=height,r=c_r),
                                self.threaded_female_column(height-c_t, to_mm(retainer_diameter), threads_per_inch),
                                cylinder(h=height, r=h_r))

        if spine_diameter:
            no_spines = kwargs.get('spines',0)
            spines = []
            for idx in xrange(0, no_spines):
                spines.append(rotate([0,0,360/no_spines*idx])(right(c_r)(cylinder(h=height-c_t-spine_diameter/2, r=spine_diameter/2)+
                                  up(height-c_t-spine_diameter/2)(sphere(r=spine_diameter/2.)))))
            self.cap+=union()(*spines)

        self.round = rotate_extrude()(right(c_r-round_radius)(square([round_radius,round_radius])*circle(round_radius)))
        self.cap -= up(height-round_radius)(rotate_extrude()(right(c_r-round_radius)(square([round_radius,round_radius]))))
        self.cap += up(height-round_radius)(self.round)
def switch_plate():
    top_wall = forward((1.5 + keyswitch_length) / 2)(
        up(plate_thickness / 2)(
            cube((keyswitch_width + 3, 1.5, plate_thickness), center=True) -
            down(notch_plate_thickness)(  # Notch for switch clips
                back(0.75)(cube((notch_width, notch_depth * 2,
                                 plate_thickness),
                                center=True)))))

    left_wall = left((1.5 + keyswitch_width) / 2)(up(plate_thickness / 2)(cube(
        (1.5, keyswitch_length + 3, plate_thickness), center=True)))

    plate_half = top_wall + left_wall

    return plate_half + mirror((0, 1, 0))(mirror((1, 0, 0))(plate_half))
Exemple #20
0
def assembly():
    outer_bars = sp.rotate([-90, 0, 0])([
        spu.left(d)(box_section.volume(length=outer_length,
                                       center=False,
                                       color='red')) for d in [-outer, outer]
    ])

    inner_bars = sp.rotate([-90, 0, 0])([
        spu.left(d)(box_section.volume(length=inner_length,
                                       center=False,
                                       color='green'))
        for d in [-inner, inner]
    ])

    front_bumper = spu.forward(inner_length +
                               (box_section.default_size[0] / 2.))(sp.rotate(
                                   [0, 90, 0])(box_section.volume(
                                       length=inner * 2. +
                                       box_section.default_size[0],
                                       center=True,
                                       color='blue')))

    mid_bars = spu.forward(outer_length + box_section.default_size[0] / 2.)(
        sp.rotate([0, 90, 0])(
            box_section.volume(length=inner * 2. - box_section.default_size[0],
                               center=True,
                               color='cyan'),
            [
                sp.rotate([0, a, 0])(
                    spu.up(inner + box_section.default_size[0] / 2.)(
                        box_section.volume(
                            length=outer - inner, center=False, color='cyan')))
                for a in [0, 180]
            ],
        ), )

    rear_bar = spu.back(box_section.default_size[0] / 2.)(sp.rotate([
        0, 90, 0
    ])(box_section.volume(length=outer * 2. + box_section.default_size[0],
                          center=True,
                          color='magenta')))

    bearings = spu.forward(rear_axle_position)(sp.rotate([180, 0, 0])([
        sp.translate([x, 0, box_section.default_size[0] / 2.
                      ])(sp.color('orange')(rear_axle_bearing.volume()))
        for x in [-outer, outer]
    ]))

    front_axle_and_wheels = sp.color('gray')(sp.translate(
        (0, 1150, -box_section.default_size[0]))(front_axle.assembly()))

    return sp.union()(
        outer_bars,
        inner_bars,
        front_bumper,
        mid_bars,
        rear_bar,
        bearings,
        front_axle_and_wheels,
    )
    def __init__(self,
                 cone,
                 shoulder=None,
                 thickness=None,
                 screw_length=None,
                 screw_diameter=None,
                 screw_size=None):
        super(HollowBaseWithScrewHole, self).__init__(cone, shoulder,
                                                      thickness)
        radius = cone.inner_diameter * MM2IN / 2

        shoulder = self.shoulder * MM2IN
        thickness = MM2IN * self.thickness
        screw_length = screw_length * MM2IN
        screw_radius = screw_diameter * MM2IN / 2
        if not screw_radius:
            "get_screw_size"

        self.cone = difference()(
            union()(self.cone,
                    down(shoulder)(cylinder(h=screw_length,
                                            r=screw_radius + thickness / 2.)),
                    up(min(screw_length - shoulder - thickness,
                           -thickness))(cylinder(h=thickness, r=radius))),
            down(shoulder)(cylinder(h=screw_length, r=screw_radius)))
Exemple #22
0
def threadAsm(uplift, thredID, thredThik, pitch, starts, turns, extern):
    '''Return an assembly for an internal or external thread of given
       inner diameter, thickness, and pitch, with specified number of
       starts (independent thread parts), wrapping a given number of
       turns.  uplift = Z-axis translation amount.  Inner diameter
       thredID is the diameter of the cylinder the threads wrap
       against.  It is that cylinder's outer diameter for external
       threads, or the cylinder's inner diameter for internal threads.
       threadAsm adds or subtracts an epsilon (0.0001) to prevent
       small gaps between thread and cylinder, which if they happen
       will lead to rendering/slicing error messages.
    '''
    inRadi, eps, thredSpan = thredID/2, 1e-4, pitch*turns
    # Set tooth_height and tooth_depth in thread-shape
    thredShape = default_thread_section((pitch/starts)-eps, thredThik)
    # Generate one thread start, with eps to ensure not non-manifold
    inRadiEps = inRadi - (eps if extern else -eps)
    thred1 = thread(thredShape, inRadiEps, pitch, thredSpan, external=extern,
                  segments_per_rot=40, neck_in_degrees=30, neck_out_degrees=30)
    thred = thred1
    # Rotate thred1 for other thread starts
    for t in range(1,starts):
        thred += rotate(a=(0, 0, (t*360)/starts))(thred1)
    # Return thread moved up to proper position
    return up(uplift)(thred)
def key_grid_tester(
    length_units,
    width_units,
    wall_height=default_wall_height,
    margin_length=0,
    margin_width=0,
):
    x_grid_size = mount_width + switch_spacing
    y_grid_size = mount_length + switch_spacing

    case = key_grid_tester_walls(
        length_units, width_units, wall_height, margin_length, margin_width
    ) + up(wall_height - plate_thickness)(
        right(x_grid_size * (width_units - 1) / 2)(
            back(y_grid_size * (length_units - 1) / 2)(
                *[
                    left(x_grid_size * x_units)(
                        forward(y_grid_size * y_units)(spaced_switch_plate())
                    )
                    for y_units in range(length_units)
                    for x_units in range(width_units)
                ]
            )
        )
    )

    return case
    def __init__(self,
                 cone,
                 shoulder=None,
                 thickness=None,
                 threads_per_inch=6,
                 thread_height=None,
                 thread_diameter=None,
                 screw_length=None,
                 screw_diameter=None,
                 screw_size=None):
        super(ScrewInBaseWithScrewHole,
              self).__init__(cone, shoulder, thickness, threads_per_inch,
                             thread_height, thread_diameter)
        radius = to_mm(cone.inner_diameter / 2)

        shoulder = to_mm(self.shoulder)
        thickness = to_mm(self.thickness)
        screw_length = to_mm(screw_length)
        screw_radius = to_mm(screw_diameter / 2)
        if not screw_radius:
            "get_screw_size"

        self.mate = difference()(
            union()(self.mate,
                    down(shoulder)(cylinder(h=screw_length,
                                            r=screw_radius + thickness / 2.)),
                    up(min(screw_length - shoulder - thickness,
                           -thickness))(cylinder(h=thickness, r=radius))),
            down(shoulder)(cylinder(h=screw_length, r=screw_radius)))
Exemple #25
0
def assembly():
    axle = sp.color('red')(
        round_bar.volume(
            diameter=axle_diameter, length=axle_length, center=True
        )
    )

    sprocket_assy = spu.up(sprocket_pos)(
        sp.color('green')(sp.rotate((180, 0, 0))(drive_sprocket.assembly()))
    )

    brake_disc_assy = spu.down(brake_disc_pos)(
        sp.color('blue')(brake_disc.assembly())
    )

    wheels = [
        sp.rotate([0, a, 0])(
            spu.left(wheel_centre_distance / 2.)(
                sp.color('cyan')(wheel.assembly())
            )
        ) for a in [0, 180]
    ]

    return sp.union()(
        sp.rotate([0, 90,
                   0])(sp.union()(
                       axle,
                       sprocket_assy,
                       brake_disc_assy,
                   )),
        wheels,
    )
def createlogo():
    """createlogo

    Openscad cannot handle the Storm font. To mitigate, a vector image of the
    storm font is converted to PNG via Inkscape. The PNG image is linearly
    extruded and converted to a STL.
    This STL is imported by this function, to create the logo.
    """
    # TODO: move Python converter for logo to here
    # LOGO bounding box x  = 234 , y = 26, z = 1
    # scaled to x = 120, y = 13
    x_bound = 120 + THICK_WALL * 2
    y_bound = 13 + THICK_WALL * 2

    # TODO: should throw error !! you removed logo
    logo = scale([0.5, 0.5, 1])(import_stl('hexastorm.stl'))
    logo = None
    # openscad cannot handle minkowski on hexastorm logo
    # logo_mink = up(1)(minkowski()(cylinder(r=0.5, h=1), logo))
    result = translate([-0.5 * x_bound, -0.5 * y_bound, 0])(cube(
        [x_bound, y_bound, 1])) - hole()(mirror([0, 1, 0])(logo))
    result = scale([1, 1, HEIGHT_TOP - THICK_WALL
                    ])(translate([0.5 * x_bound, 0.5 * y_bound, 0])(result))
    result = up(HEIGHT_TOP - THICK_WALL)(cube([x_bound, y_bound, 1]))
    # TODO: Openscad can create a preview but does not render the logo,
    #      at the moment we resort to
    # modiefs in blender
    return result
Exemple #27
0
def multipart_hole():
    # It's good to be able to keep holes empty, but often we want to put
    # things (bolts, etc.) in them.  The way to do this is to declare the
    # object containing the hole a "part".  Then, the hole will remain
    # empty no matter what you add to the 'part'.  But if you put an object
    # that is NOT part of the 'part' into the hole, it will still appear.

    # On the left (not_part), here's what happens if we try to put an object
    # into an explicit hole:  the object gets erased by the hole.

    # On the right (is_part), we mark the cube-with-hole as a "part",
    # and then insert the same 'bolt' cylinder into it.  The entire
    # bolt rematins.

    b = cube(10, center=True)
    c = cylinder(r=2, h=12, center=True)

    # A cube with an explicit hole
    not_part = b - hole()(c)

    # Mark this cube-with-hole as a separate part from the cylinder
    is_part = part()(not_part.copy())

    # This fits in the holes
    bolt = cylinder(r=1.5, h=14, center=True) + up(8)(cylinder(
        r=2.5, h=2.5, center=True))

    # The section of the bolt inside not_part disappears.  The section
    # of the bolt inside is_part is still there.
    return not_part + bolt + right(45)(is_part + bolt)
Exemple #28
0
def assembly():
    left_wall = lateral_wall()
    right_wall = utils.right(dimensions.box_x)(lateral_wall())
    bottom = bottom_top_wall()
    top = utils.up(dimensions.box_z)(bottom_top_wall())
    back = utils.forward(dimensions.box_y - 1)(back_wall())
    return left_wall + right_wall + bottom + top + back
Exemple #29
0
def switch_hole():
    base_shape = [SWITCH_HOLE_WIDTH, SWITCH_HOLE_LENGTH, SWITCH_HOLE_HEIGHT * 2]
    base_elevation = SWITCH_HOLE_ELEVATION
    base = forward(SWITCH_HOLE_Y_OFFSET)(up(base_elevation)(
        grounded_cube(base_shape))
    )
    return base
Exemple #30
0
def keystone_clasps():
    clasp = up(KEYSTONE_THICKNESS + KEYSTONE_REACH + KEYSTONE_THICKNESS)(
        grounded_cube([
            KEYSTONE_WIDTH + 2 * KEYSTONE_THICKNESS,
            KEYSTONE_CLASP_LENGTH + KEYSTONE_THICKNESS, KEYSTONE_CLASP_DEPTH
        ]))
    offset = (KEYSTONE_LENGTH - KEYSTONE_CLASP_LENGTH) / 2
    return back(offset)(clasp) + forward(offset)(clasp)
Exemple #31
0
def assembly():
    print "adapter needs height 32mm and we have %smm" % (8 * material_height)
    print "phone needs height 32mm and we have %smm" % (6 * material_height)
    print "total height %smm" % (len(ls) * material_height)
    layers = []
    for i, l in enumerate(ls):
        l_inst = l()
        layer = linear_extrude(height=material_height)(l_inst.body)
        layer = up(i * (material_height + layer_z_gap))(layer)
        layer = color(l_inst.color)(layer)
        layers.append(layer)

    return union()(layers)
bolt_z = height / 2.0
bolt1_y = bolt_from_edge - outer_rad
bolt2_y = square_width + outer_rad - bolt_from_edge
bolt_base1_y = (bolt_base_dia / 2.0) - outer_rad
bolt_base2_y = square_width + outer_rad - (bolt_base_dia / 2.0)
bolt_base_depth = depth * 0.66
# rotation of bolt base to merge into the side
bolt_base_angle = math.degrees(math.atan2(
    bolt_base_depth, bolt_base_dia / 2.0))
hnt = nt / 2.0  # half nested tolerance

# body centre
body = s.cube(size=[depth, square_width, height])
# body round edge 1
body += u.up(outer_rad)(s.rotate(a=[0, 90, 0])(
    s.cylinder(r=outer_rad, h=depth, segments=segments)
))
# body round edge 2
body += u.forward(square_width)(u.up(outer_rad)(s.rotate(a=[0, 90, 0])(
    s.cylinder(r=outer_rad, h=depth, segments=segments)
)))

# inner to subtract from the body for the body
inner = s.cube(
    size=[depth - wall_width, square_width, height - walls_width]
)
inner += u.up(inner_rad)(s.rotate(a=[0, 90, 0])(
    s.cylinder(r=inner_rad, h=depth - wall_width, segments=segments)
))
inner += u.forward(square_width)(u.up(inner_rad)(
    s.rotate(a=[0, 90, 0])(
Exemple #33
0
                                'with the mounting surface.',
                        end_comment='[45:90]')
v.screw_head_radius = s.var(4,
                            comment='Radius of hole to fix screw length.',
                            end_comment='[2:4.5]')
v.screw_radius = s.var(2,
                       comment='Radius of screw thread.',
                       end_comment='[1:4.5]')
v.screw_length = s.var(10,
                       comment='Length of thread to be inside spacer.',
                       end_comment='[3:45]')
v.head_hole_height = s.var('spacer_height - screw_length')

body = s.cube(size=[spacer_depth, spacer_width, v.spacer_height])

slot = u.up(3)(s.cube(size=[spacer_depth, 10, 2]))
slot_round = u.back(1)(u.up(2)(
    s.rotate(a=v.spacer_height, v=[1, 0, 0])(
        s.cube(size=[spacer_depth, 4, 4])
    )
))


screw_hole = u.forward(5)(
    s.cylinder(r=v.screw_head_radius, h=v.head_hole_height, segments=32) +
    u.up(v.head_hole_height)(
        s.cylinder(r=v.screw_radius, h=v.screw_length, segments=32)
    )
)

screw_hole_1 = u.right(screw_offset)(screw_hole)