def model(self): result = rounded_box(self.width, self.width, self.height, r=(self.width - self.hole_spacing) / 2).t( 'c', 'c', -self.height) result += scad.cylinder(d=self.ledge_diameter, h=self.ledge_height + tol).tz(-tol) result += (scad.cylinder(d=self.axel_diameter, h=self.axel_length) - scad.cube(inf, inf, inf).t( 'c', self.axel_diameter / 2 - self.axel_chamfer, 'c')) result -= scad.cylinder(d=self.screw.diameter, h=self.inf).t( self.hole_spacing / 2, self.hole_spacing / 2, -self.height / 2).mx(clone=True).my(clone=True) return result.module_name('nema17')
def base_plate_with_holes(): size = 60 thickness = 3 hole_diameter = 10 hole_position = hole_diameter / 2 + thickness # create plate plate = scad.cube(size, size, thickness) # hole holes = scad.cylinder(d=hole_diameter, h=inf) holes = holes.tz('c') # translate along Z to center of object holes = holes.t(hole_position, hole_position, 0) # translate hole holes = holes.mx( plate.com.x, clone=True) # mirror holes along x with center in plate.com holes = holes.my(plate.com.y, clone=True) # all transformations above can be written as single chain: # holes = scad.cylinder( # d=hole_diameter, h=inf # ).t( # hole_position, hole_position, 'c' # ).mx( # plate.com.x, clone=True # ).my( # plate.com.y, clone=True # ) result = plate - holes # or result = plate.difference(holes) # or result = scad.difference(plate, holes) return result
def hole(self, h=inf, inf_cap=False, no_cap=False, cap_type='hidden', clearance=0): if no_cap: return scad.cylinder(d=self.diameter, h=h).tz(-tol) if inf_cap: result = scad.cylinder(d=self.cap_diameter, h=inf).mz().tz(tol) else: result = scad.cylinder(d=self.cap_diameter, h=tol * 2).tz(-tol) if cap_type == 'hidden': result += scad.cylinder(d1=self.cap_diameter, d2=self.diameter, h=self.cap_depth) elif cap_type == 'cylinder': result += scad.cylinder(d=self.cap_diameter, h=self.cap_depth) result += scad.cylinder(d=self.diameter + clearance, h=h) return result
def model(self): result = scad.cylinder(d1=self.cap_diameter, d2=self.diameter, h=self.cap_depth) result += scad.cylinder(d=self.diameter, h=self.length) return result
def hole(self, h=inf): result = scad.cylinder(d=self.external_diameter, h=h, fn=6) return result
def model(self): result = scad.cylinder(d=self.external_diameter, h=self.height, fn=6) result -= scad.cylinder(d=self.internal_diameter, h=self.height + tol * 2).tz(-tol) return result
def holes(self, no_cap=False): result = scad.cylinder(d=self.ledge_diameter, h=inf).tz(-tol) result += self.screw.hole(no_cap=no_cap).t( self.hole_spacing / 2, self.hole_spacing / 2).mx(clone=True).my(clone=True) return result
def nut(diameter=18, length=15, tol=0.01): h = diameter * 0.4 solid = scad.cylinder(d=diameter * 1.9, h=h, fn=6) solid -= m_thread_internal_hole(d=diameter, h=h + tol * 2).tz(-tol) return solid
def bolt(diameter=18, length=20): h = diameter * 0.4 solid = m_thread_external(d=diameter, h=length + h) solid += scad.cylinder(d=diameter * 1.9, h=h, fn=6) return solid