def makestack(dia): stack = union()(cylinder(d=dia + WALL * 2, h=TRAY_H - FLOOR) - up(FLOOR)(cylinder(d=dia, h=TRAY_H))) hole_pcg = 0.7 stack -= hole()(down(1)(cylinder(d=dia * hole_pcg, h=TRAY_H))) stack -= hole()(translate([-dia / 2 - WALL, -dia / 2 * hole_pcg, -1])(cube( [dia / 2 + WALL, dia * hole_pcg, TRAY_H * 3]))) return stack
def slat_end(matress_width, overhang): length = matress_width + overhang * 2 half_cross = hole()(cube((3 / 2, 11 / 2, 1 / 4)) + translate((0, 2, 0))(cube((3 / 2, 3 / 2, 3 / 4)))) return part()(OneBySix(length) - translate((length - 3 / 2 - overhang, 0, 0))(half_cross) - translate((overhang, 0, 0))(half_cross))
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)))
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) ])))
def base_side(matress_length, overhang): end_slat_half_cross = hole()(cube((3 / 2, 2, 1 / 2)) + translate((0, 7 / 2, 0))(cube((3 / 2, 2, 1 / 2)))) slat_half_cross = hole()(cube((3 / 2, 7 / 2, 1 / 2))) base_half_cross = hole()(cube((3 / 2, 3 / 2, 11 / 8))) return color("tan")( part()(TwoByFour(matress_length + 2 * overhang, (Y, Z, X)) + translate((0, overhang, 0))(base_half_cross) + translate((0, overhang + matress_length - 3 / 2, 0))(base_half_cross) + translate((0, 0, 3))(end_slat_half_cross) + translate((0, 2 * overhang + matress_length - 11 / 2, 3))(end_slat_half_cross) - union()(*[ translate((0, overhang + y, 3))(slat_half_cross) for y in slat_displacements(matress_length) ])))
def thing(d=27.9, h=10, width=16, width_hole=10.2, z=0, X=45): center = solid.cube(size=(width, width, h), center=True) - solid.hole()( solid.cube(size=(width_hole, width_hole, h * 2), center=True)) axis_base = solid.cube(size=(d, width_hole / 2, h), center=True) axis_1 = solid.rotate(a=X)(axis_base) axis_2 = solid.rotate(a=-X)(axis_base) outer_cylinder = solid.cylinder(d=d, h=h, center=True, segments=256) ret = (center + axis_1 + axis_2) * outer_cylinder return solid.translate(v=(0, 0, z + h / 2))(ret)
def makeTube(idi, odi, hi, transl, half, eps): '''Make a tube or half-tube. idi, odi = inner and outer diameters; hi= height; transl = [x,y,z] translation vector; half = whole or half indicator: -1=right half, 0=whole, +1=left half. ''' loss = cylinder(d=idi, h=hi+2*eps) tube = cylinder(d=odi, h=hi) - hole()(down(eps)(loss)) if half: block = cube([odi/2, odi+2*eps, hi+2*eps]) dx = -(odi+eps)/2 if half < 0 else 0 tube -= translate([dx, -(eps+odi)/2,0])(block) return translate(transl)(tube)
def cage_base_plate(assemble=False): """base_plate with 3 clamps for new HolMOS-Cage""" cage_base = 30 stabilizer_base = 60 stabilizer_height = 10 angle = -atan(cage_base / 2 / stabilizer_base) / math.pi * 180 plate = translate((0, stabilizer_base / 2, 0))(cube( (cage_base + 4, stabilizer_base - 10, stabilizer_height), center=True)) plate -= translate((-cage_base, stabilizer_base / 2, 0))(rotate( (0, 0, angle))(cube( (cage_base, stabilizer_base, 2 * stabilizer_height), center=True))) plate -= translate((cage_base, stabilizer_base / 2, 0))(rotate( (0, 0, -angle))(cube( (cage_base, stabilizer_base, 2 * stabilizer_height), center=True))) for y in (15, 40): plate += hole()(translate([0, y, 5])(cylinder(d=12, center=True, h=10))) plate += hole()(translate([0, y, -5])(cylinder(d=7.5, center=True, h=2 * 10))) for y in (10, stabilizer_base - 5): strut_thick = 3 strut = strut_with_holes(hole_dist=40, strut_thick=strut_thick, strut_width=10) plate += translate((0, y, (strut_thick - 10) / 2))(rotate( (0, 0, 90))(strut)) plate = translate((0, -25, 0))(plate) plate += translate((0, 0, 10))(cage_3_clips(z_length=30)) return plate
def shell(obj: OpenSCADObject, wall: float, center_x: float, center_y: float, center_z: float) -> OpenSCADObject: ''' create a shell of a given object centered at [center_x, center_y, center_z] scaled by wall as a percentage. PARAMETERS: center_x, center_y, center_z: center coordinates of the hollow shell wall: thickness of the shell given as a percentage of the given object RETURNS: shell of given OpenSCADObject ''' solution = obj - hole()(translate([ center_x / 2, center_y / 2, center_z / 2 ])(scale([wall, wall, wall])(obj))) return solution
def makeCrossbar(railModel, chanNames, barThik, barWidth, nBars): eps = railModel.eps capW = railModel.CapWide holeD = railModel.PillarID specs = [channelSpecs[cname] for cname in chanNames] skips = [spec.ChanWide - spec.ChanHang1 - spec.ChanHang2 for spec in specs] barLen = sum([capW + skip for skip in skips]) bar = cube([barWidth, barLen, barThik]) holeAt = capW / 2 for skip in skips: bar += hole()(translate([barWidth / 2, holeAt, -eps])(cylinder(d=holeD, h=barThik + 2 * eps))) holeAt += capW + skip asm = None for line in range(nBars): asm = left(barWidth + .1)(bar + asm if asm else bar) return asm
def cylinderAsm(dii, doo, hss): '''Produce an assembly of specified cylinders, given three lists that specify sequences of inner diameters, outer diameters, and heights. Consecutive triples (of diameters and height) specify the ends of a cylindrical or conical portion of an assembly, in ascending order of heights; except if the next height in sequence isn't more than the current height, there is no output for that pair of triples. ''' # Get inner and outer start and end diameters, and s & e heights asm = None for jointNum, dis, die, dos, doe, hs, he in zip(range(len(dii)), dii, dii[1:], doo, doo[1:], hss, hss[1:]): if hs >= he: # Skip rings that don't have positive thickness continue print '{:2}. dis {:<5.2f}, die {:<5.2f}, dos {:<5.2f}, doe {:<5.2f}, ys {:<5.2f}, ye {:<5.2f}'.format(jointNum, dis, die, dos, doe, hs, he) co = cylinder(d1=dos, d2=doe, h=he-hs) ci = cylinder(d1=dis, d2=die, h=he-hs+0.002) cyl = part()(co - hole()(down(0.001)(ci))) asm = asm + up(hs)(cyl) if asm else cyl return asm
def slat_middle(matress_width, overhang): length = matress_width + overhang * 2 half_cross = hole()(cube((3 / 2, 7 / 2, 1 / 4))) return part()(OneByFour(length) - translate((length - 3 / 2 - overhang, 0, 0))(half_cross) - translate((overhang, 0, 0))(half_cross))
def foot(rise): notch_depth = 2 return part()( FourByFour(notch_depth + rise, (Z, X, Y)) - hole()(translate((0, 1, rise))(cube((3.5, 1.5, notch_depth)))) - hole()(translate((1, 0, rise))(cube((1.5, 3.5, notch_depth)))))
def makePillar(self, xloc): tHi = self.ChanHi + self.CapThik loss = cylinder(d=self.PillarID, h=tHi + 2 * self.eps) tube = cylinder(d=self.PillarOD, h=tHi) - hole()(down(self.eps)(loss)) return translate([xloc, self.CapWide / 2, 0])(tube)
_check_axis(axis) o = solid.linear_extrude(height, **kwargs)(obj) if center: o = o.down(height / 2) if axis == "y": o = o.rotate(90, 0, 0) elif axis == "x": o = o.rotate(0, 90, 0) return o solid.OpenSCADObject.d = lambda self: solid.debug((self)) solid.OpenSCADObject.debug = solid.OpenSCADObject.d solid.OpenSCADObject.b = lambda self: solid.background((self)) solid.OpenSCADObject.background = solid.OpenSCADObject.b solid.OpenSCADObject.h = lambda self: solid.hole()(self) solid.OpenSCADObject.hole = solid.OpenSCADObject.h solid.OpenSCADObject.t = lambda self, x=0, y=0, z=0: ff_translate(x, y, z)(self ) solid.OpenSCADObject.translate = solid.OpenSCADObject.t solid.OpenSCADObject.r = lambda self, a=None, b=None, c=None: ff_rotate( a, b, c)(self) solid.OpenSCADObject.rzx = lambda self: solid.utils.rot_z_to_x(self) solid.OpenSCADObject.rzy = lambda self: solid.utils.rot_z_to_y(self) solid.OpenSCADObject.rxy = lambda self: solid.utils.rot_x_to_y(self) solid.OpenSCADObject.rxz = lambda self: solid.utils.rot_z_to_x(self) solid.OpenSCADObject.ryx = lambda self: solid.utils.rot_x_to_y(self) solid.OpenSCADObject.ryz = lambda self: solid.utils.rot_z_to_y(self)