Example #1
0
def snap_shaft():
    """Return snap shaft and hole geometry in a list of PolyMeshes."""

    s_pts = solid.polygon(
        points=[
            [0.0, 0.0], [4.95, 0.0], [4.95, 3.0], [2.45, 3.0], [1.95, 3.5],
            [1.95, 5.675], [2.45, 6.175], [2.45, 7.425], [1.95, 7.925],
            [0.75, 7.925], [0.75, 3.5], [0.0, 3.0], [0.0, 0.0]
        ]
    )

    sh_gen = (
        solid.rotate_extrude(convexity=10)(s_pts)
        - solid.translate([0, 0, 8.5])(solid.cube([1.5, 10, 10], center=True))
        - solid.translate([0, 0, 3.75])(
            solid.rotate([90, 0, 0])(
                solid.cylinder(r=0.75, h=10, center=True)
            )
        )
    )

    h_pts = solid.polygon(
        points=[
            [2.5, 0], [2, 0.5], [2.0, 2.675], [2.5, 3.175], [
                4.95, 3.175], [4.95, 0], [2.5, 0]
        ]
    )

    # added hole so it will subtract geometry from arm as necessary
    h_gen = solid.translate([0, 0, 3])(
        solid.rotate_extrude(convexity=10)(h_pts))

    return [PolyMesh(generator=sh_gen), PolyMesh(generator=h_gen)]
Example #2
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)
Example #3
0
def conic_section(theta):
	line = solid.polygon(points = [[0,0],[50,50],[49.9,50],[0,.1]])
	cone = solid.rotate_extrude( convexity = 20)(line)
	
	plane = solid.translate([0,0,5])(solid.cube([50,50,.1],center = True))
	plane = solid.rotate([0,theta,0])(plane)
	
	section = solid.rotate([0,-1*theta, 0])(solid.intersection()(cone, plane))
	return section
Example #4
0
def rounded_rect_extrude_func(prof, r, sizes):
    edges = []

    for i in range(4):
        l = sizes[i % 2]
        tx = [0, 0, 0]

        if i == 0:
            tx[1] = -r
        if i == 1:
            tx[0] = -sizes[1] + r
        if i == 2:
            tx[0] = -sizes[1]
            tx[1] = -sizes[0] + r
        if i == 3:
            tx[0] = -r
            tx[1] = -sizes[0]

        edge = S.translate(tx)(S.rotate([90, 0, i * 90])(
            S.linear_extrude(l - r * 2)(prof)))
        edges.append(edge)

        tx2 = list(tx)
        if i == 0 or i == 3:
            tx2[0] -= r
        if i == 1:
            tx2[1] -= r
        if i == 2:
            tx2[0] += r
        if i == 3:
            tx2[1] += r
            tx2[0] += r

        edges.append(
            S.translate(tx2)(S.rotate([0, 0, i * 90])(S.rotate_extrude(90)(
                S.translate([r, 0, 0])(prof)))))

    obj = S.translate([sizes[1] / 2, sizes[0] / 2, 0])(S.union()(edges))
    return obj
Example #5
0
ball_min = solid.sphere(d=Dmin, segments=resolution)
ball_min = solid.translate([0, 0, H])(ball_min)
ball_max = solid.sphere(d=Dmax, segments=resolution)
nosecone = solid.hull()(ball_min, ball_max)
# nosecone = solid.intersection()(upper_plane, nosecone)
taper = solid.cylinder(d1=Dbase, d2=BIG + Dbase, h=BIG, segments=resolution)
nosecone = solid.intersection()(taper, nosecone)
minifin_top = solid.cube([17, 2.5, 10 + 3.6], center=True)
minifin_bot = solid.cube([17 + 7.2, 2, 10], center=True)
minifin = solid.hull()(minifin_top, minifin_bot)
minifin = solid.rotate([0, 90 - theta, 0])(minifin)
minifin = solid.translate([-60, 0, 24])(minifin)
nosecone += minifin
nose_groove = solid.translate([22, 0, 0])(solid.circle(2))
nose_groove = solid.rotate_extrude()(nose_groove)
nose_groove = solid.translate([0, 0, H - 22])(nose_groove)
nosecone -= nose_groove
nosecone = solid.translate([-Dmax / 2, 0, 0])(nosecone)
nosecone = solid.rotate([0, 90 - theta, 0])(nosecone)
nosecone = solid.translate([Dmax / 2, 0, 0])(nosecone)
nosecone += solid.sphere(d=Dbase, segments=resolution)
nosecone = solid.intersection()(upper_plane, nosecone)
insert = solid.cylinder(d=Dinsert, h=Hinsert + epsilon, segments=resolution)
insert = solid.translate([0, 0, -Hinsert])(insert)

hollow = solid.cylinder(d=Dhollow,
                        h=Hhollow * 2,
                        center=True,
                        segments=resolution)
hollow = solid.translate([25, 0, 0])(hollow)
Example #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
Example #7
0
    profile = 0.9 * length * term1 * np.sqrt(1 - term1)
    # For the profile to "stand up" swap the axes
    coords = list(zip(profile, xpts + offset))
    # Add origin point as the last point to close the profile
    coords.append((0., offset))
    return coords


# Read the outer profile for the shell
#shell = sol.polygon(read_csv(PROF_OUTER))
# Generate the outer profile for the shell
shell = sol.polygon(egg(LENGTH))
# Rotational extrusion to make the solid.
# rotate_extrude takes the profile on the XY plane and uses it as the
# profile in the XZ plane for revolution about the Z-axis
shell = sol.rotate_extrude(convexity=10)(shell)

# Variables...
# The following variables need to be defined in the HEADER string
# for OpenSCAD to have access to them in the generated program:
# coupler_shoulder_len, coupler_shoulder_diam, coupler_fitting_len
# coupler_fitting_diam, coupler_extra, delta, wall_th
OUTFILE = 'Customizable_hollow_egg_carrier.scad'
coupler_fitting_diam = 'coupler_fitting_diam'
coupler_shoulder_h = 'coupler_shoulder_len + coupler_extra'
coupler_shoulder_diam = 'coupler_shoulder_diam'
coupler_shoulder_shift = '-coupler_shoulder_len'
coupler_fitting_h = 'coupler_fitting_len + delta'
coupler_fitting_shift = '-(coupler_shoulder_len + coupler_fitting_len)'
hole_len = 'coupler_shoulder_len + coupler_extra + coupler_fitting_len'
hole_h = hole_len + ' + delta'