def standoff(thickness): """ Stackable, gluable 3D printable standoff connector w/pivot axis. """ global standnumber OT = (0, 0, 0) OQ = (0, 0, 1, 0) OP = (OT, OQ) peg_height = 5.5 clearance = 3.2 base = solid.cylinder(r=4, h=thickness, segments = 100) conn = solid.cylinder(r=1.9, h=peg_height, segments = 100) #wtf??? can't get z axis on Joint to work, no matter what I put it just #defaults to 0, so I'm going to orient everything at the origin. anchor = Joint((0,0, -100),Z_JOINT_POSE[1],name="A") b_placed = solid.translate([0,0,-thickness])(base) unit = b_placed+ conn - solid.translate([0,0,-(clearance+ thickness)])(conn) pm = PolyMesh(generator = unit) stand = Body( pose = OP, joints = [anchor], elts = [Layer(pm, name="lol", color = 'yellow')], name = 'standoff'+str(standnumber) ) standnumber = standnumber + 1 return stand, b_placed
def spacerMaker(radius, right, out, spacer, name): s = solid.rotate(a = [-90, 0, 0])\ (solid.cylinder(r=outerD/2, h=spacer, segments = 20)) s1 = solid.rotate(a = [90, 0, 0])\ (solid.cylinder(r=innerD/2, h=3*spacer, segments = 20, center=True)) s = solid.difference()(s, s1) """s1 = solid.rotate(a = [90, 0, 0])\ (solid.cylinder(r=innerD/2, h=2*border, segments = 20)) s1 = solid.translate(v = [0, spacer+2*border, 0])(s1) s = s + s1""" if not out: s = solid.translate(v = [0, -spacer, 0])(s) off = radius - width else: off = radius s = solid.translate(v = [0, off, 0])(s) if right: s = solid.rotate(a = [0, 0, -90])(s) s = PolyMesh(generator=s) s.save("heliodon/spacer" + name +".stl") return s
def connector(): """ Connector 2.0!!! comes in two better sized segments, now with indent! """ global pinnumber OT = (0, 0, 0) OQ = (0, 0, 1, 0) OP = (OT, OQ) base = solid.cylinder(r=4, h = 4, segments = 100) conn = solid.cylinder(r = 1.9, h = 8, segments = 100 ) #8.2 anchor = Joint( ((0, 0, 8),Z_JOINT_POSE[1]), name="pin" ) bottom = base+ solid.translate([0,0,4])(conn) cap = solid.translate([0,0,4+6.4])(base) dimple_cap = cap - bottom p1 = PolyMesh(generator = bottom) p2 = PolyMesh(generator = dimple_cap) #p1.save("pin.stl") #p2.save("cap.stl") poly = p1+p2 pin = Body( pose = OP, joints = [anchor], elts = [Layer(poly, name='lol', color = 'blue')], name = 'coupler'+str(pinnumber) ) pinnumber = pinnumber + 1 return pin
def strunk(): c1 = solid.cylinder(r= 15, h = 70) c2 = solid.translate([9,0,0])(solid.cylinder(r=15, h= 70)) m1 = solid.translate([0,-15,0])(solid.cube([9,30,70])) total = join_list([c1,c2,m1]) total = solid.translate([0,0,84])(total) return total
def hJoint (right, out, name): female = out # Create the outer cylinder j = solid.rotate(a = [-90, 0, 0])\ (solid.cylinder(r=outerD/2, h=width, segments = 20)) j = solid.translate(v = [0, 0, outerD/2])(j) # Create the clamp j = j + solid.cube([outerD,width,border]) j = j + solid.translate([0, 0, border+thick])\ (solid.cube([outerD,width,border])) j = j - solid.translate(v = [0, 0, border])(solid.cube([outerD,width,thick+2*t])) # Create the center hole c = solid.rotate(a = [90, 0, 0])\ (solid.cylinder(r=innerD/2,center=True, h=2*width, segments=20)) if female: if (right and out) or (not right and not out): off = -(width-6) else: off = width-6 c = solid.translate(v = [0, width/2+off, outerD/2])(c) else: c = solid.translate(v = [0, width/2, outerD/2])(c) j = solid.difference()(j, c) if not female: if (right and out) or (not right and not out): off = -border else: off = border c = solid.rotate(a = [90, 0, 0])\ (solid.cylinder(r=(outerD)/2-border,center=True, h=width, segments = 20)) c = solid.translate(v = [0, width/2+off, outerD/2])(c) cube = solid.cube([outerD, width, 2*border+thick]) c = solid.difference()(c, \ solid.translate(v = [-outerD/2.0, 0, 0])(cube)) j = solid.difference()(j, c) # Create bolt holes j = solid.difference()(j, solid.translate(v=[.65*outerD, width/2, 0]) (solid.cylinder(r=bolt/2, h = outerD, segments = 20))) j = solid.difference()(j, solid.translate(v=[.85*outerD, width/2, 0]) (solid.cylinder(r=bolt/2, h = outerD, segments = 20))) # Support bar # j = j + solid.translate(v = [-thick,0,border])(solid.cube([thick, width, thick+2*t])) # Move and rotate j = solid.translate(v=[0, 0, -border])(j) if right: j = solid.translate(v=[width, 0, 0])(solid.rotate(a=[0, 0, 90])(j)) j = PolyMesh(generator=j) j.save("heliodon/joint" + name + ".stl") return j
def make_stupid_connector(): """ Make "smarter" by having a recessed point in the cap for a glue hole, make more flush with bars. """ base = solid.cylinder(r=4, h = 2, segments = 100) conn = solid.cylinder(r = 1.8, h = 6.8, segments = 100 ) bottom = base+ solid.translate([0,0,2])(conn) p1 = PolyMesh(generator = bottom) p2 = PolyMesh(generator = base) p1.save("pin.stl") p2.save("cap.stl")
def locked_offset(): global locked_count name = "locked_" + str(locked_count) locked_count +=1 j_name = "locked_joint_" + str(locked_count) thickness = 6 #span 2 layers peg_height = 3.2 clearance = 3.2 base = solid.cylinder(r=1.9, h=thickness, segments = 100) conn1 = solid.cube([4/math.sqrt(2),4/math.sqrt(2),3],center=True) conn2 = solid.cube([4/math.sqrt(2),4/math.sqrt(2),3],center=True) #wtf??? can't get z axis on Joint to work, no matter what I put it just #defaults to 0, so I'm going to orient everything at the origin. b_placed = solid.translate([0,0,3])(base) unit = b_placed + solid.translate([0,0,1.5])(conn1) + solid.translate([0,0,10.5])(conn2) pm = PolyMesh(generator = unit) pm.save("lock.stl") j1 = Joint( ((0, 0, 12),NZ_JOINT_POSE[1]), #9 name=j_name ) OT = (0, 0, 0) OQ = (0, 0, 1, 0) OP = (OT, OQ) layers=Layer( pm, name="lol", color='blue' ) b = Body(pose=OP, elts=[layers], joints=[j1], name=name) return b, name, j_name
def create_servo_mount(): """ right now designed to fit Jacobs institute model """ width = 6.5 length = 20.0 depth = 2.3 voffset = -18.5 - 9 left_bar = solid.cube([width,length,depth], center = True) hole = solid.cylinder(r=2,h=10, center =True,segments = 100) hole1 = solid.translate([0,4,0])(hole) hole2 = solid.translate([0,-4,0])(hole) left_bar = solid.difference()(left_bar, hole1) left_bar = solid.difference()(left_bar, hole2) right_bar = solid.cube([width,length,depth],center = True) right_bar = solid.difference()(right_bar, hole1) right_bar = solid.difference()(right_bar, hole2) left_spread = -30.0 right_spread = 17.0 left_bar = solid.translate([left_spread, 0,-(depth/2 + voffset)])(left_bar) right_bar = solid.translate([right_spread, 0 , -(depth/2+voffset)])(right_bar) connector = solid.cube([(right_spread - left_spread) + width,width,depth],center=True) placed_connector = solid.translate([(left_spread+right_spread)/2,-(length/2 +width/2), -(depth/2+voffset)])(connector) total_mount = left_bar + placed_connector + right_bar pl = PolyMesh(generator= total_mount) attach_point1 = PolyMesh(generator =solid.translate([width, 0,0])(right_bar)) attach_point2 = PolyMesh(generator =solid.translate([-width, 0,0])(left_bar)) return pl, attach_point1, attach_point2
def create_support_bar(jt, offset): """ create a support bar to the point from the origin XY plane account for default klann spacing for now. plan on gluing two segments with acetone """ ((dx,dy,dz),_) = jt.pose placed_base = solid.translate([0,0,-offset])(solid.cylinder(r = 4, h = offset)) clevis_pin = solid.translate([0,0,-(offset+5.5)])(solid.cylinder(r=1.9, h = 5.5,segments=300)) total = placed_base + clevis_pin translated = solid.translate([dx,dy,dz])(total) pl = PolyMesh(generator=translated) attach = PolyMesh(generator = solid.translate([dx,dy,dz])(placed_base)) return pl, attach
def create_crank_shaft(save = False): """ Oriented relative to the shaft that will be driven at the origin in the +Z direction. """ global shaft_count name = "shaft_" + str(shaft_count) j_name = "shaft_joint_" + str(shaft_count) mount_plate = solid.cylinder(r = 10, h= 3) shaft = solid.cube([4/math.sqrt(2),4/math.sqrt(2),6], center = True) shifted_shaft = solid.translate([0,0,3])(shaft) total = mount_plate+shaft pl = PolyMesh(generator=total) if save: pl.save("crank.stl") j1 = Joint( ((0, 0, 0),Z_JOINT_POSE[1]), name=j_name ) OT = (0, 0, 0) OQ = (0, 0, 1, 0) OP = (OT, OQ) layers=Layer( pl, name="lol", color='blue' ) b = Body(pose=OP, elts=[layers], joints=[j1], name=name) return b, name, j_name
def sarms(): hand = solid.sphere(r=4) arm = solid.translate([0,0,4])( solid.cylinder(r=4, h = 68)) shoulder = solid.translate([0,0,72])( solid.sphere(r=4)) a1 = hand+arm+shoulder 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 arc(radius): a = solid.difference()( solid.cylinder(r=radius, h=thick, segments=48), solid.cylinder(r=radius-width, h=thick, segments=48)) a = solid.intersection()(a, solid.cube([radius, radius, thick])) a = solid.difference()(a, solid.translate(v=[.75*outerD, radius-width/2, 0]) (solid.cylinder(r=bolt/2, h=2*thick, segments=20, center=True))) a = solid.difference()(a, solid.translate(v=[radius-width/2, .75*outerD, width/2.0]) (solid.cylinder(r=bolt/2, h=2*thick, segments=20, center=True))) c = solid.translate(v=[radius-width/2, 0, 0])\ (solid.cylinder(r=bolt/2, h=2*thick, segments=20, center=True)) # Add bolt holes for fastening the two sheets of acryllic together for step in range(1,3): a = solid.difference()(a, solid.rotate(a = [0,0, step * 30])(c)) PolyLine(generator = solid.projection()(a)).save("heliodon/a" + str(radius) + ".dxf") return PolyMesh(generator=a)
def ssupport(): arch1 ,thet1, rad1= circle_arch(30.0, 5.0, 3) arch1 = solid.translate([14,-28/2,0])(solid.rotate([0,0, -thet1/2])(arch1)) arch2 = solid.translate([0,0,1])(arch1) arch3 = solid.translate([0,0,-1])(arch1) arch1 = join_list([arch1, arch2, arch3]) pillar1 = solid.rotate([0,90,0])(solid.cylinder(r=2, h=35) ) pillar1 = pillar1 - solid.translate([-1,0,-3])(solid.cube([37,4, 8])) pillar2 = solid.rotate([180,0,0])(solid.translate([0,28])(pillar1)) return join_list([arch1, pillar1, pillar2])
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
def create_offset(): """ Oriented relative to the shaft that will be driven at the origin in the +Z direction. TODO: Consider refactoring into mechanism with joint at O. """ global offset_count name = "offset_" + str(offset_count) offset_count +=1 j_name = "offset_joint_" + str(offset_count) thickness = 6 #span 2 layers peg_height = 5.5 clearance = 3.2 base = solid.cylinder(r=4, h=thickness, segments = 100) conn = solid.cylinder(r=1.9, h=peg_height, segments = 100) #wtf??? can't get z axis on Joint to work, no matter what I put it just #defaults to 0, so I'm going to orient everything at the origin. b_placed = solid.translate([0,0,-thickness])(base) unit = b_placed+ conn - solid.translate([0,0,-(clearance+ thickness)])(conn) pm = PolyMesh(generator = unit) pm.save("offset.stl") j1 = Joint( ((0, 0, 0),NZ_JOINT_POSE[1]), name=j_name ) OT = (0, 0, 0) OQ = (0, 0, 1, 0) OP = (OT, OQ) layers=Layer( pm, name="lol", color='blue' ) b = Body(pose=OP, elts=[layers], joints=[j1], name=name) return b, name, j_name
def create_shaft_connector(): """ Oriented relative to the shaft that will be driven at the origin in the +Z direction. TODO: Consider refactoring into mechanism with joint at O. """ mount_plate = solid.cylinder(r = 10, h= 3) shaft = solid.translate([-2,-2,0])(solid.cube([4,4,20])) shifted_shaft = solid.translate([0,0,3])(shaft) total = mount_plate+shaft pl = PolyMesh(generator=total) return pl
def produce_slice(lower, upper, outer_offset=0.0): res = [] step = (upper - lower) / slice_steps for i, f in enumerate(frange(lower, upper, step)): r1 = cone_at(f) r2 = cone_at(f + step) offset = i * step + outer_offset res.append( solid.translate([0, 0, offset])( solid.cylinder(h=step, r1=r1, r2=r2) ) ) return res
def genAsOpenscad(self): """Generates cone geometry as solid python object. Useful if geometry is used to be passed to openscad. Returns: solid.solidpython.openscad_object: Solid python object. """ z=self.getZExtend() cone=solid.translate([self.center[0],self.center[1],min(z)])(solid.cylinder(r1=self.lowerRadius,h=self.height,r2=self.upperRadius)) return cone
def genAsOpenscad(self): """Generates cylinder geometry as solid python object. Useful if geometry is used to be passed to openscad. Returns: solid.solidpython.openscad_object: Solid python object. """ z=self.getZExtend() cylinder=solid.translate([self.center[0],self.center[1],min(z)])(solid.cylinder(r=self.radius,h=abs(self.height))) return cylinder
def rationalize_segment(seg,joints,name, state= {}, is_locked = False): p1 = seg p2 = seg if type(seg) != Point: p1 = seg.p1 p2 = seg.p2 buff = 6 thickness = 3 p1x = p1.x.evalf(subs=state) p1y = p1.y.evalf(subs=state) p2x = p2.x.evalf(subs=state) p2y = p2.y.evalf(subs=state) c = solid.cylinder(r= buff, h =thickness, segments =100) c1 = solid.translate([p1x, p1y, 0])(c) c2 = solid.translate([p2x, p2y, 0])(c) link = solid.hull()(c1,c2) OT = (0, 0, 0) OQ = (0, 0, 1, 0) OP = (OT, OQ) pm = PolyMesh(generator=link) for joint in joints: if is_locked: pm = square_neg(pm,joint) else: pm = clevis_neg(pm,joint) if "conn" in name: #this is a connector joint pm = add_servo_mount(pm) layers=Layer( pm, name="lol", color='green' ) link_body = Body(pose=OP, elts=[layers], joints=joints, name=name) return link_body
def hexfield(R, sep, thick, xmax, ymax): list = [] h1=numpy.array((0,1,0)) h2=numpy.array((.5*3**.5,-.5,0)) total = R * 3**.5 + sep i=0 j=0 move = h1*j*total+h2*i*total while move[0] <= xmax: while move[1] <= ymax: list_move = numpy_to_list(move) hex = solid.cylinder(r=R, h=thick, segments=6) hex = solid.translate(list_move)(hex) list +=[hex] j+=1 move = h1*j*total+h2*i*total #print move i+=1 j=0 move = h1*j*total+h2*i*total field = join_list(list) field = solid.translate([0,0,-1])(field) return field
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])(
a1 = hand+arm+shoulder 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)
def clevis_neg(poly, joint): transform = matrix_pose(joint.pose) h_hole = PolyMesh(generator=solid.cylinder(r=2, h=20, segments=100,center =True)) tf_snap_sub = transform * h_hole return poly - tf_snap_sub
g = float(color[1])/255 b = float(color[2])/255 return [r,g,b] ### 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])))
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) screw_hole_2 = u.right(screw_offset_2)(screw_hole) wire_run = u.up(20)(s.cube(size=[spacer_depth, 4, 9])) final = body - slot - slot_round - screw_hole_1 - screw_hole_2 - wire_run s.scad_render_to_file(final, __file__.replace('.py', '.scad'), variables=v)
def slegs(): l1= solid.translate([-3,0,0])(solid.cylinder(r=5, h= 84)) l2= solid.translate([13,0,0])(l1) out = l1+l2 return out
### 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]))
def save(self, file): # Add screws screw_head_radius = 3.0 screw_head_length = 2.5 screw_shaft_radius = 1.40 # 2.8mm diameter = 0.3mm extra screw_shaft_length = 15.0 head = sc.translate([0,0,screw_shaft_length])( sc.cylinder(h=screw_head_length + 100, r=screw_head_radius, segments=self._round_segments) ) shaft = sc.cylinder(h=screw_shaft_length + 0.1, r=screw_shaft_radius, segments=self._round_segments) screw_down = sc.translate([0,0,-screw_shaft_length - screw_head_length])( sc.union()(head,shaft) ) # Origin is top of screw screw_side = sc.rotate([0,90,0])(screw_down) sc.scad_render_to_file(screw_side, "screw.scad", include_orig_code=False) # Place 4 screws in the right side screw_recess_side = 1.0 assert screw_recess_side < self._thickness_xy side_thick = self._thickness_xy - self._board_slot ymin = self._board_bbox.bot() - self._board_slot - side_thick/2.0 ymax = self._board_bbox.top() + self._board_slot + side_thick/2.0 zmin = -self.cavity_bot - self._thickness_z + screw_head_radius + self._min_screw_material zmax = self.cavity_top - self._thickness_z - screw_head_radius x = self._board_bbox.right() + self._thickness_xy + 1.0 # Add screws to the side for y in [ymin, ymax]: for z in [zmin, zmax]: self._case -= sc.translate([x,y,z])(screw_side) print "Free material around side screws: {0}mm".\ format(self._thickness_xy - self._board_slot - 2*screw_shaft_radius) # Add screws to the top screw_recess_top = 0 assert screw_recess_top < self._thickness_z min_screw_depth = 3.0 #Lowest depth screw can possibly go zmin = self.cavity_top + screw_head_length + min_screw_depth z_want = self.cavity_top + self._thickness_z - screw_recess_top z = max(zmin, z_want) ys = [self._board_bbox.top() + self._board_slot + (self._thickness_xy - self._board_slot)/2.0, self._board_bbox.bot() - self._board_slot - (self._thickness_xy - self._board_slot)/2.0] xs = [self._board_bbox.left() + screw_head_radius, self._board_bbox.right() - screw_shaft_length - 1.0] for y in ys: for x in xs: self._case -= sc.translate([x,y,z])(screw_down) #Top area: top of the case top_area_select = self._board_bbox.copy().pad(self._thickness_xy*2) top_area_select = rect2scad(top_area_select, self._thickness_z + 0.1, self.cavity_top - 0.05) # main_area is the case without the top or side main_area = self._board_bbox.copy() main_area.bounds[0][0] -= self._thickness_xy*2 main_area.bounds[0][1] -= self._thickness_xy*2 main_area.bounds[1][0] -= 0.05 #So we don't have a degenerate face main_area.bounds[1][1] += self._thickness_xy*2 main_area = rect2scad(main_area, self.height * 2, z_start = -self.height - 10) #Add screws to hold down the board remove_top = self._board_bbox.copy().pad(self._thickness_xy*2) remove_top = rect2scad(remove_top, self.height, self.cavity_top + 0.05) x = self._board_bbox.left() + (self._board_bbox.width + self._board_slot*2)/2.0 ys = [self._board_bbox.bot() - screw_shaft_radius - 0.5, self._board_bbox.top() + screw_shaft_radius + 0.5] z = screw_head_length for y in ys: self._case -= (sc.translate([x,y,z])(screw_down) - remove_top) print "Board screw location: ({0}, {1})".format(x,y) # Separate out the sides of the case main_part = self._case * main_area side = self._case - (main_area + top_area_select) # Side of the case, first part to screw on #The top of the case (screwed on after the side) top = self._case * top_area_select main_part -= top_area_select sc.scad_render_to_file(top, "top." + file, include_orig_code=False) sc.scad_render_to_file(main_part, "main." + file, include_orig_code=False) sc.scad_render_to_file(side, "side." + file, include_orig_code=False) exploded = sc.union()( main_part, sc.translate([40,0,0])(side), sc.translate([0,0,40])(top) ) sc.scad_render_to_file(exploded, "exploded." + file, include_orig_code=False) sc.scad_render_to_file(self._case, file, include_orig_code=False)
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): bslots += [solid.translate([0,0,i*18])(bucket)]