diff --git a/nhf/handle.py b/nhf/handle.py index 0424569..5bdd311 100644 --- a/nhf/handle.py +++ b/nhf/handle.py @@ -74,11 +74,13 @@ class Handle: result.faces(">Z").tag("mate2") return result - def _external_thread(self): + def _external_thread(self, length=None): + if length is None: + length = self.insertion_length return NMt.external_metric_thread( self.diam_threading, self.thread_pitch, - self.insertion_length, + length, top_lead_in=True) def _internal_thread(self): return NMt.internal_metric_thread( @@ -86,7 +88,7 @@ class Handle: self.thread_pitch, self.insertion_length) - def insertion(self): + def insertion(self, holes=[]): """ This type of joint is used to connect two handlebar pieces. Each handlebar piece is a tube which cannot be machined, so the joint connects to the @@ -95,6 +97,12 @@ class Handle: Tags: * lip: Co-planar Mates to the rod * mate: Mates to the connector + + WARNING: A tolerance lower than the defualt (maybe 5e-4) is required for + STL export. + + Set `holes` to the heights for drilling holes into the model for resin + to flow out. """ result = ( Cq.Workplane('XY') @@ -117,12 +125,22 @@ class Handle: if not self.simplify_geometry: thread = self._internal_thread().val() result = result.union(thread) + for h in holes: + cyl = Cq.Solid.makeCylinder( + radius=2, + height=self.diam * 2, + pnt=(-self.diam, 0, h), + dir=(1, 0, 0)) + result = result.cut(cyl) return result - def connector(self, solid: bool = False): + def connector(self, solid: bool = True): """ Tags: * mate{1,2}: Mates to the connector + + WARNING: A tolerance lower than the defualt (maybe 2e-4) is required for + STL export. """ result = ( Cq.Workplane('XY') @@ -151,7 +169,7 @@ class Handle: .located(Cq.Location((0, 0, self.connector_length / 2)))) .union( thread - .rotate((0,0,0), (1,0,0), angleDegrees=90) + .rotate((0,0,0), (1,0,0), angleDegrees=180) .located(Cq.Location((0, 0, -self.connector_length / 2)))) ) return result @@ -183,6 +201,28 @@ class Handle: ) return result + def threaded_core(self, length): + """ + Generates a threaded core for unioning with other components + """ + result = ( + Cq.Workplane('XY') + .cylinder( + radius=self.diam_connector_external / 2, + height=length, + centered=(True, True, False), + ) + ) + result.faces(">Z").tag("mate") + result.faces("