boxes.py more than a box generator...what? box generator written in python creates svg several...

31
Boxes.py More than a Box generator Florian Festi 2014/03/15 Mainframe Hackspace Oldenburg

Upload: others

Post on 14-Jul-2020

7 views

Category:

Documents


0 download

TRANSCRIPT

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Questions?