示例#1
0
文件: stencil.py 项目: mplacona/KiKit
def printedStencilSubstrate(outlineDxf, thickness, frameHeight, frameWidth, frameClearance):
    bodyOffset = solid.utils.up(0) if frameWidth + frameClearance == 0 else solid.offset(r=frameWidth + frameClearance)
    body = solid.linear_extrude(height=thickness + frameHeight)(
        bodyOffset(solid.import_dxf(outlineDxf)))
    boardOffset = solid.utils.up(0) if frameClearance == 0 else solid.offset(r=frameClearance)
    board = solid.utils.up(thickness)(
        solid.linear_extrude(height=thickness + frameHeight)(
            boardOffset(solid.import_dxf(outlineDxf))))
    return body - board
示例#2
0
文件: stencil.py 项目: mplacona/KiKit
def printedStencil(outlineDxf, holesDxf, thickness, frameHeight, frameWidth,
                   frameClearance, enlargeHoles, front):
    zScale = -1 if front else 1
    xRotate = 180 if front else 0
    substrate = solid.scale([1, 1, zScale])(printedStencilSubstrate(outlineDxf,
        thickness, frameHeight, frameWidth, frameClearance))
    holesOffset = solid.utils.up(0) if enlargeHoles == 0 else solid.offset(delta=enlargeHoles)
    holes = solid.linear_extrude(height=4*thickness, center=True)(
        holesOffset(solid.import_dxf(holesDxf)))
    return solid.rotate(a=xRotate, v=[1, 0, 0])(substrate - holes)
示例#3
0
def get_case_wall(height):
    d = case - (sc.offset(-2 * mm)(case))
    d = (
        d
        + screws.create_screws(diameter=5.2 * mm)
        - screws.create_screws(diameter=3.2 * mm)
    )
    d = sc.linear_extrude(height)(d)
    # d = (d - switches.create_all_switches(size=0.8))
    return d
示例#4
0
def hollow_out(obj: OpenSCADObject, shell_thickness: int) -> OpenSCADObject:
    """Hollow SCAD object.

    Python implementation of dotSCAD's hollow_out module.
    Implemented due to solidpython having issues
    pickling imported scad modules.

    Args:
        obj: scad object to hollow.
        shell_thickness: shell thickness.

    """
    return solid.difference()(obj, solid.offset(delta=-shell_thickness)(obj))
示例#5
0
            (4, 4, 0))(sc.translate(pos * -1)(cutter)))
        offset = utils.unit_point2(angle) * 2.5 * left_or_right_dir
        cutter = sc.translate((*offset, 0))(cutter)
        return cutter

    ring = ring - (create_cutter(Point2(0, 0), -1))
    ring = ring - (create_cutter(Point2(switches.thumb_fan_size - 1, 0), 1))
    return ring


def create_left_buttom_circle():
    p0 = switches.get_cap_corner((0, 1), Point2(0.5, -0.5))
    p1 = switches.get_cap_corner((1, 1), Point2(0.5, -0.5))
    p2 = switches.get_cap_corner((3, 1), Point2(0, -0.62))
    circle = utils.three_point_cicle(p0,
                                     p1,
                                     p2,
                                     radius_adjustment=1.5 * mm,
                                     segments=1000)
    right_edge = switches.get_cap_corner(Point2(0, 0), Point2(-0.5, 0.5)).x
    return circle * sc.square(right_edge * 2, center=True)


def create_case():
    case = create_upper_case()
    case = case - create_left_buttom_circle()
    case = case + create_thumb_fan()
    case = sc.offset(r=10 * mm)(case)
    case = sc.offset(r=-7.5 * mm)(case)
    return case
示例#6
0
def rcylinder(r, h, rnd=0, center=False):
    ''' primitive for a cylinder with rounded edges'''
    if rnd == 0: return solid.cylinder(r=r, h=h, center=center)
    mod_cyl = solid.translate((0, 0, -h/2 if center else 0))( \
        solid.rotate_extrude(convexity=1)(solid.offset(r=rnd)(solid.offset(delta=-rnd)(solid.square((r, h)) + solid.square((rnd, h))))))
    return mod_cyl