Add RackEdge

This commit is contained in:
Florian Festi 2016-10-12 22:47:08 +02:00
parent fc36515fbd
commit 3ce2115365
2 changed files with 38 additions and 1 deletions

View File

@ -373,6 +373,8 @@ class Boxes:
self.addPart(NutHole(self, None))
# Gears
self.addPart(gears.Gears(self))
s = edges.GearSettings(self.thickness)
self.addPart(edges.RackEdge(self, s))
self.addPart(pulley.Pulley(self))
self.addPart(parts.Parts(self))

View File

@ -17,7 +17,7 @@
import math
import inspect
from boxes import gears
def getDescriptions():
d = {edge.char: edge.description for edge in globals().values()
@ -1221,3 +1221,38 @@ class FlexEdge(BaseEdge):
self.ctx.move_to(0, 0)
self.ctx.line_to(x, 0)
self.ctx.translate(*self.ctx.get_current_point())
class GearSettings(Settings):
absolute_params = {
"dimension" : 3.0,
"angle" : 20.0,
"profile_shift" : 20.0,
"clearance" : 0.0,
}
relative_params = {}
class RackEdge(BaseEdge):
char = "R"
def __init__(self, boxes, settings):
super(RackEdge, self).__init__(boxes, settings)
self.gear = gears.Gears(boxes)
def __call__(self, length, **kw):
params = self.settings.values.copy()
params["draw_rack"] = True
params["rack_base_height"] = -1E-36
params["rack_teeth_length"] = int(length // params["dimension"])
params["rack_base_tab"] = (length - (params["rack_teeth_length"]) * params["dimension"]) / 2.0
s_tmp = self.boxes.spacing
self.boxes.spacing = 0
self.moveTo(length, 0, 180)
self.gear(move="", **params)
self.moveTo(0, 0, 180)
self.boxes.spacing = s_tmp
def margin(self):
return self.settings.dimension * 1.1