![Page 1: Boxes.py More than a Box generator...What? Box generator Written in Python Creates SVG Several supported models Library for own creations Supports flex, finger and flat dovetail joints](https://reader033.vdocument.in/reader033/viewer/2022050110/5f47a5fa1d01695d26224a8f/html5/thumbnails/1.jpg)
Boxes.pyMore than a Box generator
Florian Festi2014/03/15
MainframeHackspace Oldenburg
![Page 2: Boxes.py More than a Box generator...What? Box generator Written in Python Creates SVG Several supported models Library for own creations Supports flex, finger and flat dovetail joints](https://reader033.vdocument.in/reader033/viewer/2022050110/5f47a5fa1d01695d26224a8f/html5/thumbnails/2.jpg)
Outline
● Brief overview● Showing existing objects● How to use and adjust● Software architecture and how to use it● Outlook
![Page 3: Boxes.py More than a Box generator...What? Box generator Written in Python Creates SVG Several supported models Library for own creations Supports flex, finger and flat dovetail joints](https://reader033.vdocument.in/reader033/viewer/2022050110/5f47a5fa1d01695d26224a8f/html5/thumbnails/3.jpg)
Motivation
● Boxes for the Lasercutter● Drawing (finger) joints in CAD is a drag● Online box generators only allow fixed styles● No flexible opensource generators found
![Page 4: Boxes.py More than a Box generator...What? Box generator Written in Python Creates SVG Several supported models Library for own creations Supports flex, finger and flat dovetail joints](https://reader033.vdocument.in/reader033/viewer/2022050110/5f47a5fa1d01695d26224a8f/html5/thumbnails/4.jpg)
What?
● Box generator● Written in Python● Creates SVG● Several supported models● Library for own creations● Supports flex, finger and flat dovetail joints● Can be use to create more complicated things than
a simple box
![Page 5: Boxes.py More than a Box generator...What? Box generator Written in Python Creates SVG Several supported models Library for own creations Supports flex, finger and flat dovetail joints](https://reader033.vdocument.in/reader033/viewer/2022050110/5f47a5fa1d01695d26224a8f/html5/thumbnails/5.jpg)
Features
● Flex● Finger joints● Dovetail joints (flat only)● Holes in honey comb pattern● Several finished Models
![Page 6: Boxes.py More than a Box generator...What? Box generator Written in Python Creates SVG Several supported models Library for own creations Supports flex, finger and flat dovetail joints](https://reader033.vdocument.in/reader033/viewer/2022050110/5f47a5fa1d01695d26224a8f/html5/thumbnails/6.jpg)
Box.py
![Page 7: Boxes.py More than a Box generator...What? Box generator Written in Python Creates SVG Several supported models Library for own creations Supports flex, finger and flat dovetail joints](https://reader033.vdocument.in/reader033/viewer/2022050110/5f47a5fa1d01695d26224a8f/html5/thumbnails/7.jpg)
Box2.py
![Page 8: Boxes.py More than a Box generator...What? Box generator Written in Python Creates SVG Several supported models Library for own creations Supports flex, finger and flat dovetail joints](https://reader033.vdocument.in/reader033/viewer/2022050110/5f47a5fa1d01695d26224a8f/html5/thumbnails/8.jpg)
Box3.py
![Page 9: Boxes.py More than a Box generator...What? Box generator Written in Python Creates SVG Several supported models Library for own creations Supports flex, finger and flat dovetail joints](https://reader033.vdocument.in/reader033/viewer/2022050110/5f47a5fa1d01695d26224a8f/html5/thumbnails/9.jpg)
Flexbox.py
![Page 10: Boxes.py More than a Box generator...What? Box generator Written in Python Creates SVG Several supported models Library for own creations Supports flex, finger and flat dovetail joints](https://reader033.vdocument.in/reader033/viewer/2022050110/5f47a5fa1d01695d26224a8f/html5/thumbnails/10.jpg)
Flexbox2.py
![Page 11: Boxes.py More than a Box generator...What? Box generator Written in Python Creates SVG Several supported models Library for own creations Supports flex, finger and flat dovetail joints](https://reader033.vdocument.in/reader033/viewer/2022050110/5f47a5fa1d01695d26224a8f/html5/thumbnails/11.jpg)
Flexbox3.py
![Page 12: Boxes.py More than a Box generator...What? Box generator Written in Python Creates SVG Several supported models Library for own creations Supports flex, finger and flat dovetail joints](https://reader033.vdocument.in/reader033/viewer/2022050110/5f47a5fa1d01695d26224a8f/html5/thumbnails/12.jpg)
Typetray
![Page 13: Boxes.py More than a Box generator...What? Box generator Written in Python Creates SVG Several supported models Library for own creations Supports flex, finger and flat dovetail joints](https://reader033.vdocument.in/reader033/viewer/2022050110/5f47a5fa1d01695d26224a8f/html5/thumbnails/13.jpg)
Magazinefile.py
![Page 14: Boxes.py More than a Box generator...What? Box generator Written in Python Creates SVG Several supported models Library for own creations Supports flex, finger and flat dovetail joints](https://reader033.vdocument.in/reader033/viewer/2022050110/5f47a5fa1d01695d26224a8f/html5/thumbnails/14.jpg)
Folder.py
![Page 15: Boxes.py More than a Box generator...What? Box generator Written in Python Creates SVG Several supported models Library for own creations Supports flex, finger and flat dovetail joints](https://reader033.vdocument.in/reader033/viewer/2022050110/5f47a5fa1d01695d26224a8f/html5/thumbnails/15.jpg)
Silverwarebox
![Page 16: Boxes.py More than a Box generator...What? Box generator Written in Python Creates SVG Several supported models Library for own creations Supports flex, finger and flat dovetail joints](https://reader033.vdocument.in/reader033/viewer/2022050110/5f47a5fa1d01695d26224a8f/html5/thumbnails/16.jpg)
Drillbox.py
![Page 17: Boxes.py More than a Box generator...What? Box generator Written in Python Creates SVG Several supported models Library for own creations Supports flex, finger and flat dovetail joints](https://reader033.vdocument.in/reader033/viewer/2022050110/5f47a5fa1d01695d26224a8f/html5/thumbnails/17.jpg)
Castle.py
![Page 18: Boxes.py More than a Box generator...What? Box generator Written in Python Creates SVG Several supported models Library for own creations Supports flex, finger and flat dovetail joints](https://reader033.vdocument.in/reader033/viewer/2022050110/5f47a5fa1d01695d26224a8f/html5/thumbnails/18.jpg)
Lamp.py
![Page 19: Boxes.py More than a Box generator...What? Box generator Written in Python Creates SVG Several supported models Library for own creations Supports flex, finger and flat dovetail joints](https://reader033.vdocument.in/reader033/viewer/2022050110/5f47a5fa1d01695d26224a8f/html5/thumbnails/19.jpg)
Getting started
● Get from https://github.com/florianfesti/boxes– Git clone
– Or download
● Requires Python 2 or 3– Defaults to /usr/bin/python
● And Pycairo– Package pycairo, python-cairo or python3-cairo
– Windows install instructions still wanted
![Page 20: Boxes.py More than a Box generator...What? Box generator Written in Python Creates SVG Several supported models Library for own creations Supports flex, finger and flat dovetail joints](https://reader033.vdocument.in/reader033/viewer/2022050110/5f47a5fa1d01695d26224a8f/html5/thumbnails/20.jpg)
Using boxes.py
● Select script you want to use– You don't want boxes.py
● Adjust sizes and parameters● Execute script● Find result in box.svg
![Page 21: Boxes.py More than a Box generator...What? Box generator Written in Python Creates SVG Several supported models Library for own creations Supports flex, finger and flat dovetail joints](https://reader033.vdocument.in/reader033/viewer/2022050110/5f47a5fa1d01695d26224a8f/html5/thumbnails/21.jpg)
Adjusting Sizes
● Skip to the end of the file● Edit params given ● E.g. in Flexbox2.py:
if __name__=="__main__":
b = FlexBox(50, 70, 50, r=25,
thickness=3.0)
b.render()
![Page 22: Boxes.py More than a Box generator...What? Box generator Written in Python Creates SVG Several supported models Library for own creations Supports flex, finger and flat dovetail joints](https://reader033.vdocument.in/reader033/viewer/2022050110/5f47a5fa1d01695d26224a8f/html5/thumbnails/22.jpg)
Typical Parameters
● x, y, z, h: inner sizes– Often x,y is the side view and z width
● r: radius of corners● thickness: strength of the wood
– Influences how joints are made
● burn: correction for the beam width– This is the radius of the beam
– the amount of the offset at one side
![Page 23: Boxes.py More than a Box generator...What? Box generator Written in Python Creates SVG Several supported models Library for own creations Supports flex, finger and flat dovetail joints](https://reader033.vdocument.in/reader033/viewer/2022050110/5f47a5fa1d01695d26224a8f/html5/thumbnails/23.jpg)
Fingerjoint Settings
b.edges["f"].settings.setValues(
b.thickness, space=3, finger=3, surroundingspaces=1)
● Space: width in between fingers● Finger: width of fingers● Surroundingspaces: width at the end of the edge● All in multiples of thickness
– as passed as first param
![Page 24: Boxes.py More than a Box generator...What? Box generator Written in Python Creates SVG Several supported models Library for own creations Supports flex, finger and flat dovetail joints](https://reader033.vdocument.in/reader033/viewer/2022050110/5f47a5fa1d01695d26224a8f/html5/thumbnails/24.jpg)
Using the boxes Framework
● Several layers of abstraction● Base class Boxes in boxes.py● Scripts sub class Boxes
![Page 25: Boxes.py More than a Box generator...What? Box generator Written in Python Creates SVG Several supported models Library for own creations Supports flex, finger and flat dovetail joints](https://reader033.vdocument.in/reader033/viewer/2022050110/5f47a5fa1d01695d26224a8f/html5/thumbnails/25.jpg)
Primitives and Building blocks
● Cairo primitives (on self.ctx)
● Building blocks– Get coordinates passed to them
– Text and all kind of holes
● self.moveTo(x, y, dir)
– Change coordinate system to given point
● self.ctx.save()
● self.ctx.restore()
– To return to previous positions
![Page 26: Boxes.py More than a Box generator...What? Box generator Written in Python Creates SVG Several supported models Library for own creations Supports flex, finger and flat dovetail joints](https://reader033.vdocument.in/reader033/viewer/2022050110/5f47a5fa1d01695d26224a8f/html5/thumbnails/26.jpg)
Turtle Graphics Commands
● Edges and corners● Start at 0, 0 heading right● Move coordinate system to their endpoint● And their end orientation● Part is above the X Axis
– Go to right and turn mathematically positive
– to get a closed part
● Automatically do burn correction
![Page 27: Boxes.py More than a Box generator...What? Box generator Written in Python Creates SVG Several supported models Library for own creations Supports flex, finger and flat dovetail joints](https://reader033.vdocument.in/reader033/viewer/2022050110/5f47a5fa1d01695d26224a8f/html5/thumbnails/27.jpg)
Edges
● Classes on their own● Separate Settings classes● Allow sharing of settings among both sides● Boxes.edges[char] and Boxes.name● width: outset needed to begin this edge● margin: additional space needed (e.g. fingers)
![Page 28: Boxes.py More than a Box generator...What? Box generator Written in Python Creates SVG Several supported models Library for own creations Supports flex, finger and flat dovetail joints](https://reader033.vdocument.in/reader033/viewer/2022050110/5f47a5fa1d01695d26224a8f/html5/thumbnails/28.jpg)
Parts
● Walls and pieces– rectangularWall()
– roundedPlate()
– surroundingWall()
● move parameter– right, left up, down, only
● Callback for all sides– To put holes and other building blocks
– Pass either single function or list of callables
![Page 29: Boxes.py More than a Box generator...What? Box generator Written in Python Creates SVG Several supported models Library for own creations Supports flex, finger and flat dovetail joints](https://reader033.vdocument.in/reader033/viewer/2022050110/5f47a5fa1d01695d26224a8f/html5/thumbnails/29.jpg)
Edges parameter
● Iterable with characters or Edge objects● e, E: straight edge, normal and outset● f, F: Finger joints● h: Straight edge with holes for finger joint● d, D: Dovetails joints● X: Flex edge● You can register your own edges● Or pass them as Objects
![Page 30: Boxes.py More than a Box generator...What? Box generator Written in Python Creates SVG Several supported models Library for own creations Supports flex, finger and flat dovetail joints](https://reader033.vdocument.in/reader033/viewer/2022050110/5f47a5fa1d01695d26224a8f/html5/thumbnails/30.jpg)
Still missing
● Command line interface● Smarter output file name (scriptname + params)● Support for Edges other than 90°
– Switch lamp.py over to hexagonal head
● Cleaning stuff up
● Patches welcome!
![Page 31: Boxes.py More than a Box generator...What? Box generator Written in Python Creates SVG Several supported models Library for own creations Supports flex, finger and flat dovetail joints](https://reader033.vdocument.in/reader033/viewer/2022050110/5f47a5fa1d01695d26224a8f/html5/thumbnails/31.jpg)
Questions?