├── demo
├── KiCad
│ ├── kicaddemo.png
│ ├── command.sh
│ ├── README.md
│ └── demo-all-pos.csv
├── demo_cc2538_top.png
├── EagleCad
│ ├── nightfirebasic.png
│ ├── nightfirebasic-smd.mnt
│ └── MeatBagPnp.ulp
├── README.md
└── demo_cc2538_pnp.csv
├── meatbag_example_topbot.png
├── .gitignore
├── README.md
├── meatbag.py
└── LICENSE
/demo/KiCad/kicaddemo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/colinoflynn/MeatBagPnP/HEAD/demo/KiCad/kicaddemo.png
--------------------------------------------------------------------------------
/demo/demo_cc2538_top.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/colinoflynn/MeatBagPnP/HEAD/demo/demo_cc2538_top.png
--------------------------------------------------------------------------------
/meatbag_example_topbot.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/colinoflynn/MeatBagPnP/HEAD/meatbag_example_topbot.png
--------------------------------------------------------------------------------
/demo/EagleCad/nightfirebasic.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/colinoflynn/MeatBagPnP/HEAD/demo/EagleCad/nightfirebasic.png
--------------------------------------------------------------------------------
/demo/KiCad/command.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | # run this command from directory with meatbag.py
3 | ./meatbag.py --format kicad --image demo/KiCad/kicaddemo.png --width 53.5 --height 58.5 --csv demo/KiCad/demo-all-pos.csv
4 |
--------------------------------------------------------------------------------
/demo/README.md:
--------------------------------------------------------------------------------
1 | ## CC2538 Demo
2 |
3 | To run demo:
4 |
5 | 1. Load top-side image file (this only has parts on top)
6 | 2. Setup PCB width/height as follows just underneath image:
7 | Width: 52.3
8 | Height: 64.5
9 | 3. Load PnP file (the .csv)
10 | 4. Click on a BOM line item, suggest the 100n capacitor as you can space-bar-place through them. You can also paste a manufacture PN into the text box.
11 |
--------------------------------------------------------------------------------
/demo/EagleCad/nightfirebasic-smd.mnt:
--------------------------------------------------------------------------------
1 | Designator,Comment,Layer,Footprint,Center-X(mm),Center-Y(mm),Rotation,SMD/THT,Manufacture Part Number 1
2 | F1,,TopLayer,1812,33.0200,17.1450,90.0,SMD,
3 | F2,,TopLayer,1812,12.7000,17.1450,90.0,SMD,
4 | F3,,TopLayer,1812,7.6200,17.1450,90.0,SMD,
5 | F4,,TopLayer,1812,27.9400,17.1450,90.0,SMD,
6 | F5,,TopLayer,1812,43.1800,17.1450,90.0,SMD,
7 | F6,,TopLayer,1812,22.8600,17.1450,90.0,SMD,
8 | F7,,TopLayer,1812,38.1000,17.1450,90.0,SMD,
9 | F8,,TopLayer,1812,17.7800,17.1450,90.0,SMD,
10 | R1,10k,TopLayer,R1206,36.8300,43.8150,270.0,SMD,
11 | R2,10k,TopLayer,R1206,33.0200,31.1150,0.0,SMD,
12 | R3,10k,TopLayer,R1206,27.9400,31.1150,180.0,SMD,
13 | R4,10k,TopLayer,R1206,12.7000,31.1150,0.0,SMD,
14 | R6,10k,TopLayer,R1206,43.1800,31.1150,0.0,SMD,
15 | R7,10k,TopLayer,R1206,38.1000,31.1150,180.0,SMD,
16 | R8,10k,TopLayer,R1206,22.8600,31.1150,0.0,SMD,
17 | R9,10k,TopLayer,R1206,17.7800,31.1150,180.0,SMD,
18 | R5,10k,TopLayer,R1206,7.6200,31.1150,180.0,SMD,RC1206FR-0710KL
19 | T1,DMN3024LSD,TopLayer,SO8,30.4800,24.7650,180.0,SMD,DMN3024LSD-13
20 | T2,DMN3024LSD,TopLayer,SO8,10.1600,24.7650,180.0,SMD,DMN3024LSD-13
21 | T3,DMN3024LSD,TopLayer,SO8,40.6400,24.7650,180.0,SMD,DMN3024LSD-13
22 | T4,DMN3024LSD,TopLayer,SO8,20.3200,24.7650,180.0,SMD,DMN3024LSD-13
23 | IC2,MCP2300X/SO,TopLayer,SO18W,27.9400,41.2750,180.0,SMD,
24 | SJ3,,BottomLayer,SJ_3_PASTE2&3,16.5100,42.5450,0.0,SMD,
25 | SJ4,,BottomLayer,SJ_3_PASTE2&3,16.5100,40.0050,0.0,SMD,
26 | SJ5,,BottomLayer,SJ_3_PASTE2&3,16.5100,37.4650,0.0,SMD,
27 |
--------------------------------------------------------------------------------
/demo/KiCad/README.md:
--------------------------------------------------------------------------------
1 | # MeatBagPnP Kicad integration demo
2 |
3 | The p&p placement file and PCB image in this directory were generated using kicad.
4 | The actual PCB dimensions are
5 | * width: 53.5
6 | * height: 58.5
7 |
8 | In order to enable kicad CSV parsing, you must specify the "--format kicad" argument when launching the program, e.g. (from the application directory):
9 |
10 | ./meatbag.py --format kicad --image demo/KiCad/kicaddemo.png --width 53.5 --height 58.5 --csv demo/KiCad/demo-all-pos.csv
11 |
12 |
13 | ## Kicad PnP File Format
14 |
15 | The PnP placement files created with Kicad (File -> Fabrication Outputs -> Footprint position (.pos) file) will work as-is, as long as you:
16 | * place a "drill and place offset" marker on the lower left corner of your board
17 | * select the CSV export format;
18 | * use the "single file per board" option (rather than file per side); and
19 | * ensure the units match whatever you will specify as the PCB size, here.
20 |
21 | For reference, the currently standard PnP format for kicad is
22 |
23 | Ref,Val,Package,PosX,PosY,Rot,Side
24 |
25 | which MeatBadPnP now supports.
26 |
27 | ## Kicad PCB Image
28 |
29 | You can produce an image anyway you like using kicad. I've used the gerber viewer and the 3D viewer successfully, the important points are that the images must be head on (perspective won't be account for) and only include the PCB itself (no margins, unless you account for this when specifying your dimensions to meatbagpnp).
30 |
31 |
32 | 2018-04-30, Pat Deegan, psychogenic.com
33 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Byte-compiled / optimized / DLL files
2 | __pycache__/
3 | *.py[cod]
4 | *$py.class
5 |
6 | # C extensions
7 | *.so
8 |
9 | # Distribution / packaging
10 | .Python
11 | env/
12 | build/
13 | develop-eggs/
14 | dist/
15 | downloads/
16 | eggs/
17 | .eggs/
18 | lib/
19 | lib64/
20 | parts/
21 | sdist/
22 | var/
23 | wheels/
24 | *.egg-info/
25 | .installed.cfg
26 | *.egg
27 |
28 | # PyInstaller
29 | # Usually these files are written by a python script from a template
30 | # before PyInstaller builds the exe, so as to inject date/other infos into it.
31 | *.manifest
32 | *.spec
33 |
34 | # Installer logs
35 | pip-log.txt
36 | pip-delete-this-directory.txt
37 |
38 | # Unit test / coverage reports
39 | htmlcov/
40 | .tox/
41 | .coverage
42 | .coverage.*
43 | .cache
44 | nosetests.xml
45 | coverage.xml
46 | *.cover
47 | .hypothesis/
48 |
49 | # Translations
50 | *.mo
51 | *.pot
52 |
53 | # Django stuff:
54 | *.log
55 | local_settings.py
56 |
57 | # Flask stuff:
58 | instance/
59 | .webassets-cache
60 |
61 | # Scrapy stuff:
62 | .scrapy
63 |
64 | # Sphinx documentation
65 | docs/_build/
66 |
67 | # PyBuilder
68 | target/
69 |
70 | # Jupyter Notebook
71 | .ipynb_checkpoints
72 |
73 | # pyenv
74 | .python-version
75 |
76 | # celery beat schedule file
77 | celerybeat-schedule
78 |
79 | # SageMath parsed files
80 | *.sage.py
81 |
82 | # dotenv
83 | .env
84 |
85 | # virtualenv
86 | .venv
87 | venv/
88 | ENV/
89 |
90 | # Spyder project settings
91 | .spyderproject
92 | .spyproject
93 |
94 | # Rope project settings
95 | .ropeproject
96 |
97 | # mkdocs documentation
98 | /site
99 |
100 | # mypy
101 | .mypy_cache/
102 | /*.csv
103 | .idea/
104 |
--------------------------------------------------------------------------------
/demo/demo_cc2538_pnp.csv:
--------------------------------------------------------------------------------
1 | Altium Designer Pick and Place Locations
2 | C:\Users\colin\Dropbox (NewAE Technology Inc)\engineering\git_repos\CW308T\CW308T_CC2538\NAE-CW308T-CC2538\OUTPUT\FILES\Pick Place\Pick Place for NPCB-CW308T-CC2538(Production of NAE-CW308T-CC2538).csv
3 |
4 | ========================================================================================================================
5 | File Design Information:
6 |
7 | Date: 24/11/17
8 | Time: 09:12
9 | Revision: Not in VersionControl
10 | Variant: Production of NAE-CW308T-CC2538
11 | Units used: mm
12 |
13 | "Designator","Comment","Layer","Footprint","Center-X(mm)","Center-Y(mm)","Rotation","Description","Manufacture Part Number 1","Supplier Part Number 1"
14 | "R10","2k2","TopLayer","RESC1608X55N","39.6240","35.7750","90","2k2 res, 0603, 1%, 1/10W","RC0603FR-072K2L","311-2.20KHRCT-ND"
15 | "C18","1n","TopLayer","CAPC0603_M","38.9240","38.6080","180","1n, 0603","",""
16 | "R9","56k","TopLayer","RESC1608X55N","21.0430","44.8310","360","56k res, 0603, 1%, 1/10W","RC0603FR-0756KL","311-56KHRCT-ND"
17 | "C20","100n","TopLayer","CAPC0603_M","25.2730","32.0690","270","100n, 0603","C0603C104K5RACTU","399-5089-2-ND"
18 | "C15","100n","TopLayer","CAPC0603_M","34.3520","36.7030","360","100n, 0603","C0603C104K5RACTU","399-5089-2-ND"
19 | "R1","22R","TopLayer","RESC1608X55N","38.9010","45.2120","360","22R res, 0603, 1%, 1/10W","RC0603FR-0722RL","311-22.0HRCT-ND"
20 | "R2","100R","TopLayer","RESC1608X55N","15.9630","49.2760","180","100R res, 0603, 1%, 1/10W","RC0603FR-07100RL","311-100HRCT-ND"
21 | "J1","","TopLayer","CW308_TBOARD_CONN","26.1620","31.2420","0","CW308 "Standard" Target Board Connector","",""
22 | "C8","1u","TopLayer","CAPC0603_M","15.9370","34.0360","180","1u, 0603","CL10A105KB8NNNC","1276-1860-1-ND"
23 | "C6","1u","TopLayer","CAPC0603_M","44.3230","44.5150","270","1u, 0603","CL10A105KB8NNNC","1276-1860-1-ND"
24 | "C7","100n","TopLayer","CAPC0603_M","41.9100","44.5150","270","100n, 0603","C0603C104K5RACTU","399-5089-2-ND"
25 | "C9","100n","TopLayer","CAPC0603_M","15.9370","37.0840","180","100n, 0603","C0603C104K5RACTU","399-5089-2-ND"
26 | "C10","100n","TopLayer","CAPC0603_M","15.9400","40.1320","180","100n, 0603","C0603C104K5RACTU","399-5089-2-ND"
27 | "C11","100n","TopLayer","CAPC0603_M","15.9400","43.1800","180","100n, 0603","C0603C104K5RACTU","399-5089-2-ND"
28 | "C12","100n","TopLayer","CAPC0603_M","15.9370","46.2280","180","100n, 0603","C0603C104K5RACTU","399-5089-2-ND"
29 | "C13","100n","TopLayer","CAPC0603_M","34.3550","41.1480","0","100n, 0603","C0603C104K5RACTU","399-5089-2-ND"
30 | "C14","100n","TopLayer","CAPC0603_M","29.0830","30.5450","270","100n, 0603","C0603C104K5RACTU","399-5089-2-ND"
31 | "BRD","","TopLayer","CW308T_TBOARD_DEFSIZE","-25.2730","-25.5270","0","308T Board Outline (Layer 1)","",""
32 | "C19","100n","TopLayer","CAPC0603_M","34.3550","47.6250","360","100n, 0603","C0603C104K5RACTU","399-5089-2-ND"
33 | "U1","CC2538SF53RT","TopLayer","QFN50P800X800X100_HS-57M","26.1620","39.7510","90","IC RF TXRX+MCU 802.15.4, ARM, ECC/AES/RSA","CC2538SF53RTQT","296-35797-1-ND"
34 |
--------------------------------------------------------------------------------
/demo/KiCad/demo-all-pos.csv:
--------------------------------------------------------------------------------
1 | Ref,Val,Package,PosX,PosY,Rot,Side
2 | "C1","0.1u","C_0805",23.800000,40.000000,270.000000,top
3 | "C2","0.1u","C_0805",28.000000,14.500000,90.000000,top
4 | "C3","0.1u","C_0805",25.600000,33.800000,270.000000,top
5 | "C4","0.1u","C_0805",36.200000,24.800000,180.000000,top
6 | "C5","10u","C_0805",16.600000,24.700000,270.000000,top
7 | "C6","0.1u","C_0805",18.500000,24.700000,270.000000,top
8 | "C7","22u","C_0805",38.100000,49.200000,180.000000,top
9 | "C8","1u","C_0805",37.000000,46.300000,90.000000,top
10 | "C9","0.1u","C_0805",34.000000,32.400000,0.000000,top
11 | "C10","1u","C_0805",48.400000,48.000000,180.000000,top
12 | "C11","1u","C_0805",11.300000,8.900000,270.000000,top
13 | "C12","1u","C_0805",17.300000,8.800000,90.000000,top
14 | "C13","0.1u","C_0805",14.200000,18.500000,90.000000,top
15 | "C14","0.1u","C_0805",11.100000,14.400000,0.000000,top
16 | "C15","DNP","C_0805",7.000000,21.600000,270.000000,top
17 | "C16","0.1u","C_0805",40.800000,20.800000,90.000000,top
18 | "C17","0.1u","C_0805",47.700000,14.700000,180.000000,top
19 | "C18","4pF","C_0805",38.400000,20.800000,270.000000,top
20 | "C19","0.1u","C_0805",40.800000,7.400000,270.000000,top
21 | "C21","4pF","C_0805",38.400000,7.400000,90.000000,top
22 | "D1","LED","LED_0805",21.650000,14.750000,90.000000,top
23 | "D2","LED","LED_0805",25.666789,14.711961,90.000000,top
24 | "L1","Ferrite_Bead","R_0805_HandSoldering",14.600000,24.800000,270.000000,top
25 | "Q1","MOSFET_PCH","SOT23-3",9.400000,34.500000,0.000000,top
26 | "Q2","MOSFET_PCH","SOT23-3",10.430872,40.226462,90.000000,top
27 | "Q3","MOSFET_NCH","SOT-23",5.400000,49.400000,270.000000,top
28 | "Q4","MOSFET_NCH","SOT-23",40.400000,38.800000,90.000000,top
29 | "Q5","MOSFET_NCH","SOT-23",40.442500,27.689762,270.000000,top
30 | "R1","10k","R_0603",19.750000,14.250000,270.000000,top
31 | "R2","10k","R_0603",23.750000,14.250000,270.000000,top
32 | "R3","5k","R_0603",34.780000,52.400000,270.000000,top
33 | "R4","5k","R_0603",34.780000,49.600000,270.000000,top
34 | "R5","10k","R_0603",23.800000,43.400000,270.000000,top
35 | "R6","22R","R_0603",39.100000,46.200000,90.000000,top
36 | "R7","10k","R_0603",31.700000,42.800000,0.000000,top
37 | "R8","22R","R_0603",44.800000,45.750000,270.000000,top
38 | "R9","10k","R_0603",11.800000,34.100000,270.000000,top
39 | "R10","10k","R_0603",13.000000,40.200000,90.000000,top
40 | "R11","200k","R_0603",8.800000,38.250000,90.000000,top
41 | "R12","73.2k/1%","R_0603",4.800000,43.500000,270.000000,top
42 | "R13","127k/1%","R_0603",6.500000,43.500000,90.000000,top
43 | "R14","10k","R_0603",10.250000,29.200000,0.000000,top
44 | "R15","10k","R_0603",8.900000,22.200000,270.000000,top
45 | "R16","10k","R_0603",4.500000,22.750000,0.000000,top
46 | "R17","10k","R_0603",8.200000,14.750000,90.000000,top
47 | "R18","R_US","R_0603",44.000000,39.000000,180.000000,top
48 | "R19","56k","R_0603",43.400000,21.700000,0.000000,top
49 | "R20","470k","R_0603",43.400000,20.000000,180.000000,top
50 | "R21","R_US","R_0603",44.000000,27.500000,180.000000,top
51 | "R22","56k","R_0603",43.400000,8.400000,0.000000,top
52 | "R23","470k","R_0603",43.400000,6.800000,180.000000,top
53 | "R24","5k","R_0603",41.250000,51.500000,0.000000,top
54 | "R25","5k","R_0603",44.750000,51.500000,0.000000,top
55 | "R26","1k","R_0603",5.500000,52.200000,180.000000,top
56 | "R27","1k","R_0603",40.400000,36.000000,0.000000,top
57 | "R28","1k","R_0603",40.500000,30.400000,180.000000,top
58 | "U1","ATXMEGA128A4U-AU","TQFP44",27.000000,24.300000,90.000000,top
59 | "U2","SOMECHIP","DFN-6-2x2mm_Pitch0.65mm",41.900000,44.800000,0.000000,top
60 | "U3","NOTHERCHIP","SOIC-8_3.9x4.9mm_Pitch1.27mm",33.100000,37.800000,270.000000,top
61 | "U4","AP2112","SOT-23-5",14.300000,8.900000,0.000000,top
62 | "U5","NICECHIP","SOIC-8_3.9x4.9mm_Pitch1.27mm",4.500000,38.100000,90.000000,top
63 | "U7","SMELLYCHIP","Bosch_LGA-8_2.5x2.5mm_P0.65mm_ClockwisePinNumbering",11.182500,17.032381,90.000000,top
64 | "U8","SOMECHIP2","AMS_LGA-10-1EP_2.7x4mm_P0.6mm",8.750000,26.300000,270.000000,top
65 | "U9","ICMCHIP","SOIC-14_3.9x8.7mm_Pitch1.27mm",40.800000,14.400000,270.000000,top
66 | "U10","FUNNYCHIP","SOIC-8_3.9x4.9mm_Pitch1.27mm",45.000000,33.300000,270.000000,top
67 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # MeatBagPnP
2 | The year is 2040. The robot uprising is complete, and most humans are enslaved for their purposes. This tool is written to provide an easy tool for the robot overlords to now use humans as a pick-n-place machine. It's rumored that by contributing to this repo you will be given a task involving less poisonous materials.
3 |
4 | To use: scan barcode on a part bag, and utility tells you where to place part on PCB. Helps you, [the meatbag,](https://www.youtube.com/watch?v=f-1ry9zMi4o) become a pick-n-place. Notice little red dot on right-side in following image, telling you where to place part. If you hit 'spacebar' it advances to next placement (also special scan-codes could be used to avoid needing keyboard):
5 |
6 | 
7 |
8 | See the following video for a demo: https://www.youtube.com/watch?v=3arWSPCR0Ww .
9 |
10 | ## Installing
11 |
12 | The tool runs on Python 2.7, which is still around in 2040.
13 |
14 | ### Dependencies
15 | Pyside
16 |
17 |
18 | ### Scanner Setup
19 |
20 | The tool is designed to run with a crappy barcode scanner. It probably works with a good barcode scanner, but I don't have one.
21 |
22 | It automatically collects keystrokes while the window has focus, since the scanner normally appears as a keyboard. Do not type your bank password into this tool, as it will send it to Mouser.
23 |
24 | The scanner does not require a line-end, as the tool uses a pause in characters to mean "done with data". Some scanners aren't setup with line-ends so this way you don't need to worry about configuration.
25 |
26 | If you don't have a scanner you can copy/paste pns into the text box. But it also allows you to "click" on a row - when you click on a row it uses that to match the PN, so rows must still have valid PNs. This means you can click on ANY 200-ohm resistor for example, and it will highlight the first one and allow you to "spacebar" through placement.
27 |
28 | #### Scanner Types
29 |
30 | Be aware there are two main types of scanners. One type uses a scanned laser (with a little spinning mirror), and works VERY well for linear (classic-looking) barcodes. These barcodes are used (as of Q4/2017) on Mouser bags.
31 |
32 | The second uses a little CMOS camera. It works with all barcode types, BUT can be very hard to use with the Mouser linear barcodes. The problem is the Mouser barcodes are too long to easily fit in the camera's field of view, and it requires you to mask out the "other" barcodes beside the Mouser PN code. But this cmos camera type (will normally advertise working with 2D barcodes) is required for Digikeys.
33 |
34 | The easiest solution is to purchase two cheap scanners - they are still only like $15. Both run at once without issue.
35 |
36 | ## Command Line
37 | In order to support other CSV file formats, and simply to avoid the requirement of using lots of GUI elements on every start-up, there are now several supported command line arguments. These are documented by the online help, visible by launching with the --help flag.
38 |
39 |
40 | usage: meatbag.py [-h] [--csv CSV] [--format FORMAT] [--width WIDTH] [--height HEIGHT] [--image IMAGE]
41 | MeatBagPnP
42 | optional arguments:
43 | -h, --help show this help message and exit
44 | --csv CSV CSV file to use
45 | --format FORMAT CSV file format (altium|kicad|eagle)
46 | --width WIDTH PCB width
47 | --height HEIGHT PCB height
48 | --image IMAGE
49 |
50 |
51 | Where "csv" and "image" are paths to the files in question, and width/height are floats for the relevant PCB dimension.
52 |
53 |
54 | ## Supported CAD
55 |
56 | The --format flag determines what type of CSV file the program expects.
57 |
58 | ### Altium
59 | Altium is the original, and default, system supported.
60 |
61 | ### KiCad
62 | Specifying kicad for the --format will set things up for the default .pos file output by that program. You can get specific info on how to get going on
63 | [this page](https://flyingcarsandstuff.com/2018/04/simplifying-assembly-open-source-manual-pick-place-assistance/) or having a gander at the contents of demo/KiCad in the source distribution.
64 |
65 | ### Eagle
66 | Eagle works by using a ULP to spit out a CSV of the correct format. See demo/EagleCad.
67 |
68 | ## PnP File Format
69 |
70 | You can modify this as needed. Right now it assumes the following rough format (which is basically a default Altium output with some other stuff enabled):
71 |
72 | "Designator","Comment","Layer","Footprint","Center-X(mm)","Center-Y(mm)","Rotation","Description","Manufacture Part Number 1","Supplier Part Number 1"
73 | "L4","FBMH3225HM102NTV","BottomLayer","INDC3225X06N","79.5274","5.9436","360","Ferrite Bead, 1K@100MHz, 2A, 1210, 100mOhm DC, AEC-Q200","FBMH3225HM102NTV","587-3835-1-ND"
74 | "L2","FBMH3225HM102NTV","BottomLayer","INDC3225X06N","84.3788","10.5918","180","Ferrite Bead, 1K@100MHz, 2A, 1210, 100mOhm DC, AEC-Q200","FBMH3225HM102NTV","587-3835-1-ND"
75 | "C58","100n","BottomLayer","CAPC0603_M","67.3354","36.0172","180","100n, 0603","C0603C104K5RACTU","399-5089-2-ND"
76 |
77 | NOTE1: Of all those fields, the only ones needed are "Designator", "Layer", "Center-X(mm)","Center-Y(mm)", and "Manufacture Part Number 1". They are hard-coded numbers in the Python right now regarding the column location.
78 |
79 | NOTE2: You MUST have set your origin/reference as the bottom left of the PCB.
80 |
81 | NOTE3: Part number is the only used feature right now. The code could be modified to use value as well for example, which would allow you to use the "click feature" to identify all placements of a certain value even if you don't use unique PNs in your BOM.
82 |
83 |
84 |
85 | ## PCB Image
86 |
87 | The tool uses a PCB image. This PCB image should be a .png file which exactly matches the PCB width/height. The tool is told the actual PCB dimensions (i.e., in mm) and automatically scales stuff assuming you have provided a correct image.
88 |
89 | The image of the bottom side should be mirrored (i.e., so it looks like when you are holding the PCB). The easiest thing here if you have a tool with 3D rendering is to screen-shot the 3D view, and just crop it in paint or whatever. You could also just take a photo of your actual PCB. Be sure to crop it down to remove any whitespace around PCB.
90 |
91 | ## Future Plans
92 |
93 | ### API Integration
94 |
95 | The tool uses web scraping style stuff right now. Digikey & Mouser have APIs that probably do what I want even better, but then you've got to individually register API keys. The web scraping is more likely to break with website changes, but doesn't need API keys.
96 |
97 | ### Phone App
98 |
99 | One day this thing might exist as a phone app, allowing you to do everything (take photo of PCB, scan barcodes, etc). This will have to wait until I know how to write phone apps. Be assured when it does become released, the screen will be so obscured with advertising it will be almost unusable, and inexplicitly require permissions to send text messages.
100 |
101 | # About/License
102 |
103 | MeatbagPnP is a community project with the following authors:
104 |
105 | * Colin O'Flynn (@colinoflynn: original author)
106 | * @pikokosan (added Eagle support and examples)
107 | * Pat Deegan (@psychogenic: added Kicad support + many features including matching all parts, different file formats, hotkeys etc)
108 |
109 |
--------------------------------------------------------------------------------
/demo/EagleCad/MeatBagPnp.ulp:
--------------------------------------------------------------------------------
1 | #usage "en:Data generation for mounting machines
"
2 | "Export of data for SMD and THT can be in separated files.
"
3 | "Author: support@cadsoft.de",
4 | "de:Datengenerierung für Bestückungsautomaten "
5 | "Exportiert die Daten für SMD- und THT-Bauteile ggf. in getrennte Dateien.
"
6 | "Author: support@cadsoft.de
"
7 |
8 | // THIS PROGRAM IS PROVIDED AS IS AND WITHOUT WARRANTY OF ANY KIND, EXPRESSED OR IMPLIED
9 |
10 | string Version = "0.0.2"; // 1.0.0 - 2011-11-23
11 |
12 | #require 5.1100
13 |
14 | // History
15 | // 1.0.0 - 2011-11-23
16 | // 1.0.1 - 2016-01-21 support@cadsoft.de, output file names changed
17 | // 1.0.2 - 2016-07-18 support@cadsoft.de, added contact typ to output
18 |
19 |
20 | string AttributeFeederAngleOffset = "FAO"; // feeder angle offset to part
21 | real FeederAngleOffset[];
22 |
23 | real AngleLayoutFeeder = 0.0; // offset between feeder and placed PCB on mounting machine
24 |
25 | string ExpAttrName = "MPN"; // Manufacturer Part Number
26 | char delimiter = ',';
27 | char quote = '"';
28 | string Passer;
29 | string EName[];
30 | string EPack[];
31 | string EValue[];
32 | string EAttr[];
33 | real Ex[], Ey[], Ea[];
34 | real Eox[], Eoy[];
35 | real ExC[], EyC[]; // calculated center by smd
36 | int Em[];
37 | string tb[] = {"TopLayer", "BottomLayer" };
38 | string smdthtString[] = {"SMD", "THT"};
39 |
40 | int PacSmd[];
41 | int PacPad[];
42 | int SmdTht[];
43 | int SMD_THT = 2; // 2 = SMD & PAD
44 | enum { SMD, THT };
45 | int SmdThtSeparate = 1;
46 |
47 | int cnte = 0;
48 | int sele = -1;
49 | string SelPasser[];
50 | int SelM1 = -1;
51 |
52 | string EList[];
53 | int selCalculated = 0;
54 | int useMarker;
55 |
56 | int maxX = INT_MIN;
57 | int minX = INT_MAX;
58 | int maxY = INT_MIN;
59 | int minY = INT_MAX;
60 |
61 | real outlines = 0;
62 | string brdoutline;
63 | string brdmaximum = "max. Board length ?\n(layer 20 empty)";
64 |
65 | int index[];
66 |
67 |
68 | /****************** Functions ***********************/
69 | void header(string bname) {
70 | int t = time();
71 | // |Package_Value| MPN Attribute|
72 | // \______ ________/
73 | // \ /
74 | //printf(" \"NAME\" = ( \"DESCRIPTION\"%c\"\"%c%c%c x-cord%c y-cord%c rotation%c \"SIDE\")\n",
75 | // delimiter, delimiter, delimiter, delimiter, delimiter, delimiter, delimiter
76 | // );
77 | return;
78 | }
79 |
80 | real ArcLength(real ang1, real ang2, real radius) {
81 | return radius * 2 * PI / 360 * (ang2 - ang1);
82 | }
83 |
84 | void checkmaxmin(int x1, int x2, int y1, int y2, int width) {
85 | int w = 0;
86 | if (width) w = width/2;
87 | if (x1 > maxX) maxX = x1+w;
88 | if (x2 > maxX) maxX = x2+w;
89 | if (y1 > maxY) maxY = y1+w;
90 | if (y2 > maxY) maxY = y2+w;
91 | if (x1 < minX) minX = x1-w;
92 | if (x2 < minX) minX = x2-w;
93 | if (y1 < minY) minY = y1-w;
94 | if (y2 < minY) minY = y2-w;
95 | return;
96 | }
97 |
98 |
99 | void checkarc( int x1, int x2, int y1, int y2, int xc, int yc, real angle1, real angle2, real radius, int width) {
100 | checkmaxmin( x1, x2, y1, y2, width );
101 | if ( angle2 > angle1 + 270.0) {
102 | if ( angle1 < 90 ) checkmaxmin( x1 , xc - radius, yc + radius, yc - radius, width );
103 | else if( angle1 < 180 ) checkmaxmin( xc - radius, xc + radius, y1 , yc - radius, width );
104 | else if( angle1 < 270 ) checkmaxmin( x1 , xc + radius, yc - radius, yc + radius, width );
105 | else if( angle1 < 360 ) checkmaxmin( xc + radius, xc - radius, y1 , yc + radius, width );
106 | }
107 | else if( angle2 > angle1 + 180.0) {
108 | if ( angle1 < 90 ) checkmaxmin( x1 , xc - radius, yc + radius, y2 , width );
109 | else if( angle1 < 180 ) checkmaxmin( x1 , xc - radius, yc - radius, y2 , width );
110 | else if( angle1 < 270 ) checkmaxmin( x1 , xc + radius, yc - radius, y2 , width );
111 | else if( angle1 < 360 ) checkmaxmin( x1 , xc + radius, yc + radius, y2 , width );
112 | }
113 | else if( angle2 > angle1 + 90.0 ) {
114 | if ( angle1 < 90 ) checkmaxmin( x1 , x2 , yc + radius, y2 , width );
115 | else if( angle1 < 180 ) checkmaxmin( x1 , xc - radius, y1 , y2 , width );
116 | else if( angle1 < 270 ) checkmaxmin( x1 , x2 , yc - radius, y2 , width );
117 | else if( angle1 < 360 ) checkmaxmin( x1 , xc + radius, y1 , y2 , width );
118 | }
119 | return;
120 | }
121 |
122 |
123 | real WireLength(int x1, int x2, int y1, int y2) {
124 | return sqrt( pow(u2mm(x2) - u2mm(x1), 2) + pow(u2mm(y2) - u2mm(y1), 2));
125 | }
126 |
127 |
128 | real WireLengthCircle(int r) {
129 | return (u2mm(r) * 2 * PI) ;
130 | }
131 |
132 |
133 | string getAngle(string ang) {
134 | real angc = strtod(ang);
135 | int Result = dlgDialog("Angle") {
136 | dlgHBoxLayout {
137 | dlgLabel("Feeder offset ");
138 | dlgRealEdit(angc, -359.9, +359.9);
139 | dlgStretch(1);
140 | }
141 | dlgHBoxLayout {
142 | dlgStretch(1);
143 | dlgPushButton("+OK") dlgAccept();
144 | dlgPushButton("-Cancel") dlgReject();
145 | dlgStretch(1);
146 | }
147 | };
148 | if (!Result) return ang;
149 | sprintf(ang, "%.1f", angc);
150 | return ang;
151 | }
152 |
153 |
154 | /*** write back attribute value in to board ***/
155 | void exitfeederangle(string bname) { // write back changed feeder angle offset
156 | string scriptname = filesetext(bname, "~fao~.scr");
157 | string cmd, s;
158 | cmd = "CHANGE DISPLAY OFF;\n";
159 | for (int n = 0; n < cnte; n++) {
160 | sprintf(s, "ATTRIBUTE %s '%s' '%.1f';\n", EName[n], AttributeFeederAngleOffset, FeederAngleOffset[n]);
161 | cmd += s;
162 | }
163 | output(scriptname, "wtD") printf("%s", cmd);
164 | exit("SCRIPT '"+scriptname+"'");
165 | }
166 |
167 |
168 | void prn(int n, real x, real y, real partangle, int withTyp) {
169 | if (withTyp == 1)
170 | printf("%c%s%c%s%c%s%c%s%c%.4f%c%.4f%c%.1f%c%s%c%s\n",
171 | EName[index[n]],
172 | delimiter,
173 | EValue[index[n]],
174 | delimiter,
175 | tb[Em[index[n]]],
176 | delimiter,
177 | EPack[index[n]],
178 | delimiter,
179 | x,
180 | delimiter,
181 | y,
182 | delimiter,
183 | partangle,
184 | delimiter,
185 | smdthtString[SmdTht[index[n]]],
186 | delimiter,
187 | EAttr[index[n]]
188 |
189 |
190 |
191 | //FeederAngleOffset[index[n]],
192 | //SelPasser[index[n]]
193 | );
194 | else
195 | printf("%s%c%s%c%s%c%s%c%.4f%c%.4f%c%.1f%c%s%c%s\n",
196 | EName[index[n]],
197 | delimiter,
198 | EValue[index[n]],
199 | delimiter,
200 | tb[Em[index[n]]],
201 | delimiter,
202 | EPack[index[n]],
203 | delimiter,
204 | x,
205 | delimiter,
206 | y,
207 | delimiter,
208 | partangle,
209 | delimiter,
210 | smdthtString[SmdTht[index[n]]],
211 | delimiter,
212 | EAttr[index[n]]
213 | //FeederAngleOffset[index[n]],
214 | //SelPasser[index[n]]
215 | );
216 | return;
217 | }
218 |
219 | /**** main ****/
220 | if (board) board(B) {
221 | B.wires(W) {
222 | if (W.layer == 20) {
223 | if (W.arc) {
224 | outlines += ArcLength(W.arc.angle1, W.arc.angle2, W.arc.radius);
225 | checkarc(W.arc.x1, W.arc.x2, W.arc.y1, W.arc.y2, W.arc.xc, W.arc.yc, W.arc.angle1, W.arc.angle2, W.arc.radius, W.width);
226 | }
227 | else {
228 | outlines += WireLength(W.x1, W.x2, W.y1, W.y2);
229 | checkmaxmin( W.x1, W.x2, W.y1, W.y2, W.width );
230 | }
231 | }
232 | }
233 | B.circles(C) {
234 | if (C.layer == 20) {
235 | outlines += WireLengthCircle(C.radius);
236 | checkmaxmin( C.x - C.radius, C.x + C.radius, C.y - C.radius, C.y + C.radius, C.width );
237 | }
238 | }
239 | B.elements(E) {
240 | E.package.wires(W) {
241 | if (W.layer == 20) {
242 | // *** Dimension in Packages ***
243 | outlines += WireLength(W.x1, W.x2, W.y1, W.y2);
244 | checkmaxmin( W.x1, W.x2, W.y1, W.y2, W.width );
245 | }
246 | }
247 | E.package.circles(C) {
248 | if (C.layer == 20) {
249 | outlines += WireLengthCircle(C.radius);
250 | checkmaxmin( C.x - C.radius, C.x + C.radius, C.y - C.radius, C.y + C.radius, C.width );
251 | }
252 | }
253 | }
254 | if (outlines) {
255 | sprintf(brdoutline, "Outline contour = %.4f mm", outlines);
256 | sprintf(brdmaximum, "max. Board length (Layer 20)%cX = %.4f mm%cY = %.4f mm",
257 | delimiter, WireLength(minX, maxX, 0,0), delimiter, WireLength(minY, maxY, 0, 0)
258 | );
259 | }
260 |
261 | B.elements(E) {
262 | int xmax =-2147483648,
263 | xmin = 2147483647,
264 | ymax = xmax,
265 | ymin = xmin;
266 |
267 | E.package.contacts(C) {
268 | if (C.x > xmax) xmax = C.x;
269 | if (C.y > ymax) ymax = C.y;
270 | if (C.x < xmin) xmin = C.x;
271 | if (C.y < ymin) ymin = C.y;
272 | if (C.pad) PacPad[cnte]++;
273 | if (C.smd) PacSmd[cnte]++;
274 | }
275 |
276 | if (PacSmd[cnte] || PacPad[cnte]) { // if connect
277 | Ex[cnte] = u2mm((xmin + xmax)/2); // element coordinate calculated over smd/pad
278 | Ey[cnte] = u2mm((ymin + ymax)/2);
279 | }
280 | if (PacPad[cnte]) SmdTht[cnte] = THT;
281 | if (PacSmd[cnte]) SmdTht[cnte] = SMD; // if SMD THT mixed, then favorite SMD
282 |
283 | Eox[cnte] = u2mm(E.x); // element origin
284 | Eoy[cnte] = u2mm(E.y);
285 | Ea[cnte] = E.angle;
286 | EValue[cnte] = E.value;
287 | Em[cnte] = E.mirror;
288 | EName[cnte] = E.name;
289 | EPack[cnte] = E.package.name;
290 |
291 | if (E.attribute[AttributeFeederAngleOffset]) { // "FAO" feeder offset of part for mountig machine
292 | FeederAngleOffset[cnte] = strtod(E.attribute[AttributeFeederAngleOffset]);
293 | }
294 | else FeederAngleOffset[cnte] = 0.0;
295 |
296 | if (E.attribute[ExpAttrName]) {
297 | EAttr[cnte] = E.attribute[ExpAttrName];
298 | }
299 | else {
300 | EAttr[cnte] = "";
301 | }
302 |
303 | cnte++;
304 | }
305 |
306 | sort(cnte, index, Em, SmdTht, EValue, EPack, EAttr);
307 |
308 | for (int i = 0; i < cnte; i++) {
309 | //Partname, Value, Package, Position, Orientation, Angabe TOP bzw BOT,MPN
310 | sprintf(EList[i], "%s\t%s\t%s\t%.4f\t%.4f\t%.1f\t%s\t%s\t%s",
311 | EName[index[i]],
312 | EValue[index[i]],
313 | EPack[index[i]],
314 | Eox[index[i]],
315 | Eoy[index[i]],
316 | Ea[index[i]],
317 | tb[Em[index[i]]],
318 | smdthtString[SmdTht[index[i]]],
319 | EAttr[index[i]]
320 | //FeederAngleOffset[index[i]],
321 | //SelPasser[index[i]]
322 | );
323 | }
324 |
325 | int writeback = 0;
326 |
327 | int RESULT = dlgDialog("Mounting Data") {
328 | string t[];
329 | enum { M, A};
330 | int changemode = M;
331 | int srt = 0;
332 | dlgHBoxLayout dlgSpacing(500);
333 | dlgHBoxLayout {
334 | dlgVBoxLayout dlgSpacing(300);
335 | dlgVBoxLayout {
336 | dlgListView("Designator\tComment\tFootprint\tCenter-X(mm)\tCenter-Y(mm)\tRotation\tLayer\tSMD/THT\tManufacture Part Number 1", EList, sele, srt) {
337 | /*******************************************************
338 | strsplit(t, EList[sele], '\t');
339 | if (changemode == M) {
340 | if (SelPasser[sele] == "M") SelPasser[sele] = "";
341 | else {
342 | SelPasser[sele] = "M"; useMarker = 1;
343 | if (!SelM1) {
344 | SelM1 = sele+1;
345 | useMarker = sele+1;
346 | }
347 | }
348 | sprintf(EList[sele], "%s\t%s\t%s\t%s\t%s\t%s", t[0], t[1], t[2], t[3], t[4], SelPasser[sele]);
349 | }
350 | else if (changemode == A) {
351 | t[4] = getAngle(t[4]);
352 | sprintf(EList[sele], "%s\t%s\t%s\t%s\t%s\t%s", t[0], t[1], t[2], t[3], t[4], t[5]);
353 | FeederAngleOffset[sele] = strtod(t[4]);
354 | }
355 | *******************************************************/
356 | }
357 | }
358 | }
359 | /*******************************************************
360 | dlgHBoxLayout {
361 | dlgGroup("Change mode ") {
362 | dlgRadioButton("&Marker ", changemode);
363 | dlgHBoxLayout {
364 | dlgRadioButton("&Feeder angle ", changemode);
365 | dlgCheckBox("&Write feeder back in pcb ", writeback);
366 | }
367 | }
368 | }
369 | dlgGroup("Angle offset ") {
370 | dlgHBoxLayout {
371 | dlgLabel("Feeder/&Board ");
372 | dlgRealEdit(AngleLayoutFeeder);
373 | dlgStretch(1);
374 | }
375 | }
376 | *******************************************************/
377 | dlgHBoxLayout {
378 | dlgGroup("Export Packages ") {
379 | dlgRadioButton("only &SMD", SMD_THT);
380 | dlgRadioButton("only &PAD", SMD_THT);
381 | dlgHBoxLayout {
382 | dlgRadioButton("SMD &and PAD", SMD_THT);
383 | dlgCheckBox("SMD/THT in separate files", SmdThtSeparate);
384 | }
385 | }
386 | dlgGroup("Center") {
387 | dlgRadioButton("&Origin center", selCalculated);
388 | dlgRadioButton("&Calculated center (by PADs)", selCalculated);
389 | //dlgCheckBox("&Use marker package", useMarker);
390 | dlgStretch(1);
391 | }
392 | }
393 | dlgHBoxLayout {
394 | dlgPushButton("OK") {
395 | if (useMarker) {
396 | if (sele < 0) dlgMessageBox("First select e element (Marker)!", "OK");
397 | else dlgAccept();
398 | }
399 | else dlgAccept();
400 | }
401 | dlgPushButton("-CANCEL") dlgReject();
402 | dlgStretch(1);
403 | }
404 | };
405 | if (!RESULT) exit(-1);
406 |
407 | //string fileName = dlgFileSave("Save File", filesetext(B.name, ".mnt"), "*.mnt");
408 | string fileName = filesetext(B.name, ".mnt");
409 | string smdfilename = filesetext(B.name, "-smd.mnt");
410 | string thtfilename = filesetext(B.name, "-tht.mnt");
411 | if (SmdThtSeparate) {
412 | output(thtfilename, "wt"); // generate new file
413 | output(smdfilename, "wt");
414 | }
415 |
416 | if (fileName == "") exit(0);
417 | output(fileName) {
418 | int cnt = 0;
419 | int cntpad = 0;
420 | int cntsmd = 0;
421 | int cntmarkt = 0; // counter marker on top
422 | int cntmarkb = 0; // counter marker on bottom
423 | header(B.name);
424 | output(thtfilename, "at")printf("Designator,Comment,Layer,Footprint,Center-X(mm),Center-Y(mm),Rotation,SMD/THT,Manufacture Part Number 1\n");
425 | output(smdfilename, "at")printf("Designator,Comment,Layer,Footprint,Center-X(mm),Center-Y(mm),Rotation,SMD/THT,Manufacture Part Number 1\n");
426 | for (int n = 0; n < cnte; n++) {
427 | if (!SMD_THT && !PacPad[index[n]] || SMD_THT == 1 && !PacSmd[index[n]] || SMD_THT == 2) {
428 | if (PacPad[index[n]]) cntpad++;
429 | if (PacSmd[index[n]]) cntsmd++;
430 | cnt++;
431 |
432 | if (SelPasser[index[n]] == "M") { // select marker
433 | sprintf(EValue[index[n]], "MARKER");
434 | if (Em[index[n]]) {
435 | sprintf(EName[index[n]], "MARKER %d", ++cntmarkb);
436 | }
437 | else {
438 | sprintf(EName[index[n]], "MARKER %d", ++cntmarkt);
439 | }
440 | }
441 |
442 | //string pac_val_delim = "_";
443 | //if (!EValue[index[n]]) pac_val_delim = ""; // no delimiter if no value
444 |
445 | real x = Eox[index[n]]; // element origin
446 | real y = Eoy[index[n]];
447 |
448 | if (selCalculated) { // element origin calculated over smd/pad
449 | x = Ex[index[n]];
450 | y = Ey[index[n]];
451 | }
452 | real partangle = Ea[index[n]] + FeederAngleOffset[index[n]] + AngleLayoutFeeder;
453 | if (partangle > 360) partangle -= 360;
454 | if (partangle < -360) partangle += 360;
455 |
456 | if (SmdThtSeparate) {
457 | if (SmdTht[index[n]] == SMD) output(smdfilename, "at") prn(n, x ,y, partangle, 0);
458 | if (SmdTht[index[n]] == THT) output(thtfilename, "at") prn(n, x ,y, partangle, 0);
459 | }
460 | else {
461 | prn(n, x ,y, partangle, 1);
462 | }
463 | }
464 | }
465 | }
466 | // if (writeback) exitfeederangle(B.name);
467 | }
468 |
469 | else {
470 | dlgMessageBox("Start this ULP in a Board.");
471 | exit (0);
472 | }
473 |
--------------------------------------------------------------------------------
/meatbag.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | import csv
3 | import sys
4 | import argparse
5 |
6 | # a little footwork to abstract away python2/PySide
7 | # vs python3/PySide2 changes:
8 | # - try/except to attempt and make process transparent
9 | # - some import Foo as Bar to mask some differences
10 | # Only tested, to date, with python3 as that's what I
11 | # gotz.
12 | try:
13 | from PySide import QtGui, QtCore, QtWebKit
14 | from PySide import QtGui as Widgets
15 | from QtWebKit import QWebView as WebView
16 | from urllib import urlopen
17 | except Exception as py2Ex:
18 | try:
19 | from PySide2 import QtGui, QtCore, QtWidgets
20 | from PySide2 import QtWidgets as Widgets
21 | from PySide2.QtWebEngineWidgets import QWebEngineView as WebView
22 |
23 |
24 | from urllib.request import urlopen
25 | except Exception as py3Ex:
26 | print("Python2(?) Exceptions: %s" % str(py2Ex))
27 | print("Python3 Exceptions: %s" % str(py3Ex))
28 | raise py3Ex
29 |
30 |
31 | from sgmllib import SGMLParser
32 |
33 |
34 | class PCBPainter(Widgets.QDialog):
35 | def __init__(self, parent):
36 | super(PCBPainter, self).__init__(parent)
37 |
38 | self.imglabel = Widgets.QLabel()
39 |
40 | vb = Widgets.QVBoxLayout()
41 | vb.addWidget(self.imglabel)
42 |
43 | openpb = Widgets.QPushButton("Set PCB Image")
44 | openpb.clicked.connect(self.set_image)
45 |
46 | self.timerFocus = QtCore.QTimer()
47 | self.timerFocus.setSingleShot(True)
48 | self.timerFocus.timeout.connect(self.clearfocus)
49 |
50 | self.pcbwidth = Widgets.QDoubleSpinBox()
51 | self.pcbwidth.setMinimum(0)
52 | self.pcbwidth.setMaximum(100000)
53 | self.pcbwidth.valueChanged.connect(self.clearfocusdelay)
54 | self.pcbheight = Widgets.QDoubleSpinBox()
55 | self.pcbheight.setMinimum(0)
56 | self.pcbheight.setMaximum(100000)
57 | self.pcbheight.valueChanged.connect(self.clearfocusdelay)
58 | self.marker_diameter = 5
59 |
60 | buttongrid = Widgets.QHBoxLayout()
61 | buttongrid.addWidget(openpb)
62 | buttongrid.addSpacing(5)
63 | buttongrid.addWidget(Widgets.QLabel("PCB Width (units): "))
64 | buttongrid.addWidget(self.pcbwidth)
65 | buttongrid.addSpacing(5)
66 | buttongrid.addWidget(Widgets.QLabel("PCB Height (units):"))
67 | buttongrid.addWidget(self.pcbheight)
68 | buttongrid.addStretch(5)
69 |
70 | vb.addLayout(buttongrid)
71 |
72 | self.setLayout(vb)
73 |
74 | self.image_path = ""
75 |
76 | def marker_diameter_increment(self):
77 | self.marker_diameter += 10
78 | # used as key action callback, so return true to redraw
79 | return True
80 |
81 | def marker_diameter_decrement(self):
82 | if self.marker_diameter < 10:
83 | return False
84 |
85 | self.marker_diameter -= 10
86 | # used as key action callback, so return true to redraw
87 | return True
88 |
89 |
90 |
91 | def draw_marker(self, x, y, mirror=False):
92 | """Draw a placement marker"""
93 |
94 | boardwidth = self.pcbwidth.value()
95 | boardheight = self.pcbheight.value()
96 |
97 | try:
98 | scale_x = float(self.base.width()) / float(boardwidth)
99 | scale_y = float(self.base.height()) / float(boardheight)
100 | except ZeroDivisionError:
101 | Widgets.QMessageBox.warning("Division by Zero", "Division by zero - did you set board height & width in image?")
102 | raise
103 |
104 | x = x * scale_x
105 | y = y * scale_y
106 |
107 | #Y taken from wrong side normally
108 | y = self.base.height() - y
109 |
110 | if mirror:
111 | x = self.base.width() - x
112 |
113 | #print("Drawing marker at %d, %d" % (x,y))
114 | center = QtCore.QPoint(x, y)
115 |
116 | painter = QtGui.QPainter()
117 | painter.begin(self.base)
118 | painter.setBrush(QtCore.Qt.black)
119 | painter.setOpacity(0.45)
120 | painter.drawEllipse(QtCore.QPoint(x+(float(0.15*self.marker_diameter)), y+(float(0.15*self.marker_diameter))), self.marker_diameter, self.marker_diameter)
121 | painter.end()
122 |
123 | painter.begin(self.base)
124 | painter.setBrush(QtCore.Qt.red)
125 | painter.setOpacity(0.95)
126 | painter.drawEllipse(center, self.marker_diameter, self.marker_diameter)
127 | painter.end()
128 |
129 | def xy_to_draw(self, x, y, mirror):
130 |
131 | self.reload_base()
132 |
133 | self.draw_marker(x, y, mirror)
134 |
135 | self.redraw()
136 |
137 |
138 | def reload_base(self):
139 | self.base = QtGui.QImage(self.image_path)
140 |
141 | def redraw(self):
142 | self.imglabel.setPixmap(QtGui.QPixmap.fromImage(self.base))
143 |
144 | def configure_pcb_dimensions(self, height, width):
145 | self.pcbwidth.setValue(width)
146 | self.pcbheight.setValue(height)
147 |
148 | def image_selected(self, filename):
149 | if filename:
150 | self.image_path = filename
151 | self.reload_base()
152 | self.redraw()
153 |
154 | def set_image(self):
155 | filename, filter = Widgets.QFileDialog.getOpenFileName(parent=self, caption='Select PCB Image', dir='.',
156 | filter='PCB Image (*.png)')
157 |
158 | self.image_selected(filename)
159 |
160 | def clearfocusdelay(self):
161 | """After 5 seconds clear focus, used to avoid accidently writing stuff here with scan gun"""
162 | self.timerFocus.start(5000)
163 |
164 | def clearfocus(self):
165 | self.pcbwidth.clearFocus()
166 | self.pcbheight.clearFocus()
167 |
168 |
169 | class MeatBagCSVSettings(object):
170 | def __init__(self):
171 | self.col_layer = 0
172 | self.col_x = 0
173 | self.col_y = 0
174 | self.col_pn = 0
175 | self.col_des = 0
176 | self.col_com = 0
177 |
178 | #Starting data row (row=0 is often header)
179 | self.row_start = 0
180 |
181 |
182 | class MeatBagCSVSettingsAltium(MeatBagCSVSettings):
183 | def __init__(self):
184 | super(MeatBagCSVSettingsAltium, self).__init__()
185 | self.col_layer = 2
186 | self.col_x = 4
187 | self.col_y = 5
188 | self.col_pn = 8
189 | self.col_des = 0
190 | self.col_com = 1
191 |
192 | #Starting data row (row=0 is often header)
193 | self.row_start = 1
194 |
195 |
196 | class MeatBagCSVSettingsKicadSingleLayer(MeatBagCSVSettings):
197 | def __init__(self):
198 | super(MeatBagCSVSettings, self).__init__()
199 | #Default kicad .pos file layout: Ref,Val,Package,PosX,PosY,Rot,Side,
200 | # e.g. "C1","100n","C_0805_2012Metric",94.500000,-65.500000,90.000000,top
201 |
202 | self.col_layer = -1
203 | self.col_x = 3
204 | self.col_y = 4
205 | self.col_pn = 1
206 | self.col_des = 0
207 | self.col_com = 1
208 |
209 | #Starting data row (row=0 is often header)
210 | self.row_start = 1
211 |
212 | class MeatBagCSVSettingsKicadMultiLayer(MeatBagCSVSettingsKicadSingleLayer):
213 | def __init__(self):
214 | super(MeatBagCSVSettingsKicadMultiLayer, self).__init__()
215 | #Default kicad .pos file layout: Ref,Val,Package,PosX,PosY,Rot,Side
216 | self.col_layer = 6
217 |
218 |
219 | class KeyAction(object):
220 | """ action associated with a key """
221 | def __init__(self, key, callback):
222 | self.key = key.lower()
223 | self.cb = callback
224 | def matches(self, txt):
225 | if txt is None:
226 | return False
227 | if self.key == txt.lower():
228 | return True
229 | return False
230 |
231 | def trigger(self):
232 | return self.cb()
233 |
234 |
235 | class MeatBagWindow(Widgets.QMainWindow):
236 |
237 | def __init__(self, csvSettings, parsedArgs):
238 | super(MeatBagWindow, self).__init__()
239 | self.setWindowTitle("Meat Bag Pick-n-Place v0.0000000003")
240 |
241 | self.efilter = filterObj(self)
242 | self.installEventFilter(self.efilter)
243 |
244 | self.initLayout()
245 | self.initMenus()
246 | if csvSettings:
247 | self.csv_settings = csvSettings;
248 | else:
249 | self.csv_settings = MeatBagCSVSettingsAltium()
250 |
251 | self.getSettings()
252 | self.show()
253 |
254 | self.webView = WebView()
255 | self.webView.loadFinished.connect(self.lookupdone)
256 |
257 | self.last_keys = ""
258 | self.timerScan = QtCore.QTimer()
259 | self.timerScan.setSingleShot(True)
260 | self.timerScan.timeout.connect(self.timesUp)
261 |
262 | self.timerScanLineEdit = QtCore.QTimer()
263 | self.timerScanLineEdit.setSingleShot(True)
264 | self.timerScanLineEdit.timeout.connect(self.scanline_changed_dly)
265 |
266 | self.build_side = 0
267 |
268 | self.cur_placement = None
269 | self.drawing_all_same_value = False
270 | if parsedArgs is None:
271 | return
272 | # handle cmd line args
273 | if parsedArgs.image:
274 | self.pcbpainter.image_selected(parsedArgs.image)
275 |
276 | if parsedArgs.width and parsedArgs.height:
277 | self.pcbpainter.configure_pcb_dimensions(parsedArgs.height, parsedArgs.width)
278 |
279 | if parsedArgs.csv:
280 | self.parseCSVFile(parsedArgs.csv)
281 |
282 | def getSettings(self):
283 | """Configure settings. Eventually ask user, for now configure in source."""
284 | pass
285 |
286 |
287 | def initLayout(self):
288 | mainLayout = Widgets.QVBoxLayout()
289 |
290 | ###Main parts table
291 | self.table = Widgets.QTableWidget()
292 | self.table.horizontalHeader().setStretchLastSection(True)
293 | self.table.installEventFilter(self.efilter)
294 | self.table.cellClicked.connect(self.table_cellClicked)
295 |
296 | ###Build Configuration
297 | gbBuildSetup = Widgets.QGroupBox()
298 | gbBuildSetup.setTitle("Build Settings")
299 | buildLayout = Widgets.QGridLayout()
300 |
301 | #Top/Bottom Selection
302 | cbSide = Widgets.QComboBox()
303 | cbSide.addItem("Top")
304 | cbSide.addItem("Bottom")
305 | cbSide.activated.connect(self.sideSelectionChanged)
306 | cbSide.installEventFilter(self.efilter)
307 |
308 | buildLayout.addWidget(cbSide, 0, 0)
309 | gbBuildSetup.setLayout(buildLayout)
310 |
311 |
312 | ###Part Display
313 | gbPart = Widgets.QGroupBox()
314 | gbPart.setTitle("Part Info")
315 |
316 | self.topDes = Widgets.QLineEdit()
317 | self.topDes.setReadOnly(True)
318 | self.botDes = Widgets.QLineEdit()
319 | self.botDes.setReadOnly(True)
320 |
321 | partLayout = Widgets.QGridLayout()
322 |
323 | label_cur = Widgets.QLabel("Current Placement:")
324 | f = label_cur.font()
325 | f.setPointSize(12)
326 | label_cur.setFont(f)
327 | partLayout.addWidget(label_cur, 0, 0)
328 |
329 | self.place = Widgets.QLineEdit()
330 | f = self.place.font()
331 | f.setPointSize(12)
332 | self.place.setFont(f)
333 | self.place.setReadOnly(True)
334 | partLayout.addWidget(self.place, 0, 1)
335 |
336 | partLayout.addWidget(Widgets.QLabel("Top-Side Designators:"), 2, 0)
337 | partLayout.addWidget(Widgets.QLabel("Bot-Side Designators:"), 3, 0)
338 | partLayout.addWidget(self.topDes, 2, 1)
339 | partLayout.addWidget(self.botDes, 3, 1)
340 |
341 | gbPart.setLayout(partLayout)
342 |
343 | ### Debug Stuff
344 |
345 | gbDebug = Widgets.QGroupBox()
346 | gbDebug.setTitle("Part Number Info")
347 |
348 | self.scanLine = Widgets.QPlainTextEdit()
349 | self.scanLine.setFixedHeight(40)
350 | self.scanLine.setSizePolicy(Widgets.QSizePolicy.Minimum, Widgets.QSizePolicy.Minimum)
351 | self.scanLine.textChanged.connect(self.scanline_changed)
352 |
353 | debugLayout = Widgets.QHBoxLayout()
354 | debugLayout.addWidget(Widgets.QLabel("Scan Output (or paste P/N here):"))
355 | debugLayout.addWidget(self.scanLine)
356 |
357 | gbDebug.setLayout(debugLayout)
358 |
359 | ### Rest of Stuff
360 | window = Widgets.QWidget()
361 | window.setLayout(mainLayout)
362 |
363 | self.pcbpainter = PCBPainter(window)
364 | self.pcbpainter.show()
365 | self.pcbpainter.installEventFilter(self.efilter)
366 |
367 | mainLayout.addWidget(self.table)
368 | mainLayout.addWidget(gbBuildSetup)
369 | mainLayout.addWidget(gbPart)
370 | mainLayout.addWidget(gbDebug)
371 |
372 | self.setCentralWidget(window)
373 |
374 | def initMenus(self):
375 | self.openAct = Widgets.QAction("&Open...", self,
376 | shortcut=QtGui.QKeySequence.Open,
377 | statusTip="Open an existing file", triggered=self.openFile)
378 |
379 | self.fileMenu = self.menuBar().addMenu("&File")
380 | self.fileMenu.addAction(self.openAct)
381 |
382 | def isTopLayer(self, row):
383 | """Check if a given row (0-based index) is top-side or bottom-side part"""
384 | if self.csv_settings.col_layer < 0:
385 | return True
386 |
387 | tb = self.table.item(row, self.csv_settings.col_layer).text()
388 |
389 | if tb.lower().startswith("top"):
390 | return True
391 | elif tb.lower().startswith("bot"):
392 | return False
393 | else:
394 | raise ValueError("Unknown layer for row %d: '%s' in col %d" % (row, tb.lower(), self.csv_settings.col_layer))
395 |
396 | def sideSelectionChanged(self, indx):
397 | """User changed build side"""
398 | self.build_side = indx
399 | self.recolourTable()
400 |
401 | def table_cellClicked(self, row, col):
402 | """User click on a cell"""
403 |
404 | pn = self.table.item(row, self.csv_settings.col_pn).text()
405 | com = self.table.item(row, self.csv_settings.col_com).text()
406 |
407 | if pn is None or pn == "":
408 | #raise ValueError("Null PN for row - matching with Comment")
409 | self.process_new_com(com)
410 | else:
411 | self.process_new_pn(pn)
412 |
413 |
414 | def openFile(self):
415 | """Open new CSV PnP file"""
416 |
417 | filename, filter = Widgets.QFileDialog.getOpenFileName(parent=self, caption='Select PnP file', dir='.', filter='CSV files (*.csv *.mnt)')
418 |
419 | if not filename:
420 | return
421 |
422 | return self.parseCSVFile(filename)
423 |
424 | def parseCSVFile(self, filename):
425 | ppdata = []
426 |
427 | with open(filename, "r") as csvfile:
428 | ppfile = csv.reader(csvfile, delimiter=',', quotechar='"')
429 | for row in ppfile:
430 | if len(row) < 4:
431 | print("Skipped line: " + ' '.join(row))
432 | else:
433 | ppdata.append(row)
434 |
435 | self.table.clear()
436 | numRows = len(ppdata)
437 | numCols = len(ppdata[0]) + 1
438 | self.table.setRowCount(numRows)
439 | self.table.setColumnCount(numCols)
440 | for r in range(0, numRows):
441 | for c in range(0, numCols - 1):
442 | try:
443 | self.table.setItem(r, c, Widgets.QTableWidgetItem(ppdata[r][c]))
444 | except IndexError:
445 | self.table.setItem(r, c, Widgets.QTableWidgetItem("???"))
446 |
447 | checkitem = Widgets.QTableWidgetItem()
448 | checkitem.setCheckState(QtCore.Qt.Unchecked)
449 | self.table.setItem(r, numCols-1, checkitem)
450 |
451 | self.recolourTable()
452 |
453 | #Rebuild local database of part numbers to speed up search
454 | self.pdb = []
455 | for r in range(0, numRows):
456 | self.pdb.append(ppdata[r][self.csv_settings.col_pn])
457 |
458 | self.pdc = []
459 | for r in range(0, numRows):
460 | self.pdc.append(ppdata[r][self.csv_settings.col_com])
461 |
462 |
463 | def recolourTable(self):
464 | """Redo the table colour stuff"""
465 | rowcnt = self.table.rowCount()
466 | colcnt = self.table.columnCount()
467 |
468 | for r in range(self.csv_settings.row_start, rowcnt):
469 | try:
470 | placed = self.table.item(r, colcnt-1).checkState() == QtCore.Qt.Checked
471 | if placed:
472 | alpha = 5
473 | else:
474 | alpha = 120
475 | if self.isTopLayer(r):
476 | bgc = QtGui.QColor(255, 0, 0, alpha)
477 | else:
478 | bgc = QtGui.QColor(0, 0, 255, alpha)
479 | except ValueError:
480 | bgc = QtCore.Qt.lightGray
481 |
482 | for c in range(0, colcnt):
483 |
484 | self.table.item(r, c).setBackground(bgc)
485 |
486 | def key_pressed(self, key):
487 | self.last_keys += key
488 | self.timerScan.start(100)
489 |
490 | def timesUp(self, _=None):
491 | """A timer is used to detect end of scan (so no newline on scanner is assumed)"""
492 |
493 | scan = self.last_keys
494 | self.last_keys = ""
495 |
496 | if scan == " ":
497 | #User is moving between items
498 | last_place = self.cur_placement
499 |
500 | try:
501 | self.table.item(last_place, self.table.columnCount()-1).setCheckState(QtCore.Qt.Checked)
502 | except TypeError:
503 | pass
504 |
505 | self.find_next_placement()
506 | self.recolourTable()
507 | return
508 |
509 |
510 | #Remove line endings etc
511 | scan = scan.strip()
512 |
513 | #This triggers scan stuff
514 | self.scanLine.setPlainText(scan)
515 |
516 | def process_keystroke(self, txt):
517 | action_map = [
518 | KeyAction('+', self.pcbpainter.marker_diameter_increment),
519 | KeyAction('-', self.pcbpainter.marker_diameter_decrement),
520 | KeyAction('a', self.toggle_draw_all_of_current_value)
521 | ]
522 | refresh_placement = False
523 | for k in action_map:
524 | if k.matches(txt):
525 | #print("Have match")
526 | if k.trigger():
527 | #print("Should refresh")
528 | refresh_placement = True
529 |
530 | if refresh_placement:
531 | self.update_placement()
532 |
533 | def process_new_scan(self, scan):
534 | """Process a new barcode scan, convert to manufacture PN"""
535 | if len(scan) < 5:
536 | self.process_keystroke(scan)
537 | return
538 |
539 | self.topDes.setText("")
540 | self.botDes.setText("")
541 |
542 | #Check if we match already
543 | self.process_new_pn(scan, update_placement=False)
544 |
545 | if len(self.topDesList) > 0 or len(self.botDesList) > 0:
546 | self.find_next_placement()
547 | return
548 |
549 | #Failed - try web lookup
550 |
551 | if scan[0] == '[' and scan[1] == ')':
552 | # DIGIKEY
553 | if len(scan) > 30:
554 | pn_start = scan.split('1P')[1]
555 | pn = pn_start.split('K1K5')[0]
556 | self.process_new_pn(pn)
557 | else:
558 | internal_pn = scan[0:7]
559 | qty = int(scan[10:16])
560 |
561 | print("Old-style barcode, attempting lookup")
562 | sock = urlopen(
563 | 'https://www.digikey.com/product-detail/en/keystone-electronics/4245C/36-4245C-ND/' + internal_pn)
564 | data = sock.read()
565 | raise NotImplementedError("Old-style barcode not implemented")
566 |
567 | #TODO: If you need to fix this, hack around following code to get actual PN not supplier one
568 | # data = data.split(" ")
569 | digikey_pn = data.split('content="sku:')[1].split("-ND")[0] + "-ND"
570 | # print "%s: %d"%(digikey_pn, qty)
571 | else:
572 | # MOUSER???
573 | print("Maybe Mouser? Trying lookup - WAITING FOR WEBPAGE NOW")
574 | #Use webview as need JS
575 | self.webView.load(QtCore.QUrl('https://ca.mouser.com/search/ProductDetail.aspx?R=' + scan))
576 |
577 | def lookupdone(self, _=None):
578 | """Called when website loaded"""
579 | html = self.webView.page().mainFrame().toHtml()
580 |
581 | #Decode website type - try mouser first
582 | try:
583 | pn = html.split('
')[1].split("
")[0]
584 | pn = pn.split('')[1].split('
')[0]
585 | print ("Found PN: " + pn)
586 | self.process_new_pn(pn)
587 | except IndexError:
588 | print ("Failed to find PN in returned site.")
589 |
590 | def process_new_com(self, com, update_placement=True):
591 | """Given a Comment, find all likely matches"""
592 | matchlist = []
593 |
594 | #Shitty match for shitty programs
595 |
596 |
597 | for i in range(0, len(self.pdc)):
598 | #print "checking"
599 | if (len(self.pdc[i]) > 3 and self.pdc[i] in com) or com in self.pdc[i]:
600 | matchlist.append(i)
601 | #print matchlist
602 |
603 | self.topDesList = []
604 | self.botDesList = []
605 | topDesStr = ""
606 | botDesStr = ""
607 |
608 | for r in matchlist:
609 | if self.isTopLayer(r):
610 | self.topDesList.append(r)
611 | topDesStr += self.table.item(r, self.csv_settings.col_des).text() + ", "
612 | else:
613 | self.botDesList.append(r)
614 | botDesStr += self.table.item(r, self.csv_settings.col_des).text() + ", "
615 |
616 | self.topDes.setText(topDesStr)
617 | self.botDes.setText(botDesStr)
618 |
619 | if update_placement:
620 | self.find_next_placement()
621 |
622 |
623 | def process_new_pn(self, pn, update_placement=True):
624 | """Given a manufactures PN, find all likely matches"""
625 | matchlist = []
626 |
627 | #Shitty match for shitty programs
628 | for i in range(0, len(self.pdb)):
629 | if (len(self.pdb[i]) > 4 and self.pdb[i] in pn) or pn in self.pdb[i]:
630 | matchlist.append(i)
631 |
632 | self.topDesList = []
633 | self.botDesList = []
634 | topDesStr = ""
635 | botDesStr = ""
636 |
637 | for r in matchlist:
638 | if self.isTopLayer(r):
639 | self.topDesList.append(r)
640 | topDesStr += self.table.item(r, self.csv_settings.col_des).text() + ", "
641 | else:
642 | self.botDesList.append(r)
643 | botDesStr += self.table.item(r, self.csv_settings.col_des).text() + ", "
644 |
645 | self.topDes.setText(topDesStr)
646 | self.botDes.setText(botDesStr)
647 |
648 | if update_placement:
649 | self.find_next_placement()
650 |
651 | def toggle_draw_all_of_current_value(self):
652 | #print("draw_all_of_current_value")
653 | if self.cur_placement is None or not self.cur_placement:
654 | print("NO CUR PLACEMENT")
655 | return False
656 |
657 | if self.drawing_all_same_value:
658 | self.drawing_all_same_value = False
659 | self.update_placement()
660 | return
661 |
662 | if self.build_side == 0:
663 | parts = self.topDesList
664 | else:
665 | parts = self.botDesList
666 | cur_part_num_txt = self.table.item(self.cur_placement, self.csv_settings.col_pn).text()
667 | matchingPartsPos = []
668 | for p in parts:
669 | if p != self.cur_placement and self.table.item(p, self.csv_settings.col_pn).text() == cur_part_num_txt:
670 | matchingPartsPos.append([float(self.table.item(p, self.csv_settings.col_x).text()),
671 | float(self.table.item(p, self.csv_settings.col_y).text())])
672 |
673 | if not len(matchingPartsPos):
674 | print("No matching parts")
675 | return False
676 | self.update_placement()
677 | for pos in matchingPartsPos:
678 | self.pcbpainter.draw_marker(pos[0], pos[1])
679 |
680 |
681 | self.drawing_all_same_value = True
682 | self.pcbpainter.redraw()
683 | return False
684 |
685 |
686 | def find_next_placement(self):
687 | """Check the list for unplaced part on active layer"""
688 | self.cur_placement = None
689 |
690 | if self.build_side == 0:
691 | parts = self.topDesList
692 | else:
693 | parts = self.botDesList
694 |
695 | last_col = self.table.columnCount() - 1
696 |
697 | for p in parts:
698 | if self.table.item(p, last_col).checkState() == QtCore.Qt.Unchecked:
699 | #Next placement is 'p'
700 | self.cur_placement = p
701 | self.table.scrollToItem(self.table.item(p, 0))
702 | break
703 |
704 | self.update_placement()
705 |
706 | def update_placement(self):
707 | """Using variable self.cur_placement, update display to show location, name, etc."""
708 | self.drawing_all_same_value = False
709 | if self.cur_placement is not None:
710 | self.place.setText(self.table.item(self.cur_placement, self.csv_settings.col_des).text())
711 |
712 | self.pcbpainter.xy_to_draw(float(self.table.item(self.cur_placement, self.csv_settings.col_x).text()),
713 | float(self.table.item(self.cur_placement, self.csv_settings.col_y).text()),
714 | self.isTopLayer(self.cur_placement) == False)
715 |
716 | else:
717 | if len(self.topDesList) == 0 and len(self.botDesList) == 0:
718 | self.place.setText("Not Found")
719 | else:
720 | self.place.setText("Done")
721 |
722 |
723 | def scanline_changed(self):
724 | self.timerScanLineEdit.start(100)
725 |
726 | def scanline_changed_dly(self):
727 | self.process_new_scan(self.scanLine.toPlainText())
728 | self.scanLine.clearFocus()
729 |
730 |
731 |
732 | class filterObj(QtCore.QObject):
733 | def __init__(self, windowObj):
734 | QtCore.QObject.__init__(self)
735 | self.windowObj = windowObj
736 |
737 | def eventFilter(self, obj, event):
738 | if (event.type() == QtCore.QEvent.KeyPress):
739 | key = event.text()
740 |
741 | self.windowObj.key_pressed(key)
742 | return True
743 | else:
744 | return False
745 |
746 |
747 |
748 |
749 | def main():
750 | parser = argparse.ArgumentParser(description='MeatBagPnP')
751 | parser.add_argument('--csv', dest='csv', help='CSV file to use')
752 | parser.add_argument('--format', dest='format', default='altium', help='CSV file format (altium|kicad|eagle)')
753 | parser.add_argument('--width', type=float, default=0.0, help='PCB width')
754 | parser.add_argument('--height', type=float, default=0.0, help='PCB height')
755 | parser.add_argument('--image')
756 | args = parser.parse_args()
757 | csvSettingsAvailable = dict(
758 | altium = MeatBagCSVSettingsAltium(),
759 | eagle = MeatBagCSVSettingsAltium(), # same as altium for now
760 | kicad = MeatBagCSVSettingsKicadMultiLayer(),
761 | default = MeatBagCSVSettingsAltium()
762 | )
763 | csvSettings = csvSettingsAvailable['default']
764 | if args.format and args.format in csvSettingsAvailable:
765 | csvSettings = csvSettingsAvailable[args.format]
766 | else:
767 | print("Using default CSV format")
768 |
769 | app = Widgets.QApplication(sys.argv)
770 | ex = MeatBagWindow(csvSettings, args)
771 | app.exec_()
772 |
773 |
774 | if __name__ == '__main__':
775 | main()
776 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 3, 29 June 2007
3 |
4 | Copyright (C) 2007 Free Software Foundation, Inc.
5 | Everyone is permitted to copy and distribute verbatim copies
6 | of this license document, but changing it is not allowed.
7 |
8 | Preamble
9 |
10 | The GNU General Public License is a free, copyleft license for
11 | software and other kinds of works.
12 |
13 | The licenses for most software and other practical works are designed
14 | to take away your freedom to share and change the works. By contrast,
15 | the GNU General Public License is intended to guarantee your freedom to
16 | share and change all versions of a program--to make sure it remains free
17 | software for all its users. We, the Free Software Foundation, use the
18 | GNU General Public License for most of our software; it applies also to
19 | any other work released this way by its authors. You can apply it to
20 | your programs, too.
21 |
22 | When we speak of free software, we are referring to freedom, not
23 | price. Our General Public Licenses are designed to make sure that you
24 | have the freedom to distribute copies of free software (and charge for
25 | them if you wish), that you receive source code or can get it if you
26 | want it, that you can change the software or use pieces of it in new
27 | free programs, and that you know you can do these things.
28 |
29 | To protect your rights, we need to prevent others from denying you
30 | these rights or asking you to surrender the rights. Therefore, you have
31 | certain responsibilities if you distribute copies of the software, or if
32 | you modify it: responsibilities to respect the freedom of others.
33 |
34 | For example, if you distribute copies of such a program, whether
35 | gratis or for a fee, you must pass on to the recipients the same
36 | freedoms that you received. You must make sure that they, too, receive
37 | or can get the source code. And you must show them these terms so they
38 | know their rights.
39 |
40 | Developers that use the GNU GPL protect your rights with two steps:
41 | (1) assert copyright on the software, and (2) offer you this License
42 | giving you legal permission to copy, distribute and/or modify it.
43 |
44 | For the developers' and authors' protection, the GPL clearly explains
45 | that there is no warranty for this free software. For both users' and
46 | authors' sake, the GPL requires that modified versions be marked as
47 | changed, so that their problems will not be attributed erroneously to
48 | authors of previous versions.
49 |
50 | Some devices are designed to deny users access to install or run
51 | modified versions of the software inside them, although the manufacturer
52 | can do so. This is fundamentally incompatible with the aim of
53 | protecting users' freedom to change the software. The systematic
54 | pattern of such abuse occurs in the area of products for individuals to
55 | use, which is precisely where it is most unacceptable. Therefore, we
56 | have designed this version of the GPL to prohibit the practice for those
57 | products. If such problems arise substantially in other domains, we
58 | stand ready to extend this provision to those domains in future versions
59 | of the GPL, as needed to protect the freedom of users.
60 |
61 | Finally, every program is threatened constantly by software patents.
62 | States should not allow patents to restrict development and use of
63 | software on general-purpose computers, but in those that do, we wish to
64 | avoid the special danger that patents applied to a free program could
65 | make it effectively proprietary. To prevent this, the GPL assures that
66 | patents cannot be used to render the program non-free.
67 |
68 | The precise terms and conditions for copying, distribution and
69 | modification follow.
70 |
71 | TERMS AND CONDITIONS
72 |
73 | 0. Definitions.
74 |
75 | "This License" refers to version 3 of the GNU General Public License.
76 |
77 | "Copyright" also means copyright-like laws that apply to other kinds of
78 | works, such as semiconductor masks.
79 |
80 | "The Program" refers to any copyrightable work licensed under this
81 | License. Each licensee is addressed as "you". "Licensees" and
82 | "recipients" may be individuals or organizations.
83 |
84 | To "modify" a work means to copy from or adapt all or part of the work
85 | in a fashion requiring copyright permission, other than the making of an
86 | exact copy. The resulting work is called a "modified version" of the
87 | earlier work or a work "based on" the earlier work.
88 |
89 | A "covered work" means either the unmodified Program or a work based
90 | on the Program.
91 |
92 | To "propagate" a work means to do anything with it that, without
93 | permission, would make you directly or secondarily liable for
94 | infringement under applicable copyright law, except executing it on a
95 | computer or modifying a private copy. Propagation includes copying,
96 | distribution (with or without modification), making available to the
97 | public, and in some countries other activities as well.
98 |
99 | To "convey" a work means any kind of propagation that enables other
100 | parties to make or receive copies. Mere interaction with a user through
101 | a computer network, with no transfer of a copy, is not conveying.
102 |
103 | An interactive user interface displays "Appropriate Legal Notices"
104 | to the extent that it includes a convenient and prominently visible
105 | feature that (1) displays an appropriate copyright notice, and (2)
106 | tells the user that there is no warranty for the work (except to the
107 | extent that warranties are provided), that licensees may convey the
108 | work under this License, and how to view a copy of this License. If
109 | the interface presents a list of user commands or options, such as a
110 | menu, a prominent item in the list meets this criterion.
111 |
112 | 1. Source Code.
113 |
114 | The "source code" for a work means the preferred form of the work
115 | for making modifications to it. "Object code" means any non-source
116 | form of a work.
117 |
118 | A "Standard Interface" means an interface that either is an official
119 | standard defined by a recognized standards body, or, in the case of
120 | interfaces specified for a particular programming language, one that
121 | is widely used among developers working in that language.
122 |
123 | The "System Libraries" of an executable work include anything, other
124 | than the work as a whole, that (a) is included in the normal form of
125 | packaging a Major Component, but which is not part of that Major
126 | Component, and (b) serves only to enable use of the work with that
127 | Major Component, or to implement a Standard Interface for which an
128 | implementation is available to the public in source code form. A
129 | "Major Component", in this context, means a major essential component
130 | (kernel, window system, and so on) of the specific operating system
131 | (if any) on which the executable work runs, or a compiler used to
132 | produce the work, or an object code interpreter used to run it.
133 |
134 | The "Corresponding Source" for a work in object code form means all
135 | the source code needed to generate, install, and (for an executable
136 | work) run the object code and to modify the work, including scripts to
137 | control those activities. However, it does not include the work's
138 | System Libraries, or general-purpose tools or generally available free
139 | programs which are used unmodified in performing those activities but
140 | which are not part of the work. For example, Corresponding Source
141 | includes interface definition files associated with source files for
142 | the work, and the source code for shared libraries and dynamically
143 | linked subprograms that the work is specifically designed to require,
144 | such as by intimate data communication or control flow between those
145 | subprograms and other parts of the work.
146 |
147 | The Corresponding Source need not include anything that users
148 | can regenerate automatically from other parts of the Corresponding
149 | Source.
150 |
151 | The Corresponding Source for a work in source code form is that
152 | same work.
153 |
154 | 2. Basic Permissions.
155 |
156 | All rights granted under this License are granted for the term of
157 | copyright on the Program, and are irrevocable provided the stated
158 | conditions are met. This License explicitly affirms your unlimited
159 | permission to run the unmodified Program. The output from running a
160 | covered work is covered by this License only if the output, given its
161 | content, constitutes a covered work. This License acknowledges your
162 | rights of fair use or other equivalent, as provided by copyright law.
163 |
164 | You may make, run and propagate covered works that you do not
165 | convey, without conditions so long as your license otherwise remains
166 | in force. You may convey covered works to others for the sole purpose
167 | of having them make modifications exclusively for you, or provide you
168 | with facilities for running those works, provided that you comply with
169 | the terms of this License in conveying all material for which you do
170 | not control copyright. Those thus making or running the covered works
171 | for you must do so exclusively on your behalf, under your direction
172 | and control, on terms that prohibit them from making any copies of
173 | your copyrighted material outside their relationship with you.
174 |
175 | Conveying under any other circumstances is permitted solely under
176 | the conditions stated below. Sublicensing is not allowed; section 10
177 | makes it unnecessary.
178 |
179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
180 |
181 | No covered work shall be deemed part of an effective technological
182 | measure under any applicable law fulfilling obligations under article
183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or
184 | similar laws prohibiting or restricting circumvention of such
185 | measures.
186 |
187 | When you convey a covered work, you waive any legal power to forbid
188 | circumvention of technological measures to the extent such circumvention
189 | is effected by exercising rights under this License with respect to
190 | the covered work, and you disclaim any intention to limit operation or
191 | modification of the work as a means of enforcing, against the work's
192 | users, your or third parties' legal rights to forbid circumvention of
193 | technological measures.
194 |
195 | 4. Conveying Verbatim Copies.
196 |
197 | You may convey verbatim copies of the Program's source code as you
198 | receive it, in any medium, provided that you conspicuously and
199 | appropriately publish on each copy an appropriate copyright notice;
200 | keep intact all notices stating that this License and any
201 | non-permissive terms added in accord with section 7 apply to the code;
202 | keep intact all notices of the absence of any warranty; and give all
203 | recipients a copy of this License along with the Program.
204 |
205 | You may charge any price or no price for each copy that you convey,
206 | and you may offer support or warranty protection for a fee.
207 |
208 | 5. Conveying Modified Source Versions.
209 |
210 | You may convey a work based on the Program, or the modifications to
211 | produce it from the Program, in the form of source code under the
212 | terms of section 4, provided that you also meet all of these conditions:
213 |
214 | a) The work must carry prominent notices stating that you modified
215 | it, and giving a relevant date.
216 |
217 | b) The work must carry prominent notices stating that it is
218 | released under this License and any conditions added under section
219 | 7. This requirement modifies the requirement in section 4 to
220 | "keep intact all notices".
221 |
222 | c) You must license the entire work, as a whole, under this
223 | License to anyone who comes into possession of a copy. This
224 | License will therefore apply, along with any applicable section 7
225 | additional terms, to the whole of the work, and all its parts,
226 | regardless of how they are packaged. This License gives no
227 | permission to license the work in any other way, but it does not
228 | invalidate such permission if you have separately received it.
229 |
230 | d) If the work has interactive user interfaces, each must display
231 | Appropriate Legal Notices; however, if the Program has interactive
232 | interfaces that do not display Appropriate Legal Notices, your
233 | work need not make them do so.
234 |
235 | A compilation of a covered work with other separate and independent
236 | works, which are not by their nature extensions of the covered work,
237 | and which are not combined with it such as to form a larger program,
238 | in or on a volume of a storage or distribution medium, is called an
239 | "aggregate" if the compilation and its resulting copyright are not
240 | used to limit the access or legal rights of the compilation's users
241 | beyond what the individual works permit. Inclusion of a covered work
242 | in an aggregate does not cause this License to apply to the other
243 | parts of the aggregate.
244 |
245 | 6. Conveying Non-Source Forms.
246 |
247 | You may convey a covered work in object code form under the terms
248 | of sections 4 and 5, provided that you also convey the
249 | machine-readable Corresponding Source under the terms of this License,
250 | in one of these ways:
251 |
252 | a) Convey the object code in, or embodied in, a physical product
253 | (including a physical distribution medium), accompanied by the
254 | Corresponding Source fixed on a durable physical medium
255 | customarily used for software interchange.
256 |
257 | b) Convey the object code in, or embodied in, a physical product
258 | (including a physical distribution medium), accompanied by a
259 | written offer, valid for at least three years and valid for as
260 | long as you offer spare parts or customer support for that product
261 | model, to give anyone who possesses the object code either (1) a
262 | copy of the Corresponding Source for all the software in the
263 | product that is covered by this License, on a durable physical
264 | medium customarily used for software interchange, for a price no
265 | more than your reasonable cost of physically performing this
266 | conveying of source, or (2) access to copy the
267 | Corresponding Source from a network server at no charge.
268 |
269 | c) Convey individual copies of the object code with a copy of the
270 | written offer to provide the Corresponding Source. This
271 | alternative is allowed only occasionally and noncommercially, and
272 | only if you received the object code with such an offer, in accord
273 | with subsection 6b.
274 |
275 | d) Convey the object code by offering access from a designated
276 | place (gratis or for a charge), and offer equivalent access to the
277 | Corresponding Source in the same way through the same place at no
278 | further charge. You need not require recipients to copy the
279 | Corresponding Source along with the object code. If the place to
280 | copy the object code is a network server, the Corresponding Source
281 | may be on a different server (operated by you or a third party)
282 | that supports equivalent copying facilities, provided you maintain
283 | clear directions next to the object code saying where to find the
284 | Corresponding Source. Regardless of what server hosts the
285 | Corresponding Source, you remain obligated to ensure that it is
286 | available for as long as needed to satisfy these requirements.
287 |
288 | e) Convey the object code using peer-to-peer transmission, provided
289 | you inform other peers where the object code and Corresponding
290 | Source of the work are being offered to the general public at no
291 | charge under subsection 6d.
292 |
293 | A separable portion of the object code, whose source code is excluded
294 | from the Corresponding Source as a System Library, need not be
295 | included in conveying the object code work.
296 |
297 | A "User Product" is either (1) a "consumer product", which means any
298 | tangible personal property which is normally used for personal, family,
299 | or household purposes, or (2) anything designed or sold for incorporation
300 | into a dwelling. In determining whether a product is a consumer product,
301 | doubtful cases shall be resolved in favor of coverage. For a particular
302 | product received by a particular user, "normally used" refers to a
303 | typical or common use of that class of product, regardless of the status
304 | of the particular user or of the way in which the particular user
305 | actually uses, or expects or is expected to use, the product. A product
306 | is a consumer product regardless of whether the product has substantial
307 | commercial, industrial or non-consumer uses, unless such uses represent
308 | the only significant mode of use of the product.
309 |
310 | "Installation Information" for a User Product means any methods,
311 | procedures, authorization keys, or other information required to install
312 | and execute modified versions of a covered work in that User Product from
313 | a modified version of its Corresponding Source. The information must
314 | suffice to ensure that the continued functioning of the modified object
315 | code is in no case prevented or interfered with solely because
316 | modification has been made.
317 |
318 | If you convey an object code work under this section in, or with, or
319 | specifically for use in, a User Product, and the conveying occurs as
320 | part of a transaction in which the right of possession and use of the
321 | User Product is transferred to the recipient in perpetuity or for a
322 | fixed term (regardless of how the transaction is characterized), the
323 | Corresponding Source conveyed under this section must be accompanied
324 | by the Installation Information. But this requirement does not apply
325 | if neither you nor any third party retains the ability to install
326 | modified object code on the User Product (for example, the work has
327 | been installed in ROM).
328 |
329 | The requirement to provide Installation Information does not include a
330 | requirement to continue to provide support service, warranty, or updates
331 | for a work that has been modified or installed by the recipient, or for
332 | the User Product in which it has been modified or installed. Access to a
333 | network may be denied when the modification itself materially and
334 | adversely affects the operation of the network or violates the rules and
335 | protocols for communication across the network.
336 |
337 | Corresponding Source conveyed, and Installation Information provided,
338 | in accord with this section must be in a format that is publicly
339 | documented (and with an implementation available to the public in
340 | source code form), and must require no special password or key for
341 | unpacking, reading or copying.
342 |
343 | 7. Additional Terms.
344 |
345 | "Additional permissions" are terms that supplement the terms of this
346 | License by making exceptions from one or more of its conditions.
347 | Additional permissions that are applicable to the entire Program shall
348 | be treated as though they were included in this License, to the extent
349 | that they are valid under applicable law. If additional permissions
350 | apply only to part of the Program, that part may be used separately
351 | under those permissions, but the entire Program remains governed by
352 | this License without regard to the additional permissions.
353 |
354 | When you convey a copy of a covered work, you may at your option
355 | remove any additional permissions from that copy, or from any part of
356 | it. (Additional permissions may be written to require their own
357 | removal in certain cases when you modify the work.) You may place
358 | additional permissions on material, added by you to a covered work,
359 | for which you have or can give appropriate copyright permission.
360 |
361 | Notwithstanding any other provision of this License, for material you
362 | add to a covered work, you may (if authorized by the copyright holders of
363 | that material) supplement the terms of this License with terms:
364 |
365 | a) Disclaiming warranty or limiting liability differently from the
366 | terms of sections 15 and 16 of this License; or
367 |
368 | b) Requiring preservation of specified reasonable legal notices or
369 | author attributions in that material or in the Appropriate Legal
370 | Notices displayed by works containing it; or
371 |
372 | c) Prohibiting misrepresentation of the origin of that material, or
373 | requiring that modified versions of such material be marked in
374 | reasonable ways as different from the original version; or
375 |
376 | d) Limiting the use for publicity purposes of names of licensors or
377 | authors of the material; or
378 |
379 | e) Declining to grant rights under trademark law for use of some
380 | trade names, trademarks, or service marks; or
381 |
382 | f) Requiring indemnification of licensors and authors of that
383 | material by anyone who conveys the material (or modified versions of
384 | it) with contractual assumptions of liability to the recipient, for
385 | any liability that these contractual assumptions directly impose on
386 | those licensors and authors.
387 |
388 | All other non-permissive additional terms are considered "further
389 | restrictions" within the meaning of section 10. If the Program as you
390 | received it, or any part of it, contains a notice stating that it is
391 | governed by this License along with a term that is a further
392 | restriction, you may remove that term. If a license document contains
393 | a further restriction but permits relicensing or conveying under this
394 | License, you may add to a covered work material governed by the terms
395 | of that license document, provided that the further restriction does
396 | not survive such relicensing or conveying.
397 |
398 | If you add terms to a covered work in accord with this section, you
399 | must place, in the relevant source files, a statement of the
400 | additional terms that apply to those files, or a notice indicating
401 | where to find the applicable terms.
402 |
403 | Additional terms, permissive or non-permissive, may be stated in the
404 | form of a separately written license, or stated as exceptions;
405 | the above requirements apply either way.
406 |
407 | 8. Termination.
408 |
409 | You may not propagate or modify a covered work except as expressly
410 | provided under this License. Any attempt otherwise to propagate or
411 | modify it is void, and will automatically terminate your rights under
412 | this License (including any patent licenses granted under the third
413 | paragraph of section 11).
414 |
415 | However, if you cease all violation of this License, then your
416 | license from a particular copyright holder is reinstated (a)
417 | provisionally, unless and until the copyright holder explicitly and
418 | finally terminates your license, and (b) permanently, if the copyright
419 | holder fails to notify you of the violation by some reasonable means
420 | prior to 60 days after the cessation.
421 |
422 | Moreover, your license from a particular copyright holder is
423 | reinstated permanently if the copyright holder notifies you of the
424 | violation by some reasonable means, this is the first time you have
425 | received notice of violation of this License (for any work) from that
426 | copyright holder, and you cure the violation prior to 30 days after
427 | your receipt of the notice.
428 |
429 | Termination of your rights under this section does not terminate the
430 | licenses of parties who have received copies or rights from you under
431 | this License. If your rights have been terminated and not permanently
432 | reinstated, you do not qualify to receive new licenses for the same
433 | material under section 10.
434 |
435 | 9. Acceptance Not Required for Having Copies.
436 |
437 | You are not required to accept this License in order to receive or
438 | run a copy of the Program. Ancillary propagation of a covered work
439 | occurring solely as a consequence of using peer-to-peer transmission
440 | to receive a copy likewise does not require acceptance. However,
441 | nothing other than this License grants you permission to propagate or
442 | modify any covered work. These actions infringe copyright if you do
443 | not accept this License. Therefore, by modifying or propagating a
444 | covered work, you indicate your acceptance of this License to do so.
445 |
446 | 10. Automatic Licensing of Downstream Recipients.
447 |
448 | Each time you convey a covered work, the recipient automatically
449 | receives a license from the original licensors, to run, modify and
450 | propagate that work, subject to this License. You are not responsible
451 | for enforcing compliance by third parties with this License.
452 |
453 | An "entity transaction" is a transaction transferring control of an
454 | organization, or substantially all assets of one, or subdividing an
455 | organization, or merging organizations. If propagation of a covered
456 | work results from an entity transaction, each party to that
457 | transaction who receives a copy of the work also receives whatever
458 | licenses to the work the party's predecessor in interest had or could
459 | give under the previous paragraph, plus a right to possession of the
460 | Corresponding Source of the work from the predecessor in interest, if
461 | the predecessor has it or can get it with reasonable efforts.
462 |
463 | You may not impose any further restrictions on the exercise of the
464 | rights granted or affirmed under this License. For example, you may
465 | not impose a license fee, royalty, or other charge for exercise of
466 | rights granted under this License, and you may not initiate litigation
467 | (including a cross-claim or counterclaim in a lawsuit) alleging that
468 | any patent claim is infringed by making, using, selling, offering for
469 | sale, or importing the Program or any portion of it.
470 |
471 | 11. Patents.
472 |
473 | A "contributor" is a copyright holder who authorizes use under this
474 | License of the Program or a work on which the Program is based. The
475 | work thus licensed is called the contributor's "contributor version".
476 |
477 | A contributor's "essential patent claims" are all patent claims
478 | owned or controlled by the contributor, whether already acquired or
479 | hereafter acquired, that would be infringed by some manner, permitted
480 | by this License, of making, using, or selling its contributor version,
481 | but do not include claims that would be infringed only as a
482 | consequence of further modification of the contributor version. For
483 | purposes of this definition, "control" includes the right to grant
484 | patent sublicenses in a manner consistent with the requirements of
485 | this License.
486 |
487 | Each contributor grants you a non-exclusive, worldwide, royalty-free
488 | patent license under the contributor's essential patent claims, to
489 | make, use, sell, offer for sale, import and otherwise run, modify and
490 | propagate the contents of its contributor version.
491 |
492 | In the following three paragraphs, a "patent license" is any express
493 | agreement or commitment, however denominated, not to enforce a patent
494 | (such as an express permission to practice a patent or covenant not to
495 | sue for patent infringement). To "grant" such a patent license to a
496 | party means to make such an agreement or commitment not to enforce a
497 | patent against the party.
498 |
499 | If you convey a covered work, knowingly relying on a patent license,
500 | and the Corresponding Source of the work is not available for anyone
501 | to copy, free of charge and under the terms of this License, through a
502 | publicly available network server or other readily accessible means,
503 | then you must either (1) cause the Corresponding Source to be so
504 | available, or (2) arrange to deprive yourself of the benefit of the
505 | patent license for this particular work, or (3) arrange, in a manner
506 | consistent with the requirements of this License, to extend the patent
507 | license to downstream recipients. "Knowingly relying" means you have
508 | actual knowledge that, but for the patent license, your conveying the
509 | covered work in a country, or your recipient's use of the covered work
510 | in a country, would infringe one or more identifiable patents in that
511 | country that you have reason to believe are valid.
512 |
513 | If, pursuant to or in connection with a single transaction or
514 | arrangement, you convey, or propagate by procuring conveyance of, a
515 | covered work, and grant a patent license to some of the parties
516 | receiving the covered work authorizing them to use, propagate, modify
517 | or convey a specific copy of the covered work, then the patent license
518 | you grant is automatically extended to all recipients of the covered
519 | work and works based on it.
520 |
521 | A patent license is "discriminatory" if it does not include within
522 | the scope of its coverage, prohibits the exercise of, or is
523 | conditioned on the non-exercise of one or more of the rights that are
524 | specifically granted under this License. You may not convey a covered
525 | work if you are a party to an arrangement with a third party that is
526 | in the business of distributing software, under which you make payment
527 | to the third party based on the extent of your activity of conveying
528 | the work, and under which the third party grants, to any of the
529 | parties who would receive the covered work from you, a discriminatory
530 | patent license (a) in connection with copies of the covered work
531 | conveyed by you (or copies made from those copies), or (b) primarily
532 | for and in connection with specific products or compilations that
533 | contain the covered work, unless you entered into that arrangement,
534 | or that patent license was granted, prior to 28 March 2007.
535 |
536 | Nothing in this License shall be construed as excluding or limiting
537 | any implied license or other defenses to infringement that may
538 | otherwise be available to you under applicable patent law.
539 |
540 | 12. No Surrender of Others' Freedom.
541 |
542 | If conditions are imposed on you (whether by court order, agreement or
543 | otherwise) that contradict the conditions of this License, they do not
544 | excuse you from the conditions of this License. If you cannot convey a
545 | covered work so as to satisfy simultaneously your obligations under this
546 | License and any other pertinent obligations, then as a consequence you may
547 | not convey it at all. For example, if you agree to terms that obligate you
548 | to collect a royalty for further conveying from those to whom you convey
549 | the Program, the only way you could satisfy both those terms and this
550 | License would be to refrain entirely from conveying the Program.
551 |
552 | 13. Use with the GNU Affero General Public License.
553 |
554 | Notwithstanding any other provision of this License, you have
555 | permission to link or combine any covered work with a work licensed
556 | under version 3 of the GNU Affero General Public License into a single
557 | combined work, and to convey the resulting work. The terms of this
558 | License will continue to apply to the part which is the covered work,
559 | but the special requirements of the GNU Affero General Public License,
560 | section 13, concerning interaction through a network will apply to the
561 | combination as such.
562 |
563 | 14. Revised Versions of this License.
564 |
565 | The Free Software Foundation may publish revised and/or new versions of
566 | the GNU General Public License from time to time. Such new versions will
567 | be similar in spirit to the present version, but may differ in detail to
568 | address new problems or concerns.
569 |
570 | Each version is given a distinguishing version number. If the
571 | Program specifies that a certain numbered version of the GNU General
572 | Public License "or any later version" applies to it, you have the
573 | option of following the terms and conditions either of that numbered
574 | version or of any later version published by the Free Software
575 | Foundation. If the Program does not specify a version number of the
576 | GNU General Public License, you may choose any version ever published
577 | by the Free Software Foundation.
578 |
579 | If the Program specifies that a proxy can decide which future
580 | versions of the GNU General Public License can be used, that proxy's
581 | public statement of acceptance of a version permanently authorizes you
582 | to choose that version for the Program.
583 |
584 | Later license versions may give you additional or different
585 | permissions. However, no additional obligations are imposed on any
586 | author or copyright holder as a result of your choosing to follow a
587 | later version.
588 |
589 | 15. Disclaimer of Warranty.
590 |
591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
599 |
600 | 16. Limitation of Liability.
601 |
602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
610 | SUCH DAMAGES.
611 |
612 | 17. Interpretation of Sections 15 and 16.
613 |
614 | If the disclaimer of warranty and limitation of liability provided
615 | above cannot be given local legal effect according to their terms,
616 | reviewing courts shall apply local law that most closely approximates
617 | an absolute waiver of all civil liability in connection with the
618 | Program, unless a warranty or assumption of liability accompanies a
619 | copy of the Program in return for a fee.
620 |
621 | END OF TERMS AND CONDITIONS
622 |
623 | How to Apply These Terms to Your New Programs
624 |
625 | If you develop a new program, and you want it to be of the greatest
626 | possible use to the public, the best way to achieve this is to make it
627 | free software which everyone can redistribute and change under these terms.
628 |
629 | To do so, attach the following notices to the program. It is safest
630 | to attach them to the start of each source file to most effectively
631 | state the exclusion of warranty; and each file should have at least
632 | the "copyright" line and a pointer to where the full notice is found.
633 |
634 |
635 | Copyright (C)
636 |
637 | This program is free software: you can redistribute it and/or modify
638 | it under the terms of the GNU General Public License as published by
639 | the Free Software Foundation, either version 3 of the License, or
640 | (at your option) any later version.
641 |
642 | This program is distributed in the hope that it will be useful,
643 | but WITHOUT ANY WARRANTY; without even the implied warranty of
644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
645 | GNU General Public License for more details.
646 |
647 | You should have received a copy of the GNU General Public License
648 | along with this program. If not, see .
649 |
650 | Also add information on how to contact you by electronic and paper mail.
651 |
652 | If the program does terminal interaction, make it output a short
653 | notice like this when it starts in an interactive mode:
654 |
655 | Copyright (C)
656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
657 | This is free software, and you are welcome to redistribute it
658 | under certain conditions; type `show c' for details.
659 |
660 | The hypothetical commands `show w' and `show c' should show the appropriate
661 | parts of the General Public License. Of course, your program's commands
662 | might be different; for a GUI interface, you would use an "about box".
663 |
664 | You should also get your employer (if you work as a programmer) or school,
665 | if any, to sign a "copyright disclaimer" for the program, if necessary.
666 | For more information on this, and how to apply and follow the GNU GPL, see
667 | .
668 |
669 | The GNU General Public License does not permit incorporating your program
670 | into proprietary programs. If your program is a subroutine library, you
671 | may consider it more useful to permit linking proprietary applications with
672 | the library. If this is what you want to do, use the GNU Lesser General
673 | Public License instead of this License. But first, please read
674 | .
675 |
--------------------------------------------------------------------------------