示例#1
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,
    )
示例#2
0
def assembly():
    return sp.union()(
        sp.color('red')(spu.left(100.)(wheel.volume())),
        sp.color('green')(left_stub_axle.volume()),
        sp.color('blue')(spu.left(58.)(sp.rotate(
            (0., -90., 0.))(wheel_bushing.volume()))),
    )
示例#3
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,
    )
示例#4
0
def assembly():
    rear_lights = spu.forward(light_y_offset)([
        place_at_centres([x, 0], lights.small.volume()) for x in light_centres
    ])

    return sp.union()(
        sp.color('red')(bumper.volume()),
        spu.up(bumper.thickness)(sp.color('green')(rear_lights), ),
    )
示例#5
0
def draw_profile():
    obj = prof_p1 + S.color("black")(prof_n1)

    # draw intersection points
    if True:
        obj += S.color("red")(S.linear_extrude(10)(S.union()(
            S.translate(bottom_meet_pt)(S.circle(0.2)),
            S.translate(upper_meet_pt)(S.circle(0.2)),
        )))
    return obj
示例#6
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())),
        ),
    )
示例#7
0
def rasp_pi():
	base = solid.color([0,.7,.1])(solid.cube([8.5,5.5,.1]))
	metal = t55_to_1([209,209,209])
	yellow = t55_to_1([255, 188, 60])

	ether = solid.translate([-0.1,3.9,0])(solid.cube([2.1,1.6,1.4]))
	ether = solid.color(metal)(ether)

	usb = solid.cube([1.7,1.3,1.5])
	usb = solid.translate([-.7,1.9,0])(solid.color(metal)(usb))
	
	audio = solid.cube([1.2, 1.5, 1.2])
	audio = solid.translate([1.5,-.5,0])(solid.color([0,0,0])(audio))
	
	tv = solid.cube([1,1.9,1.5])
	tv = solid.translate([3.4,-.8,0])(solid.color(yellow)(tv))	
	
	hdmi = solid.cube([1.5,1.1,.9])
	hdmi = solid.translate([3.4,4.6,0])(solid.color(metal)(hdmi))
	
	gpio = solid.cube([3.2,.4,1.2])
	gpio = solid.translate([5.3,.1,0])(solid.color([0,0,0])(gpio))
	
	sdcard = solid.cube([1.8,2.9,.4])
	sdcard = solid.translate([6.7, 1.6, -.4])(solid.color([0,0,0])(sdcard))
	
	musb = solid.cube([.5,.7,.3])
	musb = solid.translate([7.9, 4.5, 0])(solid.color([0,0,0])(musb))
	
	out = [base, ether, usb, audio, tv, hdmi, gpio, sdcard, musb]
	return join_list(out)
示例#8
0
def make_solid(arr):
    HEIGHT = 1
    SCALE = 2  # output defaults to 1 mm per unit; this lets us increase the size of objects proportionally.
    cubes = [
        translate([i * SCALE, j * SCALE,
                   0])(color('black')(cube(size=[SCALE, SCALE, HEIGHT])))
        for i, row in enumerate(arr) for j, col in enumerate(row)
        if arr[i, j] == 1
    ]

    base_plate = color('white')(cube(size=(arr.shape[0] * SCALE,
                                           arr.shape[1] * SCALE, HEIGHT / 2)))
    qrobj = union()(*cubes, base_plate)
    return qrobj
示例#9
0
def assembly():
    small_lights = spu.forward(small_light_y_offset)(
        place_at_centres([small_light_centres, 0], lights.small.volume())
    )

    large_lights = spu.forward(large_light_y_offset)(
        place_at_centres([large_light_centres, 0], lights.large.assembly())
    )

    return sp.union()(
        sp.color('red')(bumper.volume()),
        spu.up(bumper.thickness)(
            sp.color('green')(small_lights),
            sp.color('blue')(large_lights),
        ),
    )
示例#10
0
def sa_cap(Usize=1):
    # MODIFIED TO NOT HAVE THE ROTATION.  NEEDS ROTATION DURING ASSEMBLY
    sa_length = 18.25

    bw2 = Usize * sa_length / 2
    bl2 = sa_length / 2
    m = 0
    pw2 = 6 * Usize + 1
    pl2 = 6

    if Usize == 1:
        m = 17 / 2

    k1 = sl.polygon([[bw2, bl2], [bw2, -bl2], [-bw2, -bl2], [-bw2, bl2]])
    k1 = sl.linear_extrude(height=0.1, twist=0, convexity=0, center=True)(k1)
    k1 = sl.translate([0, 0, 0.05])(k1)
    k2 = sl.polygon([[pw2, pl2], [pw2, -pl2], [-pw2, -pl2], [-pw2, pl2]])
    k2 = sl.linear_extrude(height=0.1, twist=0, convexity=0, center=True)(k2)
    k2 = sl.translate([0, 0, 12.0])(k2)
    if m > 0:
        m1 = sl.polygon([[m, m], [m, -m], [-m, -m], [-m, m]])
        m1 = sl.linear_extrude(height=0.1, twist=0, convexity=0, center=True)(m1)
        m1 = sl.translate([0, 0, 6.0])(m1)
        key_cap = sl.hull()(k1, k2, m1)
    else:
        key_cap = sl.hull()(k1, k2)

    # key_cap = sl.translate([0, 0, 5 + plate_thickness])(key_cap)
    key_cap = sl.color([220 / 255, 163 / 255, 163 / 255, 1])(key_cap)

    return key_cap
示例#11
0
def base_support(matress_length, overhang):
    half_cross = hole()(cube((3 / 2, 3 / 2, 11 / 8)))
    return color("tan")(
        part()(Board(matress_length + overhang * 2, 11 / 4, 3 / 2, (Y, Z, X)) -
               translate((0, overhang, 0))(half_cross) -
               translate((0, overhang + matress_length - 3 / 2,
                          0))(half_cross)))
示例#12
0
 def createElementModule(name, sp):
     elModSrc = "module " + sp.name + "(pos=[0,0,0]){" + useOpenScadVariable(
         sld.translate("%%%positionExprPlaceholder%%%")(sld.color(
             convertWebColorToOpenScad(sp.cpk_color))(sld.sphere(
                 r * sp.covalent_radius / maxRad))),
         {"%%%positionExprPlaceholder%%%": "pos*lFact"}) + "\n}"
     return elModSrc
示例#13
0
 def unrotated_origin_verts(self):
     verts = []
     for idx in range(len(self.unrotated_verts)):
         vert = self.vertices[idx]
         color = self.vert_colors[idx]
         verts.append(sl.color(color)(sl.translate(vert)(sl.cube(1))))
     return sl.union()(*verts)
示例#14
0
def base_end(matress_width, overhang):
    half_cross = hole()(cube((3 / 2, 3 / 2, 11 / 8)))
    return color("saddlebrown")(
        part()(Board(matress_width + 2 * overhang, 11 / 4, 3 / 2, (X, Z, Y)) -
               union()(*[
                   translate((overhang + x, 0, 11 / 8))(half_cross)
                   for x in base_longitudinal_displacements(matress_width)
               ])))
示例#15
0
    def test_transform_dispatch_unsuported(self) -> None:
        holonomic_transformable = MockHolonomicTransformable()

        color = solid.color([1.0, 1.0, 1.0])
        with self.assertRaises(
                NotImplementedError,
                msg="Unsupported transformations should error out"):
            holonomic_transformable.transform(color)
示例#16
0
def assembly():
    main = sp.translate([
        box_section.default_size[0] / 2., 0, -cable_side_length
    ])(box_section.volume(length=pedal_side_length +
                          cable_side_length)) - sp.rotate([0, 90, 0])(
                              drilled_hole.volume(pivot_hole_diameter))

    pedal = sp.translate([
        0, -box_section.default_size[1],
        pedal_side_length - box_section.default_size[1] / 2.
    ])(sp.rotate([0, 90, 0])(box_section.volume(length=pedal_width,
                                                center=True)))

    return sp.union()(
        sp.color('red')(main),
        sp.color('green')(pedal),
    )
示例#17
0
def mannequin():
	trunk = strunk()
	legs = slegs()
	head = shead()
	arms = sarms()
	body = [trunk, head, legs, arms]
	body = solid.color([.1,.9,.1])(join_list(body))
	return body
示例#18
0
def arr2scad(arr, HEIGHT: int = 2):
    """
    Convert an array `arr` into valid OpenSCAD text.
    """

    SCALE = 2  # output defaults to 1 mm per unit; this lets us increase the size of objects proportionally.
    cubes = [
        translate([i * SCALE, j * SCALE,
                   0])(color('black')(cube(size=[SCALE, SCALE, HEIGHT])))
        for i, row in enumerate(arr) for j, col in enumerate(row)
        if arr[i, j] == 1
    ]

    base_plate = color('white')(cube(size=(arr.shape[0] * SCALE,
                                           arr.shape[1] * SCALE, HEIGHT / 2)))
    qrobj = union()(*cubes, base_plate)

    return scad_render(qrobj)
示例#19
0
def size_check():
    return sp.union()(
        assembly(),
        sp.translate((0., 600., 100.))(
            sp.color((1., 1., 1., 0.4))(
                sp.cube(max_outer_dimensions, center=True)
            )
        ),
    )
示例#20
0
def assembly():
    x_bars = sp.rotate([0, 90, 0])(
        [
            spu.back(d)(
                box_section.volume(
                    length=outer * 2. + box_section.default_size[0],
                    center=True
                )
            ) for d in split_centers(seat_depth)
        ]
    )

    y_bars = sp.rotate([90, 0, 0])(
        [
            spu.left(d)(
                box_section.volume(
                    length=seat_depth - box_section.default_size[0],
                    center=True
                )
            ) for d in [-outer, outer]
        ]
    )

    _mount_bar_centres = (mount_bar_centres - box_section.default_size[0]) / 2.
    mount_bars = spu.up(box_section.default_size[0])(
        sp.rotate([90, 0, 0])(
            [
                spu.left(d)(
                    box_section.volume(
                        length=seat_depth + box_section.default_size[0],
                        center=True
                    )
                ) for d in [-_mount_bar_centres, _mount_bar_centres]
            ]
        )
    )

    frame = sp.union()(
        sp.color('red')(x_bars),
        sp.color('green')(y_bars),
        sp.color('blue')(mount_bars),
    )

    return frame
示例#21
0
def volume():
    mounting_holes = spu.down(1)(place_at_centres([mounting_hole_centres, 0],
                                                  sp.cylinder(
                                                      d=mounting_hole_diameter,
                                                      h=body_length + 2)))

    body = sp.color('orange')(sp.rotate([0, 180, 0])(
        sp.cylinder(d=body_diameter, h=body_length) - mounting_holes, ))

    shaft = sp.color('black')(sp.cylinder(d=shaft_diameter, h=shaft_length), )

    sprocket = sp.color('cyan')(spu.up(sprocket_pos)(sp.cylinder(
        d=sprocket_diameter, h=5, center=True), ))

    return sp.union()(
        body,
        shaft,
        sprocket,
    )
示例#22
0
    def test_body_with_color(self) -> None:
        color_tuple = (1.0, 0.5, 0.25, 0.125)

        self.assertTrue(
            utils.compare_flattened_openscad_children(
                MockEmbodiedComponent(size=2.0, color=color_tuple).body,
                solid.color(color_tuple)(solid.cube(size=2.0)),
            ),
            msg="Color should be applied to the body when being rendered",
        )
示例#23
0
def slats(matress_width, matress_length, overhang):
    return color("peru")(
        translate((0, 0, 11 / 4))(slat_end(matress_width, overhang)) +
        translate((0, matress_length + 2 * overhang, 11 /
                   4))(mirror((0, 1, 0))(slat_end(matress_width, overhang))) +
        union()(*[
            translate((0, overhang + y,
                       11 / 4))(slat_middle(matress_width, overhang))
            for y in slat_displacements(matress_length)
        ]))
示例#24
0
    def render_scad(self, triangles):
        triangle_points = [[
            [C.real, C.imag],
            [A.real, A.imag],
            [B.real, B.imag],
        ] for kolor, A, B, C in triangles]
        print triangles[0]
        print triangle_points[0]
        objects = [
            OpenSCADObject('polygon', {'points': x}) for x in triangle_points
        ]
        for i, obj in enumerate(objects):
            if i % 2 == 0:
                obj = color('black')(obj)
            else:
                obj = color('white')(obj)
            objects[i] = obj

        obj = union()(*objects)
        self.save_scad(obj)
示例#25
0
 def vertices_shape(self, idxs=[0, 1, 2, 3], rotate=True):
     verts = []
     for idx in idxs:
         vert = self.vertices[idx]
         color = self.vert_colors[idx]
         shape = sl.cube([1,1,self.thickness], center=True)
         if rotate:
             for rot in self.rotations:
                 shape = rot.rotate(shape)
         verts.append(sl.color(color)(sl.translate(vert)(shape)))
     return verts
示例#26
0
 def __init__(self, typ, r, center=None, h=None):
     self.rot = ()
     self.R = float(r)
     self.H = h
     self.type = typ
     if not center:
         self.center = np.zeros(3)
     else:
         self.center = center
     if typ == 0:
         self.geometry = sld.sphere(r=self.R)
         self.geometry = sld.color(gen_colr())(self.geometry)
     elif typ == 1:
         self.geometry = sld.cube(size=self.R, center=True)
         self.geometry = sld.color(gen_colr())(self.geometry)
     elif typ == 2:
         self.geometry = sld.cylinder(r=self.R, h=self.H, center=True)
         self.geometry = sld.color(gen_colr())(self.geometry)
     else:
         raise ValueError
示例#27
0
 def getOblongArm(self):
     '''Return a SolidPython object modeling an oblong arm (per specs in
     ArmParams object) bounded by four arcs of circles.        '''
     eps = 0.01
     p, q, s, t, u, w = self.p, self.q, self.s, self.t, self.u, self.w
     r1, r2 = p - s, q - t
     domis, chi, dhi = 2 * max(r1, r2), 1.1, -0.05
     arc1 = back(r1 + s)(cylinder(r=r1, h=1))
     arc2 = back(q - r2)(cylinder(r=r2, h=1))
     rl, vl, p1, p2 = self.solveArcArc(p, q, s, t, u)
     rr, vr, p3, p4 = self.solveArcArc(p, q, s, t, w)
     rightcircle = color(Green)(translate([u, -vl, dhi])(cylinder(r=rl,
                                                                  h=chi)))
     leftcircle = color(Red)(translate([w, -vr, dhi])(cylinder(r=rr,
                                                               h=chi)))
     yrhi, yrlo, ylhi, yllo = p1[1], p2[1], p3[1], p4[1]
     xr, xl = min(p1[0], p2[0]), max(p3[0], p4[0])
     dominol = translate([xl - domis, -yllo,
                          dhi])(cube([domis, yllo - ylhi, chi]))
     dominor = translate([xr, -yrlo, dhi])(cube([domis, yrlo - yrhi, chi]))
     return (arc1 * arc2 - dominol - dominor) + rightcircle + leftcircle
示例#28
0
def plot_space(dict, tl):
	path_labels = sorted(dict.keys())
	path_count = len(path_labels)
	out =[]
	for i in range(path_count):
		color = t55_to_1( colorout2(i,path_count) )
		for j in range(len(dict[path_labels[i]])):
			x = dict[path_labels[i]][j][0]*tl
			y = dict[path_labels[i]][j][1]*tl
			z = j*tl
			out += [solid.color(color)(solid.translate([x,y,z])(solid.cube([tl,tl,1])))]
	return out
示例#29
0
def assembly():
    main_bar = sp.rotate((0, 90, 0))(
        box_section.volume(length=bar_length, center=True)
    )

    return sp.union()(
        sp.color('red')(main_bar),
        spu.down(0.5 * d)(
            mount(),
            sp.rotate((0, 0, 180))(mount()),
        ),
    )
    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))
示例#31
0
def makeBridges(rail, span):
    BridgeN      = rail.Bridges
    BridgeOffset = rail.BridgeOffset
    BridgeWide   = rail.BridgeWide
    BridgeStep   = (rail.CapLen-2*rail.BridgeOffset)/max(1,BridgeN-1)
    CapWide      = rail.CapWide
    asm = None
    proto = cube([BridgeWide, span, rail.CapThik])
    proto = back(span-CapWide)(proto)
    for k in range(BridgeN):
        b = right(BridgeOffset+k*BridgeStep-BridgeWide/2)(proto)
        asm = b + asm if asm else b
    return color(Cyan)(asm) if asm else None
示例#32
0
文件: gear2.py 项目: ghjwp7/gearLegs
 def makeGear(self, sg, ap):
     '''Produce CSG for one gear.  Parameter sg is None if this will be a
     sun gear, else is the sun Gear object.  Other data is in ap, a
     GearAssembly object.        '''
     hh, h0, h1, h2, h3 = 0.1, 1, 1.1, 1.2, 1.3
     nT, tLen, tRad = self.nT, (self.td - self.rd) * .3, self.rd / 2
     asm = cylinder(d=self.rd, h=h2)
     for i in range(nT):
         tAngle = self.sma + 2 * i * pi / nT
         c = rotate(tAngle * 180 / pi)(cube([tLen, tLen / (6 + i), h2]))
         dx, dy = tRad * cos(tAngle), tRad * sin(tAngle)
         asm += translate([dx, dy, 0])(c)
     asm = color(Black)(asm) + color(Magenta)(cylinder(d=self.pd, h=h1))
     centerHole = down(hh)(cylinder(d=ap.h / 10, h=h3))
     asm = (asm + color(Green)(cylinder(d=self.td, h=h0))) - centerHole
     if sg:
         cDist = (sg.pd + self.pd) / 2
         self.cx, self.cy = cDist * cos(self.loca), cDist * sin(self.loca)
         return translate([self.cx, self.cy, 0])(asm)
     else:
         self.cx, self.cy = 0, 0
         return asm
示例#33
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)
示例#34
0
def makeLegs(rail, tapeA, tapeB, maxHi, oLegs, oRamps): 
    '''Make legs based on specs in params - overall x size from rail, y
    overhang sizes from tapeA & B, z heights from maxHi and from tapeA
    & B heights.  Add filler along rail when maxHi > A or B heights:
    maxHi is the highest clearance for any of the tapes used in the
    whole assembly.  When this exceeds (eg) tapeA.high, filler strips
    are needed to thicken the edge of the cap so clearance is reduced
    to tapeA.high instead of maxHi.

    '''   
    eps     = rail.eps
    CapLen  = rail.CapLen
    EndLen  = rail.EndLen
    PadLen  = rail.PadLen
    CapWide = rail.CapWide
    CapThik = rail.CapThik
    LegThik = rail.LegThik
    LegSepO = CapWide - tapeA.oho - tapeB.oh1
    LegSepI = LegSepO - 2*LegThik
    overEnd = 2*PadLen + LegSepO
    LegLen  = CapLen - overEnd
    
    barx  = (CapLen-LegLen-LegSepO)/2
    barz  = CapThik-eps*1.1
    chanA = rampBar(LegLen+LegSepO, tapeA.oho, maxHi-tapeA.high+eps, [barx, 0, barz])
    chanB = rampBar(LegLen+LegSepO, tapeB.oh1, maxHi-tapeB.high+eps, [barx, CapWide-tapeB.oh1, barz])
    legOut  = cappedCube(LegLen, LegSepO, maxHi+eps,   [overEnd/2, tapeA.oho,         CapThik-eps/2])
    legIn   = cappedCube(LegLen, LegSepI, maxHi+2*eps, [overEnd/2, tapeA.oho+LegThik, CapThik-eps/2])

    cutLen = CapLen - 2*EndLen
    cutR = rampSide(cutLen, tapeA.oho-tapeA.ohoa+eps, maxHi+CapThik+eps, [EndLen, tapeA.ohoa-eps/2, -eps/2], -90)
    cutL = rampSide(cutLen, tapeB.oh1-tapeB.oh1a+eps, maxHi+CapThik+eps, [EndLen, CapWide+tapeB.oh1a-tapeB.oh1-eps/2, -eps/2], 90)
    if oLegs:
        lera = legOut-legIn+chanA+chanB if oRamps else legOut-legIn
    else:
        lera = chanA+chanB if oRamps else None
    if lera: lera = color(Green)(lera)
    return lera, color(Red)(cutR)+color(Magenta)(cutL)
示例#35
0
def scaffold(length, color=[0, 0, 1, 1]):
    h = solid.translate([diameter / 2.0, 0, length / 2.0])(
        solid.scale([diameter, diameter, length])(
            solid.cube(center=True)
            )
    ) + solid.translate([0, 0, length / 2.0])(
        solid.scale([center_notch + tool_radius * 2,
                     center_notch, length])(
            solid.cube(center=True)
            )
    )
    # scale & move in Z to ensure overlap
    h = solid.translate([0, 0, -(length * .1)/2.0])(solid.scale([1, 1, 1.1])(h))
    return solid.color(color)(h)
示例#36
0
def flat():
    def offset(i, break_after=5):
        x = 0 if i < break_after else phone_width + layer_y_gap + radius
        y = i * (radius + layer_y_gap)
        y = y - break_after * (radius + layer_y_gap) if x > 0 else y
        return x, y

    layers = []
    for i, l in enumerate(ls):
        x, y = offset(i)
        l_inst = l()
        layer = l_inst.body
        layer = color(l_inst.color)(layer)
        layers.append(right(x)(forward(y)(layer)))

    return union()(layers)
示例#37
0
def splanter():
	bucket = solid.cylinder( r= 8, h= 9)- solid.translate([0,0,2])(solid.cylinder(r=7, h=9))
	hole = solid.cylinder(r=.5, h= 2)
	bottom_holes = []
	for i in range(10):
		for j in range(10):
			x= 2*i-7
			y= 2*j - 7
			if x**2 + y**2<(6.5)**2:
				bottom_holes+=[solid.translate([x,y,-1])(hole)]
	bucket -= join_list(bottom_holes)
	wall_holes = []
	wallh = solid.translate([7,0,1.5])(solid.rotate([0,90,0])(hole))
	for i in range(12):
		wall_holes += [solid.rotate([0,0,i*30])(wallh)]
	wall_ho = join_list(wall_holes)
	bucket -= wall_ho
	bucket -= solid.translate([0,0,2])(solid.rotate([0,0,15])(wall_ho))
	bucket = solid.color("SaddleBrown")(bucket)
	return bucket
示例#38
0
components and thoughts
solid base to place books on
solid back to prevent things falling behind it
sides and roof are tiled in hexagons spaces to save on material
4 columns topped in a circular arch to bear most of the weight.
'''
out_file = make_output()
bord = 2
side = hexfield(4, bord, 4, 50, 50)
side = solid.cube([40,30,2])-side
frame = solid.cube([40,30,2])-solid.translate([2,2,-1])(solid.cube([36,26,4]))
side = side + frame

side2 =solid.rotate([0,-90,0])(side)
side = solid.translate([30,0,0])(solid.rotate([0,-90,0])(side))
sides = solid.color([.1,.1,.9])(side+side2)

base = solid.translate([-2,0,-2])(solid.cube([32,30,2]))
top = solid.translate([0,0,40])(base)
back = solid.translate([0,28,0])(solid.cube([28,2,38]))
panels = solid.color([.25,.25,.15])(base+top+back)

support1 = solid.rotate([0,-90,90])(ssupport())
support2 = solid.translate([0,7,0])(support1)
support1 = solid.translate([0,21,0])(support1)
supports = solid.color([.8, .1, .8])(support1 + support2)

cubby = join_list([sides, panels, supports])

shelf_list = []
for i in range(5):
示例#39
0
###
out_file = make_output()

rcling = 5
rbutt = 20

rail1 = solid.utils.arc( rad = rcling, start_degrees = 0, end_degrees = 180)
rail1 -= solid.utils.arc( rad = rcling-1, start_degrees = 0, end_degrees = 180)

rail2= solid.translate([0,0,6])(rail1)
rail3 = solid.translate([0,0,6])(rail2)
rails = solid.translate([0,0,4])(join_list([rail1,rail2, rail3]))
rails += solid.translate([1,-.5,0])(solid.cube([4,1,20]))
rails = solid.translate([30,20,-rcling+2])((solid.rotate([90,90,0])(rails)))
rails = solid.color([0,0,0])(rails)

buttress1 = solid.utils.arc( rad = rbutt, start_degrees = 0, end_degrees = 90)
buttress1 -= solid.utils.arc( rad = rbutt-3, start_degrees = 0, end_degrees = 180)
buttress1 += solid.translate([0,rbutt-2, -1.5])(solid.cube([rbutt, 2,3]))
buttress2 = solid.translate([0,0,10])(buttress1)
buttresses = buttress1 + buttress2
buttresses = solid.rotate([-90,-90,0])(solid.translate([0,0,5])(buttresses))
buttresses = solid.translate([30-rbutt-5,0,-rbutt+2])(buttresses)
buttresses = solid.color([0,0,.8])(buttresses)

board = solid.color([.4,.4,.4])(solid.cube([30,20,2]))

object = [board, rails, buttresses]

示例#40
0
### new subroutines



###
'''
heights
0-1, base
1-4, lighting
5-6 floor/pane
7-top, chamber
'''
out_file = make_output()
orange = t55_to_1([255,127,0])

battery = solid.color([1,0,0])(solid.cylinder(r=1,h=3))
battery += solid.color([0,0,0])(solid.translate([0,0,3])(solid.cylinder(r=1,h=3)))
battery = solid.translate([11,2,2])(solid.rotate([0,90,0])(battery))

led = solid.cylinder(r=1,h=1, segments = 20)
led += solid.translate([0,0,1])(solid.sphere(r=1, segments= 20))
wire = solid.cube([.2,.2,1])
led += solid.translate([-.1,.8,-1])(wire)+ solid.translate([-.1,-1,-1])(wire)
led = solid.color(orange)(led)
led2 = solid.translate([5,3,1.5])(led)
led = solid.translate([9,3,1.5])(led)

vessel = solid.cube([20,7,15])- solid.translate([1,1,1])(solid.cube([18,5,15]))
vessel -= solid.translate([1,-1,6])(solid.cube([18,3,10]))
vessel -= solid.translate([.5,.25,5.5])(solid.cube([19,.5,10]))
vessel -= solid.translate([1,1,1])(solid.cube([20,5,3]))
示例#41
0
###

out_file = make_output()

clearance = 15
width = 70
length = 120
thick = 20
depth = 40

leg1 = solid.translate([8,8,0])(solid.cylinder(r=4, h=clearance))
leg2 = solid.translate([8,width-8,0])(solid.cylinder(r=4, h=clearance))
leg3 = solid.translate([length-8,8,0])(solid.cylinder(r=4, h=clearance))
leg4 = solid.translate([length-8,width-8,0])(solid.cylinder(r=4, h=clearance))
legs = join_list([leg1, leg2, leg3, leg4])
legs = solid.color([0,0,0])(legs)

table = solid.cube([length,width,thick])
table -= solid.translate([depth+3,-1,3])(solid.cube([length+1-depth ,width+2,thick-6]))
table -= solid.translate([-1,3,3])(solid.cube([depth,width-6,thick-6]))
table = solid.translate([0,0,clearance])(table)
table = solid.color(t55_to_1([140,80,33]))(table)

mid = solid.translate([length-20,width/2,clearance])(solid.color([0,0,0])(solid.cylinder(r=5,h=thick-1)))
glass = solid.translate([0,0,clearance+thick])(solid.color([1,1,1,.3])(solid.cube([length,width,3])))

drawer = solid.cube([depth,width-6, thick-7 ])
drawer -= solid.translate([1,1,1])(solid.cube([depth-2, width-8, thick-5]))
drawer += solid.cube([2,width-6, thick-6])

handle, theth, rh  = circle_arch(30, 7, 2)
示例#42
0
	a2 = solid.translate([50,0,70])(a1)
	a1 = solid.translate([-40,0,70])(a1)
	a1 = solid.rotate([0,10,0])(a1)
	a2 = solid.rotate([0,-10,0])(a2)
	return a1+a2
	
def shead():
	head = solid.translate([-8,-13,181-27])(solid.cube([24,24,27]))
	return head



out_file = make_output()

rod = solid.translate([70,0,0])(solid.cylinder(r= 10, h = 181 ))
rod = solid.color([0,0,0])(rod)

trunk = strunk()
legs = slegs()
head = shead()
arms = sarms()
body = [trunk, head, legs, arms]
body = solid.color([.1,.9,.1])(join_list(body))

object = [rod, body]
print>>out_file, solid.scad_render(join_list(object))

# object=[]
# for i in range(100):
# 	x = int( math.cos(float(i)/5)*10+10)
# 	object+= [solid.translate([i,0,0])( solid.cylinder(r=1,h=x ) )]
示例#43
0
	wall_ho = join_list(wall_holes)
	bucket -= wall_ho
	bucket -= solid.translate([0,0,2])(solid.rotate([0,0,15])(wall_ho))
	bucket = solid.color("SaddleBrown")(bucket)
	return bucket
###
out_file = make_output()
'''
light measurements
123 cm long
15 cm wide
5 cm tall
1:30 slope, or 6 degree slant.
'''
light = solid.cube([5,15,123])- solid.translate([1,1,1])(solid.cube([5,13,121]))
light = solid.color([.4,.4,.4])(light)
tube1 = solid.color([1,1,1])(solid.translate([4,4,1])(solid.cylinder(r=2, h=121)))
tube2 = solid.translate([0,6,0])(tube1)

trough = solid.color([.4,.4,.4])(solid.translate([15,-2.5,0])(solid.cube([10,20,123])))
trough -= solid.translate([16,-1.5,-1])(solid.cube([8,18,125]))

thole = solid.translate([14,7.5,10])(solid.rotate([0,90,0])(solid.cylinder(r=8, h = 5) ))
tslots = []
for i in range(6):
	tslots += [solid.translate([0,0,i*18])(thole)]
trough -= solid.translate([0,0,7])(join_list(tslots))

bucket = solid.translate([22.5,7.5,10])(solid.rotate([0,-90,0])(splanter()))
bslots = []
for i in range(6):
示例#44
0
	wall_ho = join_list(wall_holes)
	bucket -= wall_ho
	bucket -= solid.translate([0,0,2])(solid.rotate([0,0,15])(wall_ho))
	bucket = solid.color("SaddleBrown")(bucket)
	return bucket
###
out_file = make_output()
'''
light measurements
123 cm long
15 cm wide
5 cm tall
1:30 slope, or 6 degree slant.
'''
light = solid.cube([5,15,123])- solid.translate([1,1,1])(solid.cube([5,13,121]))
light = solid.color([.4,.4,.4])(light)
tube1 = solid.color([1,1,1])(solid.translate([4,4,1])(solid.cylinder(r=2, h=121)))
tube2 = solid.translate([0,6,0])(tube1)

trough = solid.color([.4,.4,.4])(solid.translate([15,-2.5,0])(solid.cube([10,20,123])))
trough -= solid.translate([16,-1.5,-1])(solid.cube([8,18,125]))

thole = solid.translate([14,7.5,10])(solid.rotate([0,90,0])(solid.cylinder(r=8, h = 5) ))
tslots = []
for i in range(6):
	tslots += [solid.translate([0,0,i*18])(thole)]
trough -= solid.translate([0,0,7])(join_list(tslots))

bucket = solid.translate([22.5,7.5,10])(solid.rotate([0,-90,0])(splanter()))
bslots = []
for i in range(6):
示例#45
0
文件: cc3d.py 项目: daveansell/camcam
def path_render3D(self, pconfig, border=False):
	global _delta, PRECISION, SCALEUP
	self.rotations_to_3D()
	config={}
	config=self.overwrite(config,pconfig)
      	inherited = self.get_config()
#               if('transformations' in config):
      	config=self.overwrite(config, inherited)
	if border==False and 'zoffset' in pconfig:
                zoffset= pconfig['zoffset']
	elif 'zoffset' in config and  config['zoffset']:
		zoffset= config['zoffset']
	else:
		zoffset = 0
	if 'thickness' not in config:
		config['thickness']=pconfig['thickness']
	if config['z0'] is None or config['z0'] is False:
		z0=0
	else:
		z0=config['z0']
	
	if  border==False:
                        z0 += 1

	if (config['z1'] is False or config['z1'] is None) and config['z0'] is not None and config['thickness'] is not None:
        	if  border==False:
                 	z1 = - config['thickness']- 20
           	else:
                   	z1 = - config['thickness']
	else:
		z1= config['z1']
	z0 *=config['zdir']
	z1*=config['zdir']
	#	z0 = - config['thickness'] - z0
	#	z1 = - config['thickness'] - z1
# try to avoid faces and points touching by offsetting them slightly
	z0+=_delta
	z1-=_delta
	_delta+=0.00001
	outline = []
	points = self.polygonise(RESOLUTION)
#	extrude_path = [ Point3(0,0,zoffset + float(z0)), Point3(0,0, zoffset + float(z1)) ]
	for p in points:
		outline.append( [round(p[0],PRECISION)*SCALEUP, round(p[1],PRECISION)*SCALEUP ])
	outline.append([round(points[0][0],PRECISION)*SCALEUP, round(points[0][1],PRECISION)*SCALEUP])
#		outline.append( Point3(p[0], p[1], p[2] ))
#	outline.append( Point3(points[0][0], points[0][1], points[0][2] ))
	h = round(abs(z1-z0),PRECISION)*SCALEUP
	bottom = round((min(z1,z0)+zoffset),PRECISION) *SCALEUP
#	extruded = extrude_along_path(shape_pts=outline, path_pts=extrude_path)
	
	if self.extrude_scale is not None:
                scale = self.extrude_scale
		if self.extrude_centre is None:
			self.extrude_centre = V(0,0)
		centre = (PSharp(V(0,0)).point_transform(config['transformations']).pos+self.extrude_centre)
		centre = [centre[0], centre[1]]
		uncentre = [-centre[0], -centre[1]]	
		extruded = solid.translate([0,0,bottom])(
				solid.translate(centre)(
					solid.linear_extrude(height=h, center=False, scale = scale)(
						solid.translate(uncentre)(solid.polygon(points=outline)))))
        else:
                scale = 1
	        extruded = solid.translate([0,0,bottom])(solid.linear_extrude(height=h, center=False)(solid.polygon(points=outline)))
	#extruded = translate([0,0,bottom])(linear_extrude(height=h, center=False)(solid.polygon(points=outline)))
#	if 'isback' in config and config['isback'] and border==False:
#		extruded = mirror([1,0,0])(extruded )
	if 'colour' in config and config['colour']:
		extruded = solid.color(self.scad_colour(config['colour']))(extruded)
	if hasattr(self, 'transform') and self.transform is not None and self.transform is not False and 'matrix3D' in self.transform:
		if type(self.transform['matrix3D'][0]) is list:
			extruded=solid.translate([-self.transform['rotate3D'][1][0], - self.transform['rotate3D'][1][1]])(extruded)
			extruded=solid.multmatrix(m=self.transform['matrix3D'][0])(extruded)
			extruded=solid.translate([self.transform['rotate3D'][1][0],  self.transform['rotate3D'][1][1]])(extruded)
		else:
			extruded=solid.multmatrix(m=self.transform['matrix3D'])(extruded)
	if hasattr(self, 'transform') and self.transform is not None and self.transform is not False and 'rotate3D' in self.transform:
		if type(self.transform['rotate3D'][0]) is list:
			print [-self.transform['rotate3D'][1][0], - self.transform['rotate3D'][1][1], - self.transform['rotate3D'][1][2]- zoffset]
			extruded=solid.translate([-self.transform['rotate3D'][1][0], - self.transform['rotate3D'][1][1], - self.transform['rotate3D'][1][2]- zoffset])(extruded)
			extruded=solid.rotate([self.transform['rotate3D'][0][0], self.transform['rotate3D'][0][1],self.transform['rotate3D'][0][2] ])(extruded)
			extruded=solid.translate([self.transform['rotate3D'][1][0], self.transform['rotate3D'][1][1], self.transform['rotate3D'][1][1] + zoffset])(extruded)
		else:
			extruded=solid.rotate([self.transform['rotate3D'][0], self.transform['rotate3D'][1],self.transform['rotate3D'][2] ])(extruded)
	if hasattr(self, 'transform') and self.transform is not None and self.transform is not False and 'translate3D' in self.transform:
		extruded=solid.translate([self.transform['translate3D'][0], self.transform['translate3D'][1],self.transform['translate3D'][2] ])(extruded)
	return [extruded]