def xulaconnector(): screw_xuout = 2.5 screw_xuin = 1.5 screw_toph = 1 offset = 5 length = offset + THICK_WALL # XULA2 is attached to the top with two screws screw_xula = hscrew(screw_xuout, screw_toph, screw_xuin, length) screws_xula = screw_xula + right(58)(screw_xula) screws_xula += up(48.8)(screws_xula) xula_base = screws_xula # Raspberry connector xula2 rsp_cnctr = cube([58 - 2 * (screw_xuin + THICK_WALL * 0.5), length, 6]) xula_base += translate([screw_xuin + THICK_WALL * 0.5, -length, -3 + 48.8])(hole()(rsp_cnctr)) # add stickit connector top_height = 4 # top height screw in mm top_r = 3.5 # top r screw in mm shaft_r = 2 screw_stick = hscrew(top_r, top_height, shaft_r, length) screws_stick = screw_stick + up(15)(screw_stick) # stickit length 49.6-1.28-2-2 # 15.5+1.5+1.2-1.5 xula_base += translate( [-(49.6 - 1.28 - 2 - 2) - 8, 0, 15.5 + 1.5 + 1.2 - 1.5 - 2.7])(screws_stick) xula_base += translate([-60, -2, -8])(cube([123, 2, 61])) xula_base = up(THICK_WALL + 11)(xula_base) # add down connector base_exit = cube([58 + 2 * screw_xuin + THICK_WALL, 16, THICK_WALL]) base_exit += hole()(translate( [screw_xuin + THICK_WALL * 0.5, THICK_WALL, 0])(cube([58 - 2 * (screw_xuin + THICK_WALL * 0.5), 12, THICK_WALL]))) xula_base += back(16)(base_exit) return xula_base
def fibcube(): outside = cube([m.fibcube_side, m.fibcube_side, m.fibcube_height], center=False) top = translate( [ m.fibcube_wall + m.fibcube_extra / 2, m.fibcube_wall + m.fibcube_extra / 2, m.fibcube_height, ] )( cube( [ m.fibcube_plopp - m.fibcube_extra, m.fibcube_plopp - m.fibcube_extra, m.fibcube_top_margin, ], center=False, ) ) inside = translate([m.fibcube_wall, m.fibcube_wall, -m.fibcube_wall])( cube([m.fibcube_plopp, m.fibcube_plopp, m.fibcube_height], center=False) ) fc = outside + top fc = fc + hole()(inside) return fc
def screw(r_head, h_head, r_shaft, length, thick=THICK_WALL): """screw create a hole so a screw can be screwd into the box the center of the screw is aligned with the center of the coordinate system the screw is oriented as flipped T, i.e. it is standing on its head. screws are generated with an enclosing of THICK_WALL mm the interior is ensured via the hole function it is assumed that r_head > r_shaft The height of the head is h_head, an additional r_head-r_r_shaft is added to ensure printablity. :param r_head: radius of the head of the screw [mm] :param h_head: height of the head of the screw [mm] :param r_shaft: radius of the shaft of the screw [mm] :param length: desired length of the screw [mm] """ h_shaft = length - h_head - (r_head - r_shaft) head = cylinder(h=h_head, r=r_head, segments=30) # 45 degrees cone for printability cone = up(h_head)(cylinder(h=r_head - r_shaft, r1=r_head, r2=r_shaft, segments=30)) shaft = up(h_head + (r_head - r_shaft))(cylinder(h=h_shaft, r=r_shaft, segments=30)) inner = head + cone + shaft screw = cylinder(h=length, r=r_head + thick) - hole()(inner) return screw
def createlogo(): """createlogo Openscad cannot handle the Storm font. To mitigate, a vector image of the storm font is converted to PNG via Inkscape. The PNG image is linearly extruded and converted to a STL. This STL is imported by this function, to create the logo. """ # TODO: move Python converter for logo to here # LOGO bounding box x = 234 , y = 26, z = 1 # scaled to x = 120, y = 13 x_bound = 120 + THICK_WALL * 2 y_bound = 13 + THICK_WALL * 2 # TODO: should throw error !! you removed logo logo = scale([0.5, 0.5, 1])(import_stl('hexastorm.stl')) logo = None # openscad cannot handle minkowski on hexastorm logo # logo_mink = up(1)(minkowski()(cylinder(r=0.5, h=1), logo)) result = translate([-0.5 * x_bound, -0.5 * y_bound, 0])(cube( [x_bound, y_bound, 1])) - hole()(mirror([0, 1, 0])(logo)) result = scale([1, 1, HEIGHT_TOP - THICK_WALL ])(translate([0.5 * x_bound, 0.5 * y_bound, 0])(result)) result = up(HEIGHT_TOP - THICK_WALL)(cube([x_bound, y_bound, 1])) # TODO: Openscad can create a preview but does not render the logo, # at the moment we resort to # modiefs in blender return result
def slot(r_head, h_head, r_shaft, width, height): """slot openscad styled vertically oriented printable slot origin formed by the center of left circle :param r_head: the radius of the top of the screw, [mm] :param h_head: the height of the top of the screw, [mm] :param r_shaft: the radius of the shaft of the screw, [mm] :param width: the width of the slot, [mm] :param height: the height of the slot, [mm] """ h_shaft = height - h_head - (r_head - r_shaft) head = cylinder(h=h_head, r=r_head, segments=30) # 45 degrees cone for printability cone = up(h_head)(cylinder(h=r_head - r_shaft, r1=r_head, r2=r_shaft, segments=30)) shaft = up(h_head + (r_head - r_shaft))(cylinder(h=h_shaft, r=r_shaft, segments=30)) cyl = head + cone + shaft inner = hull()(cyl, right(width)(cyl)) cyl = cylinder(h=height, r=r_head + THICK_WALL) outer = hull()(cyl, right(width)(cyl)) slot = outer - hole()(inner) return slot
def laserbase(laserheight): """laserabase creates the basis for the laser with ventilation wall The laserbase is in the XY plane at quadrant 1. One corner is at the origin. The width is parallel to the x-axis. The laser was provided by Odic Force, productid OFL510-1. The padheight is laser height- 16.5 The laserbundle travels in the +x direction and departs from the center, that is 15 mm. param: laserheight: the desired height of the laser """ # The laser tube is at 8 mm from bottom. # The laser tube has a diameter of 17 mm # The laser is at 8 + 17 * 0.5 - 1 = 16.5 mm (shim of 1 mm needed) # The laser base is 30x60 mm, which was made # 30x75 mm to make room for the ventilator # PARAMETERS height = laserheight - 15.5 # [mm], xdisp = 48.5 # [mm], x-displacement screws ydisp = 16 # [mm], y-displacement screws r_shaft = 2 # [mm], shaft radius screws h_head = 5 # [mm], height shaft head r_head = 3.5 # [mm], top radius screws tspile = 4 # [mm], y-thickness ventilation spile hspile = 25 # [mm], height ventilation spile length = 75 # [mm], x-direction length laser width = 30 # [mm], y-direction width laser screw_offst = 7 # [mm], screw offset +x-edge # MINIMAL MATERIAL BASE screws = screw(r_head, h_head, r_shaft, height) + right(xdisp)(screw( r_head, h_head, r_shaft, height)) spiegel = forward(ydisp / 2)(mirror([0, 1, 0])(back(ydisp / 2)(screws))) screws += spiegel base = translate([length - xdisp - screw_offst, (width - ydisp) / 2, 0])(screws) # ventilation wall # spile spile = up(height)(cube([THICK_WALL, tspile, hspile])) nofspiles = ceil((width) / (tspile * 2)) # shift base base = right(THICK_WALL)(base) # add wall base += cube([THICK_WALL, width, HEIGHT_WALL]) # create pockets for i in range(0, nofspiles): base -= hole()(forward(i * 2 * tspile + THICK_WALL)(spile)) return base
def panelmountmini(): """panelmount panel mount for panel Mount cable -B to Mini-B cable http://adafru.it/936 """ base = cube([40, 20, THICK_WALL], center=True) # screw hole screw_hole = cylinder(r=1.75, h=THICK_WALL * 2, center=True, segments=30) # create two holes + hole usb cube base -= hole()(left(14)(screw_hole) + right(14)(screw_hole) + cube([17.5, 12, THICK_WALL * 2], center=True)) # change orientation base = right(0.5 * THICK_WALL)(rotate([0, 90, 0])(rotate([0, 0, 90])(base))) return base
def enclosure(): enc_outer = cube( size=[m.enclosure_width, m.enclosure_depth, m.enclosure_height], center=True ) enc_hole = up(m.wall_thickness)( cube( size=[ m.enclosure_width - m.wall_thickness, m.enclosure_depth - m.wall_thickness, m.enclosure_height, ], center=True, ) ) enclosure = enc_outer + hole()(enc_hole) enclosure = part()(enclosure) enclosure = up(m.enclosure_height / 2)(enclosure) return enclosure
def hscrew(head_r, head_height, shaft_r, length): """horizontal screw a horizontal screw consists out of three parts * a cylinder in the wall * possible a continuation of the head insert * shaft piece algorithm ensures it is printable param head_height: height head screw param head_r: radius head screw param shaft_r: radius shaft screw param lenght: lenght screw """ # cylinder in the wall if head_height > THICK_WALL: shift = head_height - THICK_WALL cyl_wall = cylinder(h=THICK_WALL, r=head_r + THICK_WALL, segments=30) cyl_mid = up(THICK_WALL)(cylinder(h=shift, r1=head_r + shift + THICK_WALL, r2=head_r + THICK_WALL, segments=30)) hscrew = cyl_mid + cyl_wall else: hscrew = cylinder(h=head_height, r=head_r + THICK_WALL, segments=30) # two cases: if length - head_height > head_height: shift = length - THICK_WALL cyl_shaft = up(head_height)(cylinder(h=shift, r1=shaft_r + shift + THICK_WALL, r2=shaft_r + THICK_WALL, segments=30)) else: cyl_shaft = up(head_height)(cylinder(h=length - head_height, r1=head_r + THICK_WALL, r2=shaft_r + THICK_WALL, segments=30)) hscrew += cyl_shaft hscrew = rotate([90, 0, 0])(hscrew) # gravity only one direction --> minimize in this direction # shaft field = cube([ 2 * (shaft_r + THICK_WALL), length - head_height, length + 2 * shaft_r + THICK_WALL ]) field = translate([-shaft_r - THICK_WALL, -length, -(length + shaft_r)])(field) sscrew = hscrew * field # top if head_height > THICK_WALL: field = cube([ 2 * (head_r + THICK_WALL), head_height, length + 2 * head_r + THICK_WALL ]) field = translate( [-head_r - THICK_WALL, -head_height, -(length + head_r)]) (field) tscrew = hscrew * field else: tscrew = rotate([90, 0, 0])(cylinder(h=head_height, r=head_r + THICK_WALL, segments=30)) hscrew = tscrew + sscrew cyl_top = down(0.1)(cylinder(h=head_height + 0.1, r=head_r, segments=30)) cyl_shaft = up(head_height - 0.1)(cylinder(h=length - head_height + 0.1, r=shaft_r, segments=30)) interior = rotate([90, 0, 0])(cyl_shaft + cyl_top) omg = hscrew - hole()(interior) # OMG HOLE is buggy; hscrew-=hole()(interior) does not always work return omg
def mirrormount(down, laserheight): """mirrormount A 25 mm x 25 mm square and 2 mm thick first sided mirror is used to refract the ray downward or upward. The thickness is in the +x-direction. This mirror is tilted at a 45 degrees and is positioned by a holder. The holder is put in place via two pillars. A photodiode mount is placed into these pillars to detect the laser motion. It is important that the photodiode is at the correct height The photodiode_height is LASER_HEIGHT-2.5, to ensure the laser hits the photodiode at its center. :param down: if true downward refraction, if false upward refraction :param laserheight: height laser bundle, [mm] """ width_mirror = 25 # [mm] # thickness y+ pillar, y- pillar is insert+THICK_wall tpillar_left = 14 # [mm] insert_mirror = 5 # [mm] thick_mirror = 2 # [mm] # height_mirror < photodiode_height height_mirror = laserheight - 6 # [mm] # 4.5 determined via felix printed box photodiode_height = laserheight - 4.5 # [mm] cable_guide = 2 # [mm] # sensor width with cables is 5.6 (measurement @diode) sensor_width = 2 # [mm] # sensor height is 4 (measurement @ photodiode) sensor_height = 4.5 # [mm] sensor_insert = 2 # [mm] diode thickness i 2 @ measured # margin is needed for FFF printer margin = 0.5 # [mm] # defines the thickness of the holder thick = 1.3 # [mm] # offset constraint set by upward proj. due to cable collision possibility offset = 19 # [mm] offset sensor pole x_width = 0.5 * sqrt(2) * (thick_mirror + margin + 2 * thick) # TODO: xbound seems to be an y_bound x_bound = 0.5 * sqrt(2) * (2 * thick + width_mirror + margin) + x_width y_bound = offset + THICK_WALL + sensor_insert holder = cube([ thick_mirror + margin + 2 * thick, light_hole + THICK_WALL + insert_mirror + tpillar_left, width_mirror + margin + 2 * thick ]) holder_inner = translate([thick, 0, thick])(cube([ thick_mirror + margin, light_hole + tpillar_left + insert_mirror, width_mirror + margin ])) # the holder can contain left over of filament. # To remove these left over a cleaning hole is needed. holder_inner += translate([thick, 0, thick + width_mirror + margin])(cube( [thick_mirror + margin, tpillar_left - THICK_WALL, thick])) holder -= hole()(holder_inner) # up mirror holder = up(height_mirror)(rotate([0, 45, 0])(holder)) # pillars # light exit has a width of light_hole # pillars are next to this exit point and have a width of tpillar_left, # and THICK_WALL + insert_mirror mount_mirror = cube([ x_width, light_hole + tpillar_left + THICK_WALL + insert_mirror, height_mirror ]) mount_mirror += holder # create pocket for light 2x is for certainty mount_mirror -= forward(tpillar_left)(cube( [2 * width_mirror, light_hole, 2 * width_mirror])) if not down: mount_mirror = right(x_bound)(mirror([1, 0, 0])(mount_mirror)) # add mount photodiode # the photodiode is at height photodiode_height mm # the cable guides are cable_guide mm thick, the pins of the photodiode # are sensor width displaced, the photodiode is sensor height tall # the photodiode sensor insert is sensor_insert, the wall between light # exit and sensor is fixed at 1 mm, kept small to get maximum out of light # path. The top has a three time thickness, to create a connection between # mirror and pole enclosure = cube([ THICK_WALL + sensor_insert, cable_guide * 2 + sensor_width + THICK_WALL + 1, sensor_height + photodiode_height + 2 * THICK_WALL ]) photodiode = cube([ sensor_insert + THICK_WALL, cable_guide * 2 + sensor_width, sensor_height ]) # substract central pillar photodiode -= translate([0, cable_guide, 0 ])(cube([THICK_WALL, sensor_width, sensor_height])) # combine pole with photodiode housing pole = enclosure - hole()(translate([0, 1, photodiode_height])(photodiode)) combined = mount_mirror + translate([offset, tpillar_left + light_hole, 0 ])(pole) # a trafo is executed to simplify positioning; # light should be centered at y=0 combined = translate([y_bound, tpillar_left + 0.5 * light_hole, 0])(mirror([1, 0, 0])(mirror([0, 1, 0])(combined))) # add tie-wrap # TODO: remove custom parameters fasten = translate([9, tpillar_left + 9, 0])(cable_fasten(TIE_HEIGHT, TIE_WIDTH, THICK_WALL, True)) combined += fasten return combined
def hole(self, sb: "SolidBuilder") -> "SolidBuilder": self._oso = self._oso - hole()(sb._oso) return self