# Fritzing Breadboard generator

version 1.2

An example of a breadboard.

## Usage

This script can outputs the image (.svg) or the fritzing part file (.fzp) for a breadboard. To run it you use the command line. Go to the folder that contains the scipt and run it with the `run` and `svg`. Like this:

        % cd FrizingPDK/Tools/BreadboardGenerator
        % python generator.py run svg

it will just spit out a bunch of svg xml into your window. You can copy and paste it from there, but it’s more convenient to send the output of the command to a file directly. In Unix terms this is called redirecting:

        % python generator.py run svg > myBreadboard.svg

This will generate an image file `myBreadboard.svg` in the same location as where you are running the script from.

This is still not very useful to run the script like this, because it is just generating the svg and fzp code for the standard breadboard, which already is in your Fritzing library. That's why this tool becomes especially useful if you want to create your own no-so-standard breadboard.

The way to use this tool is to modify it. Open the `generator.py` in your favorite code editor and change the variables. Most useful variables to play with can be found in the `setup()` method, right below

       50 def setup():
       51     # Edit these variables below to generate different breadboards
       52     #

There you'll find some properties, which you'll want to change to make this your own unique part: the `title`, `moduleID` and maybe the `label` and its `taxonomy`. The `svgFile` should be the file name of the svg file that you'll save it to.

       54     sL['title'] = "My Breadboard"
       55     sL['moduleID'] = "MyBreadboardModuleID"
       56     sL['svgFile'] = "myBreadboard.svg"
       57
       58     sL['label'] = "Breadboard"
       59     sL['taxonomy'] = "prototyping.breadboard.breadboard.breadboard0"

And then there you'll find some other variables (and properties of the `rowProps` and `lineProps` dict) which specify exactly how your breadboard looks:

       65     # Rows
       66     rowHeight = 5 # You probably never need to change this, but who knows
       67     rowsInterBlockSpacing = 2
       68     rowProps['startsAtX'] = -1
       69     rowProps['startsAtYWithLetter'] = 'A'
       70     rowProps['segmentLength'] = 64
       71     rowProps['interSegmentSpacing'] = 2
       72     rowProps['numberOfSegments'] = 1
       73
       74     # Lines
       75     numberOfLinesPerSet = 2
       76     interRowsLinesSpacing = 2
       77     lineProps['startAtX'] = 2
       78     lineProps['subSegmentLength'] = 5
       79     lineProps['interSubSegmentSpacing'] = 1
       80     lineProps['segmentLength'] = 5 # measures in subSegments
       81     lineProps['interSegmentSpacing'] = 2
       82     lineProps['numberOfSegments'] = 2
       83     lineProps['endsAtYWithLetter'] = 'Z'

Those variables and properties define how the breadboard is generated and what kind of breadboard it is. The following diagram shows where those variables and properties apply on the breadboard and how to measure them.

a diagram of all the variables and properties used in the generation of a breadboard.

### Choose your weapon

This tool can create the image (a `.svg` file) and the Fritzing part (a `.fzp` file). To choose between these two you have to use a second argument after `run`: `svg` or `fzp`.

The following commands creates both the image and the part file:

    	% python generator.py run svg > myBreadboard.svg
    	% python generator.py run fzp > myBreadboard.fzp

### Modify the image

This tool creates almost a perfect breadboard image. It creates all the right sockets and creates the right size background. It just doesn’t fix the text on the breadboard and the grooves and notches. For those elements this script just uses the artwork from the standard breadboard. So you would have to open the file in your drawing application and fix those elements yourself.

NOTE: The image created through this script is 90dpi. But Adobe Illustrator can only understand and assumes 72dpi. So if you open the svg in Adobe Illustrator it will scale it down (from 90 to 72 dpi), and if you then save, it will be too small.
The trick to solve this nasty dpi scaling problem is that you first 1. remove the size data from the svg file with a texteditor. Then 2. you open and modify the file in Illustrator. Finally 3. you go back to the texteditor and edit the scaling back in. Check the resolution manifest for details.

## Full Reference

This script outputs the image (.svg) or the fritzing part file (.fzp) for a breadboard.

### Usage:

Run it in the commandline and redirect the result to a file:

    	python generator.py run [svg|fzp] > partdescription.xml

### Arguments:

run
  Use this to run the script. Without this argument, this same help text is displayed.
[svg|fzp]
  Specify whether the script should generate the .svg file or the .fzp file.
  If this argument is omitted, it defaults to svg.

### Advanced Usage:

If you want to change the type of breadboard which this script generates (the main reason for this script to be in the Fritzing PDK), you can easily edit the python file. The setup() method defines most of the parameters of the breadboard. Probably changing values here is enough for you to make the exact breadboard you like.

For more information on how to create parts and how to use them in Fritzing,
please read the online documentation:
http://fritzing.org/learning/parts