Remove .open() call from the .render() method

Having this call there was necessary in the past as the open() method would
need the canvas size as a parameter. This is now determined automatically
after rendering.

Still calling open() is deprecated but won't result in an error.
This commit is contained in:
Florian Festi 2019-02-08 17:43:15 +01:00
parent 861c8451e2
commit 0d07f48b7f
68 changed files with 8 additions and 94 deletions

View File

@ -219,6 +219,7 @@ class Boxes:
def __init__(self): def __init__(self):
self.formats = formats.Formats() self.formats = formats.Formats()
self.ctx = None
description = self.__doc__ description = self.__doc__
if self.description: if self.description:
description += "\n\n" + self.description description += "\n\n" + self.description
@ -277,6 +278,8 @@ class Boxes:
Call this function from your .render() method Call this function from your .render() method
""" """
if self.ctx is not None:
return
self.bedBoltSettings = (3, 5.5, 2, 20, 15) # d, d_nut, h_nut, l, l1 self.bedBoltSettings = (3, 5.5, 2, 20, 15) # d, d_nut, h_nut, l, l1
self.hexHolesSettings = (5, 3, 'circle') # r, dist, style self.hexHolesSettings = (5, 3, 'circle') # r, dist, style

View File

@ -47,8 +47,6 @@ class BOX(Boxes): # Change class name!
# adjust to the variables you want in the local scope # adjust to the variables you want in the local scope
x, y, h = self.x, self.y, self.h x, y, h = self.x, self.y, self.h
t = self.thickness t = self.thickness
# Initialize canvas
self.open()
# Create new Edges here if needed E.g.: # Create new Edges here if needed E.g.:
s = edges.FingerJointSettings(self.thickness, relative=False, s = edges.FingerJointSettings(self.thickness, relative=False,

View File

@ -36,8 +36,6 @@ class AllEdges(Boxes):
def render(self): def render(self):
x = self.x x = self.x
t = self.thickness t = self.thickness
# Initialize canvas
self.open()
chars = list(self.edges.keys()) chars = list(self.edges.keys())
chars.sort(key=lambda c: c.lower() + (c if c.isupper() else '')) chars.sort(key=lambda c: c.lower() + (c if c.isupper() else ''))

View File

@ -72,7 +72,6 @@ class AngledBox(Boxes):
self.move(tx, ty, move) self.move(tx, ty, move)
def render(self): def render(self):
self.open()
x, y, h, n = self.x, self.y, self.h, self.n x, y, h, n = self.x, self.y, self.h, self.n

View File

@ -44,8 +44,6 @@ class AngledCutJig(Boxes): # Change class name!
# adjust to the variables you want in the local scope # adjust to the variables you want in the local scope
x, y = self.x, self.y x, y = self.x, self.y
t = self.thickness t = self.thickness
# Initialize canvas
self.open()
th = x * math.tan(math.radians(90-self.angle)) th = x * math.tan(math.radians(90-self.angle))
l = (x**2 + th**2)**0.5 l = (x**2 + th**2)**0.5

View File

@ -76,8 +76,6 @@ class Arcade(Boxes):
self.top = 100-t self.top = 100-t
self.topback = 200-0.5*t self.topback = 200-0.5*t
# Initialize canvas
self.open()
# Floor # Floor
self.rectangularWall(width, self.bottom, "efff", move="up") self.rectangularWall(width, self.bottom, "efff", move="up")
# Back # Back

View File

@ -106,7 +106,6 @@ class BinTray(Boxes):
hi = self.hi = h hi = self.hi = h
t = self.thickness t = self.thickness
self.open()
self.addPart(BinFrontEdge(self, self)) self.addPart(BinFrontEdge(self, self))
self.addPart(BinFrontSideEdge(self, self)) self.addPart(BinFrontSideEdge(self, self))

View File

@ -96,7 +96,6 @@ class CardBox(Boxes):
self.fingerHolesAt(0.5*t + (c+t)*i, 0, y, 90) self.fingerHolesAt(0.5*t + (c+t)*i, 0, y, 90)
def render(self): def render(self):
self.open()
h = self.h h = self.h
t = self.thickness t = self.thickness

View File

@ -27,7 +27,6 @@ class Castle(Boxes):
self.addSettingsArgs(edges.FingerJointSettings) self.addSettingsArgs(edges.FingerJointSettings)
def render(self, t_x=70, t_h=250, w1_x=300, w1_h=120, w2_x=100, w2_h=120): def render(self, t_x=70, t_h=250, w1_x=300, w1_h=120, w2_x=100, w2_h=120):
self.open()
s = edges.FingerJointSettings(10.0, relative=True, s = edges.FingerJointSettings(10.0, relative=True,
space=1, finger=1, space=1, finger=1,
width=self.thickness) width=self.thickness)

View File

@ -28,7 +28,6 @@ class ClosedBox(Boxes):
self.buildArgParser("x", "y", "h", "outside") self.buildArgParser("x", "y", "h", "outside")
def render(self): def render(self):
self.open()
x, y, h = self.x, self.y, self.h x, y, h = self.x, self.y, self.h

View File

@ -49,8 +49,6 @@ class ConcaveKnob(Boxes):
def render(self): def render(self):
t = self.thickness t = self.thickness
# Initialize canvas
self.open()
self.parts.concaveKnob(self.diameter, self.serrations, self.parts.concaveKnob(self.diameter, self.serrations,
self.rounded, self.angle, self.rounded, self.angle,
callback=lambda:self.dHole(0, 0, callback=lambda:self.dHole(0, 0,

View File

@ -40,8 +40,6 @@ class Display(Boxes):
x, h, r = self.x, self.h, self.radius x, h, r = self.x, self.h, self.radius
a = self.angle a = self.angle
t = self.thickness t = self.thickness
# Initialize canvas
self.open()
self.roundedPlate(0.7*x, x, r, "e", move="up") self.roundedPlate(0.7*x, x, r, "e", move="up")

View File

@ -36,7 +36,6 @@ class DisplayCase(Boxes):
) )
def render(self): def render(self):
self.open()
x, y, h = self.x, self.y, self.h x, y, h = self.x, self.y, self.h

View File

@ -61,8 +61,6 @@ class DisplayShelf(Boxes): # change class name here and below
if self.outside: if self.outside:
x = self.adjustSize(x) x = self.adjustSize(x)
# Initialize canvas
self.open()
a = math.radians(self.angle) a = math.radians(self.angle)

View File

@ -54,7 +54,6 @@ in 0.5mm steps, 3 holes each size"""
x, y, h = self.x, self.y, self.h x, y, h = self.x, self.y, self.h
t = self.thickness t = self.thickness
self.open()
self.edges["f"].settings.setValues(self.thickness, space=3, finger=3, surroundingspaces=1) self.edges["f"].settings.setValues(self.thickness, space=3, finger=3, surroundingspaces=1)
self.rectangularWall(x, h, "FfeF", callback=[self.holesx], move="right") self.rectangularWall(x, h, "FfeF", callback=[self.holesx], move="right")

View File

@ -56,7 +56,6 @@ class ElectronicsBox(Boxes):
self.fingerHolesAt(self.y, self.h-1.5*t, self.triangle, 180) self.fingerHolesAt(self.y, self.h-1.5*t, self.triangle, 180)
def render(self): def render(self):
self.open()
t = self.thickness t = self.thickness
self.h = h = self.h + 2*t # compensate for lid self.h = h = self.h + 2*t # compensate for lid

View File

@ -116,7 +116,6 @@ class FlexBox(boxes.Boxes):
r = min(r, x / 2.0) r = min(r, x / 2.0)
self.radius = r = min(r, max(0, (y - self.latchsize) / 2.0)) self.radius = r = min(r, max(0, (y - self.latchsize) / 2.0))
self.open()
self.surroundingWall(move="up") self.surroundingWall(move="up")
self.flexBoxSide(self.x, self.y, self.radius, move="right") self.flexBoxSide(self.x, self.y, self.radius, move="right")

View File

@ -105,7 +105,6 @@ class FlexBox2(Boxes):
self.radius = min(self.radius, max(0, self.h - self.latchsize)) self.radius = min(self.radius, max(0, self.h - self.latchsize))
self.c4 = c4 = math.pi * self.radius * 0.5 self.c4 = c4 = math.pi * self.radius * 0.5
self.open()
self.moveTo(2 * self.thickness, self.thickness) self.moveTo(2 * self.thickness, self.thickness)

View File

@ -146,7 +146,6 @@ class FlexBox3(Boxes):
width = 2 * x + y - 2 * r + c4 + 14 * thickness + 3 * h # lock width = 2 * x + y - 2 * r + c4 + 14 * thickness + 3 * h # lock
height = y + z + 8 * thickness height = y + z + 8 * thickness
self.open()
s = edges.FingerJointSettings(self.thickness, finger=1., s = edges.FingerJointSettings(self.thickness, finger=1.,
space=1., surroundingspaces=1) space=1., surroundingspaces=1)

View File

@ -110,7 +110,6 @@ class FlexBox4(Boxes):
self.radius = min(self.radius, max(0, self.y - self.latchsize)) self.radius = min(self.radius, max(0, self.y - self.latchsize))
self.c4 = c4 = math.pi * self.radius * 0.5 self.c4 = c4 = math.pi * self.radius * 0.5
self.open()
self.surroundingWall(move="up") self.surroundingWall(move="up")
self.flexBoxSide(self.x, self.y, self.radius, move="right") self.flexBoxSide(self.x, self.y, self.radius, move="right")

View File

@ -29,7 +29,6 @@ class FlexTest(Boxes):
def render(self): def render(self):
x, y = self.x, self.y x, y = self.x, self.y
self.open()
self.moveTo(5, 5) self.moveTo(5, 5)
self.edge(10) self.edge(10)

View File

@ -32,7 +32,6 @@ class FlexTest2(Boxes):
def render(self): def render(self):
x, y = self.x, self.y x, y = self.x, self.y
self.open()
self.rectangularWall(x, y, callback=[lambda: self.flex2D(x, y, self.fw)]) self.rectangularWall(x, y, callback=[lambda: self.flex2D(x, y, self.fw)])

View File

@ -33,7 +33,6 @@ class Folder(Boxes):
def render(self): def render(self):
x, y, r, h = self.x, self.y, self.r, self.h x, y, r, h = self.x, self.y, self.r, self.h
c2 = math.pi * h c2 = math.pi * h
self.open()
self.moveTo(r + self.thickness, self.thickness) self.moveTo(r + self.thickness, self.thickness)
self.edge(x - r) self.edge(x - r)
self.edges["X"](c2, y) self.edges["X"](c2, y)

View File

@ -56,8 +56,6 @@ class Gears(Boxes):
def render(self): def render(self):
# adjust to the variables you want in the local scope # adjust to the variables you want in the local scope
t = self.thickness t = self.thickness
# Initialize canvas
self.open()
if not self.shaft2: if not self.shaft2:
self.shaft2 = self.shaft1 self.shaft2 = self.shaft1

View File

@ -42,8 +42,6 @@ class GearBox(Boxes):
help="number of stages in the gear reduction") help="number of stages in the gear reduction")
def render(self): def render(self):
# Initialize canvas
self.open()
if self.teeth2 < self.teeth1: if self.teeth2 < self.teeth1:
self.teeth2, self.teeth1 = self.teeth1, self.teeth2 self.teeth2, self.teeth1 = self.teeth1, self.teeth2

View File

@ -34,7 +34,6 @@ class HingeBox(Boxes):
help="split the lid in y direction (mm)") help="split the lid in y direction (mm)")
def render(self): def render(self):
self.open()
x, y, h, hl = self.x, self.y, self.h, self.lidheight x, y, h, hl = self.x, self.y, self.h, self.lidheight
s = self.splitlid s = self.splitlid

View File

@ -43,7 +43,6 @@ class Hook(Boxes):
help="angle of the support underneeth") help="angle of the support underneeth")
def render(self): def render(self):
self.open()
self.angle = min(self.angle, 80) self.angle = min(self.angle, 80)
t = self.thickness t = self.thickness

View File

@ -33,7 +33,6 @@ class IntegratedHingeBox(Boxes):
def render(self): def render(self):
self.open()
x, y, h, hl = self.x, self.y, self.h, self.lidheight x, y, h, hl = self.x, self.y, self.h, self.lidheight

View File

@ -80,8 +80,6 @@ class JigsawPuzzle(Boxes): # change class name here and below
def render(self): def render(self):
size = self.size size = self.size
t = self.thickness t = self.thickness
# Initialize canvas
self.open()
self.burn = 0.0 self.burn = 0.0
self.moveTo(10, 10) self.moveTo(10, 10)
self.hilbert(self.depth) self.hilbert(self.depth)

View File

@ -90,7 +90,6 @@ class Lamp(Boxes):
h : height box h : height box
""" """
self.open()
# self.edges["f"].settings = (5, 5) # XXX # self.edges["f"].settings = (5, 5) # XXX

View File

@ -85,7 +85,6 @@ parts sliding on each other to reduce friction.
def render(self): def render(self):
t = self. thickness t = self. thickness
h_max, h_min, h_extra = self.maxheight, self.minheight,self.extraheight h_max, h_min, h_extra = self.maxheight, self.minheight,self.extraheight
self.open()
if h_extra and h_extra < 2*t: if h_extra and h_extra < 2*t:
h_extra = 2*t h_extra = 2*t

View File

@ -35,7 +35,6 @@ class LBeam(Boxes):
y = self.adjustSize(y, False) y = self.adjustSize(y, False)
self.open()
self.rectangularWall(x, h, "eFee", move="right") self.rectangularWall(x, h, "eFee", move="right")
self.rectangularWall(y, h, "eeef") self.rectangularWall(y, h, "eeef")

View File

@ -69,7 +69,6 @@ class MagazinFile(Boxes):
self.hi = hi = self.hi or (h / 2.0) self.hi = hi = self.hi or (h / 2.0)
t = self.thickness t = self.thickness
self.open()
with self.saved_context(): with self.saved_context():
self.rectangularWall(x, h, "Ffef", move="up") self.rectangularWall(x, h, "Ffef", move="up")

View File

@ -36,7 +36,6 @@ class NemaMount(Boxes):
x = y = h = motor + 2*t x = y = h = motor + 2*t
self.open()
self.rectangularWall(x, y, "ffef", callback=[ self.rectangularWall(x, y, "ffef", callback=[
lambda: self.NEMA(self.size, x/2, y/2)], move="right") lambda: self.NEMA(self.size, x/2, y/2)], move="right")

View File

@ -35,7 +35,6 @@ class OpenBox(Boxes):
y = self.adjustSize(y, False) y = self.adjustSize(y, False)
h = self.adjustSize(h, False) h = self.adjustSize(h, False)
self.open()
d2 = [edges.Bolts(2)] d2 = [edges.Bolts(2)]
d3 = [edges.Bolts(3)] d3 = [edges.Bolts(3)]

View File

@ -126,8 +126,6 @@ class OrganPipe(Boxes): # Change class name!
total_length = resonator_length + base_length total_length = resonator_length + base_length
# Initialize canvas
self.open()
e = ["f", "e", e = ["f", "e",
edges.CompoundEdge(self, "fef", (resonator_length - mouth_height - 10*t, mouth_height + 10*t, base_length)), "f"] edges.CompoundEdge(self, "fef", (resonator_length - mouth_height - 10*t, mouth_height + 10*t, base_length)), "f"]

View File

@ -98,7 +98,6 @@ class OttoBody(Boxes):
self.move(w+4, h+8+t, move) self.move(w+4, h+8+t, move)
def render(self): def render(self):
self.open()
self.x = x = 60. self.x = x = 60.
self.y = y = 60. self.y = y = 60.

View File

@ -104,8 +104,6 @@ class OttoLegs(Boxes):
def render(self): def render(self):
# adjust to the variables you want in the local scope # adjust to the variables you want in the local scope
t = self.thickness t = self.thickness
# Initialize canvas
self.open()
ws = 25 ws = 25
lx, ly, lh = 12.4, 23.5, max(self.length, ws+6+t) lx, ly, lh = 12.4, 23.5, max(self.length, ws+6+t)

View File

@ -45,8 +45,6 @@ class OttoSoles(Boxes):
w2 = w * 2**0.5 - c2 / 2 w2 = w * 2**0.5 - c2 / 2
d = w * math.tan(math.radians(22.5)) d = w * math.tan(math.radians(22.5))
# Initialize canvas
self.open()
self.edges["d"].settings.setValues(w, size=0.4, depth=0.3, self.edges["d"].settings.setValues(w, size=0.4, depth=0.3,
radius=0.05) radius=0.05)

View File

@ -68,8 +68,6 @@ class PaintStorage(Boxes):
x, y = self.x, self.y x, y = self.x, self.y
t = self.thickness t = self.thickness
# Initialize canvas
self.open()
stack = self.edges['s'].settings stack = self.edges['s'].settings
h = self.canheight - stack.height - stack.holedistance + t h = self.canheight - stack.height - stack.holedistance + t

View File

@ -49,8 +49,6 @@ class Planetary(Boxes):
# help="number of stages in the gear reduction") # help="number of stages in the gear reduction")
def render(self): def render(self):
# Initialize canvas
self.open()
ringteeth = self.sunteeth + 2 * self.planetteeth ringteeth = self.sunteeth + 2 * self.planetteeth
spoke_width = 3 * self.shaft spoke_width = 3 * self.shaft

View File

@ -77,8 +77,6 @@ class Planetary2(Boxes):
def render(self): def render(self):
# Initialize canvas
self.open()
ringteeth = self.sunteeth + 2 * self.planetteeth ringteeth = self.sunteeth + 2 * self.planetteeth
t = self.thickness t = self.thickness

View File

@ -99,8 +99,6 @@ class PoleHook(Boxes): # change class name here and below
# adjust to the variables you want in the local scope # adjust to the variables you want in the local scope
d = self.diameter d = self.diameter
t = self.thickness t = self.thickness
# Initialize canvas
self.open()
shh = self.screwheadheight shh = self.screwheadheight
self.bedBoltSettings = (self.screw, self.screwhead, shh, d/4+shh, d/4) # d, d_nut, h_nut, l, l self.bedBoltSettings = (self.screw, self.screwhead, shh, d/4+shh, d/4) # d, d_nut, h_nut, l, l

View File

@ -69,8 +69,6 @@ class Pulley(Boxes):
def render(self): def render(self):
# adjust to the variables you want in the local scope # adjust to the variables you want in the local scope
t = self.thickness t = self.thickness
# Initialize canvas
self.open()
if self.top: if self.top:
self.disk( self.disk(

View File

@ -63,7 +63,6 @@ class Rack19Box(Boxes):
def _render(self, type): def _render(self, type):
self.open()
t = self.thickness t = self.thickness
self.h = h = self.height * 44.45 - 0.787 - t self.h = h = self.height * 44.45 - 0.787 - t

View File

@ -64,7 +64,6 @@ class RackBox(Boxes):
def render(self): def render(self):
self.open()
t = self.thickness t = self.thickness
self.h = h = self.h + 2*t # compensate for lid self.h = h = self.h + 2*t # compensate for lid

View File

@ -62,8 +62,6 @@ class RectangularWall(Boxes):
def render(self): def render(self):
# adjust to the variables you want in the local scope # adjust to the variables you want in the local scope
# Initialize canvas
self.open()
t = self.thickness t = self.thickness
self.edgetypes = [self.bottom_edge, self.right_edge, self.top_edge, self.left_edge] self.edgetypes = [self.bottom_edge, self.right_edge, self.top_edge, self.left_edge]

View File

@ -38,7 +38,6 @@ class RegularBox(Boxes):
help="style of the top and lid") help="style of the top and lid")
def render(self): def render(self):
self.open()
r, h, n = self.radius, self.h, self.n r, h, n = self.radius, self.h, self.n

View File

@ -44,8 +44,6 @@ class RobotArm(Boxes): # change class name here and below
help="length of segment axle to axle") help="length of segment axle to axle")
def render(self): def render(self):
# Initialize canvas
self.open()
for i in range(5, 0,-1): for i in range(5, 0,-1):
armtype = getattr(self, "type%i" % i) armtype = getattr(self, "type%i" % i)

View File

@ -189,8 +189,6 @@ class Rotary(Boxes):
a = self.a = self.axle a = self.a = self.axle
bw, bh = self.beamwidth, self.beamheight bw, bh = self.beamwidth, self.beamheight
# Initialize canvas
self.open()
# self.spacing = 0.1 * t # self.spacing = 0.1 * t
# Change settings of default edges if needed. E.g.: # Change settings of default edges if needed. E.g.:

View File

@ -58,7 +58,6 @@ class RoundedBox(Boxes):
self.corner(90, r) self.corner(90, r)
def render(self): def render(self):
self.open()
x, y, h, r = self.x, self.y, self.h, self.radius x, y, h, r = self.x, self.y, self.h, self.radius

View File

@ -163,8 +163,6 @@ class RoyalGame(Boxes): # Change class name!
self.size = size = x / 8.0 self.size = size = x / 8.0
h = size/2 * 3**0.5 h = size/2 * 3**0.5
y = 3 * size y = 3 * size
# Initialize canvas
self.open()
self.rectangularWall(x, h, "FLFF", move="right") self.rectangularWall(x, h, "FLFF", move="right")
self.rectangularWall(y, h, "nlmE", callback=[ self.rectangularWall(y, h, "nlmE", callback=[

View File

@ -159,8 +159,6 @@ class ShutterBox(Boxes):
self.radius = r = min(r, h/2) self.radius = r = min(r, h/2)
t = self.thickness t = self.thickness
# Initialize canvas
self.open()
self.ctx.save() self.ctx.save()
self.side(x, h, r, style, move="right") self.side(x, h, r, style, move="right")
self.side(x, h, r, style, move="right") self.side(x, h, r, style, move="right")

View File

@ -91,7 +91,6 @@ class Silverware(Boxes):
h = self.h h = self.h
r = self.cornerradius r = self.cornerradius
self.open()
t = self.thickness t = self.thickness
b = self.burn b = self.burn

View File

@ -86,8 +86,6 @@ class Stachel(Boxes):
def render(self): def render(self):
# Initialize canvas
self.open()
ri = self.flutediameter / 2.0 ri = self.flutediameter / 2.0
ro = ri + self.wall ro = ri + self.wall

View File

@ -122,8 +122,6 @@ When turned by 90°, it can be also used to create a bottle holder."""
th = n * (h + t) - t th = n * (h + t) - t
# Initialize canvas
self.open()
self.addPart(ShadyEdge(self, None)) self.addPart(ShadyEdge(self, None))

View File

@ -37,7 +37,6 @@ class TrayInsert(Boxes):
h = self.h h = self.h
t = self.thickness t = self.thickness
self.open()
# Inner walls # Inner walls
for i in range(len(self.sx) - 1): for i in range(len(self.sx) - 1):

View File

@ -151,7 +151,6 @@ class TrayLayout2(TrayLayout):
for f in line: for f in line:
hasfloor |= f hasfloor |= f
self.open()
self.edges["s"] = boxes.edges.Slot(self, self.hi / 2.0) self.edges["s"] = boxes.edges.Slot(self, self.hi / 2.0)
self.edges["C"] = boxes.edges.CrossingFingerHoleEdge(self, self.hi) self.edges["C"] = boxes.edges.CrossingFingerHoleEdge(self, self.hi)

View File

@ -44,8 +44,6 @@ class TwoPiece(Boxes):
y -= 4*t + 2*p y -= 4*t + 2*p
h -= 2 * t h -= 2 * t
# Initialize canvas
self.open()
# Adjust h edge with play # Adjust h edge with play
self.edges["f"].settings.setValues(t, False, edge_width=self.edges["f"].settings.edge_width + p) self.edges["f"].settings.setValues(t, False, edge_width=self.edges["f"].settings.edge_width + p)

View File

@ -88,7 +88,6 @@ class TypeTray(_TopEdge):
hi = self.hi = self.hi or h hi = self.hi = self.hi or h
t = self.thickness t = self.thickness
self.open()
# outer walls # outer walls
b = self.bottom_edge b = self.bottom_edge

View File

@ -93,7 +93,6 @@ class UBox(_TopEdge, _ChestLid):
self.radius = r = min(r, x/2.0, y) self.radius = r = min(r, x/2.0, y)
self.open()
t1, t2, t3, t4 = self.topEdges(self.top_edge) t1, t2, t3, t4 = self.topEdges(self.top_edge)

View File

@ -69,7 +69,6 @@ class UnevenHeightBox(Boxes):
def render(self): def render(self):
self.open()
x, y = self.x, self.y x, y = self.x, self.y
heights = [self.height0, self.height1, self.height2, self.height3] heights = [self.height0, self.height1, self.height2, self.height3]

View File

@ -56,7 +56,6 @@ class UniversalBox(_TopEdge, _ChestLid):
x, y, h = self.x, self.y, self.h x, y, h = self.x, self.y, self.h
t = self.thickness t = self.thickness
self.open()
t1, t2, t3, t4 = self.topEdges(self.top_edge) t1, t2, t3, t4 = self.topEdges(self.top_edge)
b = self.edges.get(self.bottom_edge, self.edges["F"]) b = self.edges.get(self.bottom_edge, self.edges["F"])

View File

@ -46,8 +46,6 @@ class WaivyKnob(Boxes):
def render(self): def render(self):
t = self.thickness t = self.thickness
# Initialize canvas
self.open()
angle = self.serrationangle angle = self.serrationangle
self.parts.waivyKnob(self.diameter, self.serrations, angle, self.parts.waivyKnob(self.diameter, self.serrations, angle,
callback=lambda:self.dHole(0, 0, d=self.bolthole, callback=lambda:self.dHole(0, 0, d=self.bolthole,

View File

@ -110,7 +110,6 @@ class WineRack(Boxes):
self.cy = cy = int((y-dy-t) // (r+dy)) self.cy = cy = int((y-dy-t) // (r+dy))
self.delta = 3**0.5/6.*t self.delta = 3**0.5/6.*t
self.open()
self.rectangularWall(x, y, callback=[self.wallCB], move="up") self.rectangularWall(x, y, callback=[self.wallCB], move="up")
self.rectangularWall(x, y, callback=[lambda:self.wallCB(backwall=True)], move="up") self.rectangularWall(x, y, callback=[lambda:self.wallCB(backwall=True)], move="up")
self.rectangularWall(x, y, callback=[lambda:self.wallCB(frontwall=True)], move="up") self.rectangularWall(x, y, callback=[lambda:self.wallCB(frontwall=True)], move="up")

View File

@ -68,6 +68,7 @@ def run_generator(name, args):
if lower_name in generators.keys(): if lower_name in generators.keys():
box = generators[lower_name]() box = generators[lower_name]()
box.parseArgs(args) box.parseArgs(args)
box.open()
box.render() box.render()
box.close() box.close()
else: else:

View File

@ -27,7 +27,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 6, "execution_count": 5,
"metadata": { "metadata": {
"scrolled": true "scrolled": true
}, },
@ -36,7 +36,7 @@
"data": { "data": {
"image/svg+xml": [ "image/svg+xml": [
"<svg height=\"210mm\" version=\"1.1\" viewBox=\"0 9790 170 210\" width=\"170mm\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n", "<svg height=\"210mm\" version=\"1.1\" viewBox=\"0 9790 170 210\" width=\"170mm\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n",
"<g id=\"surface4\">\n", "<g id=\"surface11\">\n",
"<path d=\"M 150 50.103125 L 0 50.103125 M 0 50.103125 L -3 50.103125 C -3.054688 50.103125 -3.101562 50.060156 -3.101562 50.001562 M -3.101562 50.001562 L -3.101562 50.001562 M -3.101562 50.001562 L -3.101562 37.001562 M -3.101562 37.001562 C -3.101562 36.946875 -3.058594 36.9 -3 36.9 M -3 36.9 L 0 36.9 C -0.0546875 36.9 -0.101562 36.942969 -0.101562 37.001562 M -0.101562 37.001562 L -0.101562 28.001562 C -0.101562 28.05625 -0.0585938 28.103125 0 28.103125 M 0 28.103125 L -3 28.103125 C -3.054688 28.103125 -3.101562 28.060156 -3.101562 28.001562 M -3.101562 28.001562 L -3.101562 22.001562 M -3.101562 22.001562 C -3.101562 21.946875 -3.058594 21.9 -3 21.9 M -3 21.9 L 0 21.9 C -0.0546875 21.9 -0.101562 21.942969 -0.101562 22.001562 M -0.101562 22.001562 L -0.101562 13.001562 C -0.101562 13.05625 -0.0585938 13.103125 0 13.103125 M 0 13.103125 L -3 13.103125 C -3.054688 13.103125 -3.101562 13.060156 -3.101562 13.001562 M -3.101562 13.001562 L -3.101562 0.0015625 M -3.101562 0.0015625 L -3.101562 -5.998438 C -3.101562 -6.053125 -3.058594 -6.1 -3 -6.1 M -3 -6.1 L 0 -6.1 M 0 0.0015625 \" style=\"fill:none;stroke-width:0.2;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(0%,0%,0%);stroke-opacity:1;stroke-miterlimit:10;\" transform=\"matrix(-1,-0.000000000000000122,-0.000000000000000122,1,153.851562,9949.045313)\"/>\n", "<path d=\"M 150 50.103125 L 0 50.103125 M 0 50.103125 L -3 50.103125 C -3.054688 50.103125 -3.101562 50.060156 -3.101562 50.001562 M -3.101562 50.001562 L -3.101562 50.001562 M -3.101562 50.001562 L -3.101562 37.001562 M -3.101562 37.001562 C -3.101562 36.946875 -3.058594 36.9 -3 36.9 M -3 36.9 L 0 36.9 C -0.0546875 36.9 -0.101562 36.942969 -0.101562 37.001562 M -0.101562 37.001562 L -0.101562 28.001562 C -0.101562 28.05625 -0.0585938 28.103125 0 28.103125 M 0 28.103125 L -3 28.103125 C -3.054688 28.103125 -3.101562 28.060156 -3.101562 28.001562 M -3.101562 28.001562 L -3.101562 22.001562 M -3.101562 22.001562 C -3.101562 21.946875 -3.058594 21.9 -3 21.9 M -3 21.9 L 0 21.9 C -0.0546875 21.9 -0.101562 21.942969 -0.101562 22.001562 M -0.101562 22.001562 L -0.101562 13.001562 C -0.101562 13.05625 -0.0585938 13.103125 0 13.103125 M 0 13.103125 L -3 13.103125 C -3.054688 13.103125 -3.101562 13.060156 -3.101562 13.001562 M -3.101562 13.001562 L -3.101562 0.0015625 M -3.101562 0.0015625 L -3.101562 -5.998438 C -3.101562 -6.053125 -3.058594 -6.1 -3 -6.1 M -3 -6.1 L 0 -6.1 M 0 0.0015625 \" style=\"fill:none;stroke-width:0.2;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(0%,0%,0%);stroke-opacity:1;stroke-miterlimit:10;\" transform=\"matrix(-1,-0.000000000000000122,-0.000000000000000122,1,153.851562,9949.045313)\"/>\n",
"<path d=\"M 0 -0.000000000000028422 C 1.867188 -0.000000000000028422 1.867188 -2.796875 0 -2.796875 C -1.863281 -2.796875 -1.863281 -0.000000000000028422 0 -0.000000000000028422 \" style=\"fill:none;stroke-width:0.2;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(0%,0%,100%);stroke-opacity:1;stroke-miterlimit:10;\" transform=\"matrix(-0.000000000000000184,-1,-1,0.000000000000000184,142.453125,9959.046875)\"/>\n", "<path d=\"M 0 -0.000000000000028422 C 1.867188 -0.000000000000028422 1.867188 -2.796875 0 -2.796875 C -1.863281 -2.796875 -1.863281 -0.000000000000028422 0 -0.000000000000028422 \" style=\"fill:none;stroke-width:0.2;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(0%,0%,100%);stroke-opacity:1;stroke-miterlimit:10;\" transform=\"matrix(-0.000000000000000184,-1,-1,0.000000000000000184,142.453125,9959.046875)\"/>\n",
"<path d=\"M 0 0 C -0.0546875 0 -0.101562 0.046875 -0.101562 0.101562 M -0.101562 0.101562 L -0.101562 -2.898438 C -0.101562 -2.84375 -0.0585938 -2.796875 0 -2.796875 M 0 -2.796875 L -9 -2.796875 C -8.945312 -2.796875 -8.898438 -2.839844 -8.898438 -2.898438 M -8.898438 -2.898438 L -8.898438 0.101562 C -8.898438 0.046875 -8.941406 0 -9 0 M -9 0 L 0 0 \" style=\"fill:none;stroke-width:0.2;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(0%,0%,100%);stroke-opacity:1;stroke-miterlimit:10;\" transform=\"matrix(1,-0,-0,-1,143.351562,9946.046875)\"/>\n", "<path d=\"M 0 0 C -0.0546875 0 -0.101562 0.046875 -0.101562 0.101562 M -0.101562 0.101562 L -0.101562 -2.898438 C -0.101562 -2.84375 -0.0585938 -2.796875 0 -2.796875 M 0 -2.796875 L -9 -2.796875 C -8.945312 -2.796875 -8.898438 -2.839844 -8.898438 -2.898438 M -8.898438 -2.898438 L -8.898438 0.101562 C -8.898438 0.046875 -8.941406 0 -9 0 M -9 0 L 0 0 \" style=\"fill:none;stroke-width:0.2;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(0%,0%,100%);stroke-opacity:1;stroke-miterlimit:10;\" transform=\"matrix(1,-0,-0,-1,143.351562,9946.046875)\"/>\n",
@ -96,7 +96,6 @@
" def render(self):\n", " def render(self):\n",
" x, y, h = self.x, self.y, self.h\n", " x, y, h = self.x, self.y, self.h\n",
" t = self.thickness\n", " t = self.thickness\n",
" self.open()\n",
" \n", " \n",
" # render-magic goes here\n", " # render-magic goes here\n",
" \n", " \n",
@ -113,6 +112,7 @@
"b = Example()\n", "b = Example()\n",
"fd, fn = tempfile.mkstemp()\n", "fd, fn = tempfile.mkstemp()\n",
"b.parseArgs(['--reference=0', '--debug=0', '--output=' + fn])\n", "b.parseArgs(['--reference=0', '--debug=0', '--output=' + fn])\n",
"b.open()\n",
"b.render()\n", "b.render()\n",
"b.close()\n", "b.close()\n",
"\n", "\n",

View File

@ -395,6 +395,7 @@ Create boxes and more with a laser cutter!
box.format, box.format,
[('Content-type', 'application/unknown; charset=utf-8')])) [('Content-type', 'application/unknown; charset=utf-8')]))
fd, box.output = tempfile.mkstemp() fd, box.output = tempfile.mkstemp()
box.open()
box.render() box.render()
box.close() box.close()
result = open(box.output).readlines() result = open(box.output).readlines()