From a7f0e9701217e086e4d59af1206a335793148745 Mon Sep 17 00:00:00 2001 From: Florian Festi Date: Thu, 30 Jun 2016 14:25:29 +0200 Subject: [PATCH] Add GrippingEdge Still needs to replace Boxes.grip() --- boxes/__init__.py | 2 + boxes/edges.py | 73 +++++++++++++++++++++++++++++++++++++ documentation/src/edges.rst | 21 +++++++---- 3 files changed, 89 insertions(+), 7 deletions(-) diff --git a/boxes/__init__.py b/boxes/__init__.py index f9dc08d..b1120e1 100755 --- a/boxes/__init__.py +++ b/boxes/__init__.py @@ -297,6 +297,8 @@ class Boxes: self.edges = {} self.addPart(edges.Edge(self, None)) self.addPart(edges.OutSetEdge(self, None)) + s = edges.GripSettings(self.thickness) + self.addPart(edges.GrippingEdge(self, s)) # Finger joints # Share settings object diff --git a/boxes/edges.py b/boxes/edges.py index b02248c..beb1644 100644 --- a/boxes/edges.py +++ b/boxes/edges.py @@ -211,6 +211,79 @@ class OutSetEdge(BaseEdge): def startwidth(self): return self.boxes.thickness +############################################################################# +#### Gripping Edge +############################################################################# + +class GripSettings(Settings): + """Settings for GrippingEdge +Values: + +* absolute_params + + * style : A : "A" (wiggly line) or "B" (bumps) + * outset : True : extend outward the straight edge + +* relative (in multiples of thickness) + + * depth : 0.3 : depth of the grooves + +""" + + absolute_params = { + "style" : "A", + "outset" : True, + } + + relative_params = { + "depth" : 0.3, + } + +class GrippingEdge(BaseEdge): + description = """Corrugated edge useful as an gipping area""" + char = 'g' + + + def A(self, length): + depth = self.settings.depth + grooves = int(length // (depth*2.0)) + 1 + depth = length / grooves / 4.0 + + o = 1 if self.settings.outset else -1 + for groove in range(grooves): + self.corner(o * -90, depth) + self.corner(o * 180, depth) + self.corner(o * -90, depth) + + def B(self, length): + depth = self.settings.depth + grooves = int(length // (depth*2.0)) + 1 + depth = length / grooves / 2.0 + o = 1 if self.settings.outset else -1 + if self.settings.outset: + self.corner(-90) + else: + self.corner(90) + self.edge(depth) + self.corner(-180) + for groove in range(grooves): + self.corner(180, depth) + self.corner(-180, 0) + if self.settings.outset: + self.corner(90) + else: + self.edge(depth) + self.corner(90) + + def margin(self): + if self.settings.outset: + return self.settings.depth + self.boxes.spacing + else: + return self.boxes.spacing + + def __call__(self, length, **kw): + getattr(self, self.settings.style)(length) + class CompoundEdge(BaseEdge): """Edge composed of multiple different Edges""" description = "Compound Edge" diff --git a/documentation/src/edges.rst b/documentation/src/edges.rst index ea6cc9f..0b590f6 100644 --- a/documentation/src/edges.rst +++ b/documentation/src/edges.rst @@ -5,17 +5,18 @@ As edges started out as methods of the main Boxes class they still are callables. A set of instances are kept the ``.edges`` attribute of the ``Boxes`` class. It is a dict with strings of length one as keys: -* e : Edge -* E : OutSetEdge -* s : StackableEdge -* S : StackableEdgeTop -* f : FingerJointEdge -* F : FingerJointEdgeCounterPart -* h : FingerHoleEdge * d : DoveTailJoint * D : DoveTailJointCounterPart +* e : Edge +* E : OutSetEdge +* f : FingerJointEdge +* F : FingerJointEdgeCounterPart +* g : GrippingEdge +* h : FingerHoleEdge * ijk : Hinge (start, end, both sides) * IJK : HingePin (start, end, both sides) +* s : StackableEdge +* S : StackableEdgeTop Edges of the same type share a settings instance to make sure both sides match (when the same length is given). @@ -41,6 +42,12 @@ Straight Edges .. autoclass:: boxes.edges.Edge .. autoclass:: boxes.edges.OutSetEdge +Grip +---- + +.. autoclass:: boxes.edges.GripSettings +.. autoclass:: boxes.edges.GrippingEdge + Stackable Edges ---------------