Giter Club home page Giter Club logo

gerbmerge's Introduction

GerbMerge -- A Gerber-file merging program

What's New

In Release 1.x

  • Python 3
  • Split up parsing

In release 1.9

  • Added metric support
  • Added default timeout for random tile placement
  • Added DipTrace support
  • Use boardoutline files (when present) to build cutlines in silkscreen layers instead of the default calculated algorithm. This change permits non-rectangular board outlines.

In release 1.8:

  • Released under more recent GPL v3 license
  • Summary statistics prints out smallest drill tool diameter
  • Added FiducialPoints, FiducialCopperDiameter, and FiducialMaskDiameter configuration options
  • Added option to write fiducials to final panel
  • Scoring lines now go all the way across a panel

In release 1.7:

  • Added a new command-line option --search-timeout to time-limit the automatic placement process.
  • Added preliminary support for a GUI controller interface.

Introduction

GerbMerge is a program for combining (panelizing) the CAM data from multiple printed circuit board designs into a single set of CAM files. The purpose of doing so is to submit a single job to a board manufacturer, thereby saving on manufacturing costs.

GerbMerge currently works with:

  • CAM data generated by the Eagle circuit board design program, with "best effort" support for Orcad, Protel, and PCB
  • Artwork in Gerber RS274-X format
  • Drill files in Excellon format

Here is one sample and another sample of the program's output. These samples demonstrate panelizing multiple, different jobs, and also demonstrate board rotation.

Requirements

GerbMerge is written in pure Python. It depends upon the following packages for operation:

  • Python version 2.4 or later
  • SimpleParse version 2.1.0 or later

All of the above packages come with easy installation programs for both Windows, Mac OS X,and Linux.

Installation

First, install all of the packages listed above in the Requirements section.

Windows

Run the gerbmerge1.8.exe installation program. I will assume you choose all of the default installation options. The installer will create and populate the following directories:

c:\Python24\lib\site-packages\gerbmerge
c:\Python24\gerbmerge

The above assumes you have Python installed in C:\Python24. The first directory is where the actual program resides. The second directory contains the documentation, example files, etc. In the C:\Python24 directory is a sample batch file GERBMERGE.BAT which shows you how to run the GerbMerge program.

Unix / Mac OS X

Extract the gerbmerge1.8.tar.gz file then install as follows:

python setup.py install   (You may need to be root to install to system directories)

The installer will create and populate the following directories/files:

/usr/local/lib/python2.4/site-packages/gerbmerge
/usr/local/lib/python2.4/gerbmerge
/usr/local/bin/gerbmerge

The above assumes your Python library directory is as indicated (it may be elsewhere but the installer should be able to find it, so don't worry about it). The first directory is where the actual program resides. The second directory contains the documentation, example files, etc. A sample program for invoking GerbMerge is installed as /usr/local/bin/gerbmerge...feel free to move it somewhere else.

Not all Linux distributions are the same, however. If you have trouble, there is a useful set of instructions from Chetan Bhargava for installing GerbMerge on Ubuntu distributions.

Running GerbMerge

Windows

Open a DOS box and invoke the Python interpreter on the gerbmerge.py file. Have a look at GERBMERGE.BAT (and put this on your Path somewhere) for an example. c:\python24\python c:\python24\lib\site-packages\gerbmerge\gerbmerge.py

Unix / Mac OS X

You run GerbMerge by invoking the Python interpreter on the gerbmerge.py file of the gerbmerge package. For example:

python /usr/local/lib/python2.4/site-packages/gerbmerge/gerbmerge.py

The gerbmerge shell script that comes with this software contains an example for running GerbMerge, modelled on the above. By default, this shell script is installed in /usr/local/bin so you should just be able to type gerbmerge from a shell prompt.

Operation

There are three ways to run GerbMerge:

  1. By manually specifying the relative placement of jobs
  2. By manually specifying the absolute placement of jobs
  3. By letting GerbMerge automatically search for a placement that minimizes total panel area

Manual Relative Placement

For the manual relative placement approach, GerbMerge needs two input text files:

  • The configuration file specifies global options and defines the jobs to be panelized
  • The layout file specifies how the jobs are to be laid out.

The names of these files are the two required parameters to GerbMerge: gerbmerge file.cfg file.def

The following links describe the contents of the configuration file and layout file.

Manual Absolute Placement

For the manual absolute placement approach, GerbMerge also needs the configuration file as well as another text file that specifies where each job is located on the panel and whether or not it is rotated:

gerbmerge --place-file=place.txt file.cfg

The place.txt file looks something like:

cpu 0.756 0.100
cpu*rotated 1.35 1.50

This method of placement is not meant for normal use. It can be used to recreate a previous invocation of GerbMerge, since GerbMerge saves its results in a text file (whose name is set in the MergeOutputFiles section of the configuration file) after every run. Thus, you can experiment with different parameters, save a placement you like, do some more experimentation, then return to the saved placement if necessary.

Alternatively, this method of placement can be used with third-party back ends that implement intelligent auto-placement algorithms, using GerbMerge only for doing the actual panelization.

Automatic Placement

For the automatic placement approach, GerbMerge only needs the configuration file: gerbmerge file.cfg Command-line options can be used to modify the search algorithm. See the Automatic Placement page for more information.

Input File Requirements

GerbMerge requires the following input CAM files:

  • Each job must have a Gerber file describing the board outline, which is assumed rectangular. In Eagle, a board outline is usually generated from the Dimension layer. This board outline is a width-0 line describing the physical extents of the board. If you're not using Eagle, you don't have to generate a width-0 rectangle, but GerbMerge does need to use some Gerber layer to determine the extents of the board. GerbMerge will take the maximum extents of all drawn objects in this layer as the extents of the board.
  • Each job must have an Excellon drill file.
  • Each job can have any number of optional Gerber files describing copper layers, silkscreen, solder masks, etc.
  • All files must have the same offset and must be shown looking from the top of the board, i.e., not mirrored.
  • Each job may have an optional tool list file indicating the tool names used in the Excellon file and the diameter of each tool. This file is not necessary if tool sizes are embedded in the Excellon file. A typical tool list file looks like:
T01 0.025in
T02 0.032in
T03 0.045in

Verifying the Output

Before sending your job to be manufactured, it is imperative that you verify the correctness of the output. Remember that GerbMerge comes with NO WARRANTY. Manufacturing circuit boards costs real money and a single mistake can render an entire lot of boards unusable.

I recommend the following programs for viewing the final output data. Take the time to become very familiar with at least one of these tools and to use it before every job you send out for manufacture.

gerbv
For Linux, the best option (currently) for viewing Gerber and Excellon files is the `gerbv` program. Simply type in the names of all files generated by GerbMerge as parameters to `gerbv`:
gerbv merged.*.ger merged.*.xln
GC-Prevue
For Windows, [GC-Prevue](http://www.graphicode.com) is a good program that I have used often. It is a free program. GraphiCode makes lots of other, more powerful Gerber manipulation and viewing programs but they are quite pricey ($495 and up).
ViewMate
Another free Windows program, [ViewMate](http://www.pentalogix.com) is similar to GC-Prevue. I have not used ViewMate much, but that is mostly due to familiarity with GC-Prevue. The two programs are comparable, although I'm sure that someone who is much more familiar with both could point out some differences.

Limitations

  • This program has mainly been tested with output from the Eagle CAD program. Limited testing has been performed with Orcad, Protel, and PCB. Other CAD programs will NOT WORK with a very high probability, as the input parser is quite primitive. If you have the need/motivation to adapt GerbMerge to other CAD programs, have a look at the gerber2pdf program. It is written in Python and implements a much more complete RS274-X input file parser. Combining GerbMerge with gerber2pdf should be a fairly simple exercise. Also, feel free to send us samples of Gerber/Excellon output of your CAD tool and we'll see if we can add support for it.

  • This program handles apertures that are rectangles, ovals, circles, macros without parameters or operators, and Eagle octagons (which are defined using a macro with a single parameter, hence currently handled as a special case).

  • The panelizing capabilities of this program do not allow for arbitrary placement of jobs, although there is a fair amount of flexibility.

  • All jobs are assumed to be rectangular in shape. Non-rectangular jobs can be handled but will lead to wasted space in the final panel.

  • A maximum of 26 different drill sizes is supported for generating a fabrication drawing.

Program Options

--octagons=normal
--octagons=rotate
The `--octagons` option affects how the octagon aperture is defined in the output files. The parameter to this option must either be `rotate` or `normal`. Normally, octagons begin at an angle of 22.5 degrees, but some Gerber viewers have a problem with that (notably CircuitMaker from LPKF). These programs expect octagons to begin at 0.0 degrees.
The `--octagons=normal` option is the default (22.5 degrees) and need not be specified. A rotation of 0.0 degrees can be achieved by specifying `--octagons=rotate`.
--random-search
This option is the default when only a configuration file is specified (see the documentation on [Automatic Placement](./doc/autosearch.md) for more information). It indicates that a randomized search of possible job tilings is to be performed. This option does not make sense when a layout file is specified.
--full-search
This option may be specified to indicate that all possible job tilings are to be searched (see the documentation on [Automatic Placement](./doc/autosearch.md) for more information). This option does not make sense when a layout file is specified.
--rs-fsjobs=N
This option is used with randomized search to indicate how many jobs are to undergo full search for each tiling. See the documentation on [Automatic Placement](./doc/autosearch.md) for more information.
--place-file=filename
This option performs a panel layout based upon absolute job positions in the given text file, rather than by random/full search or by a layout file. The placement file created by GerbMerge can be used as an input file to this option in order to recreate a previous layout.
--no-trim-gerber
This option prevents GerbMerge from trying to trim all Gerber data to lie within the extents of a given job's board outline. Normally, GerbMerge will try to do so to prevent one job's Gerber data (most notably, silkscreen lines for connectors that protrude from the board) from interfering with a neighboring job on the final panel. Specify this command-line option if you do not want this trimming to occur.
--no-trim-excellon
This option prevents GerbMerge from trying to trim all Excellon data to lie within the extents of a given job's board outline. Normally, GerbMerge will try to do so to prevent one job's drill holes from landing in the middle of a neighboring job on the final panel. Specify this command-line option if you do not want this trimming to occur.
--search-timeout=seconds
When random placements are used, this option can be used to automatically terminate the search process after the specified number of seconds. If the number of seconds is 0 or this option is not specified, then random placements are tried forever, until Ctrl-C is pressed to stop the process and keep the best placement so far.
-h, --help
The '`-h`' or '`--help`' option prints a brief summary of available options.
-v, --version
The '`-v`' or '`--version`' option prints the current program version and author contact information.

Copyright & License

Copyright © 2013 ProvideYourOwn.com. All Rights Reserved.

This repo is a fork of gerbmerge, version 1.8 from Rugged Circuits LLC:

Copyright © 2011 Rugged Circuits LLC. All Rights Reserved. mailto:[email protected]

GerbMerge comes with ABSOLUTELY NO WARRANTY. This is free software licensed under the terms of the GNU General Public License Version 3. You are welcome to copy, modify and redistribute this software under certain conditions. For more details, see the LICENSE file or visit The Free Software Foundation.

To Do

  1. Accept outputs from more CAD programs
  2. A graphical interface for interactive placement
  3. Better reporting of parse errors in the layout and configuration files
  4. Implement simple primitive for panelizing a single job in an array
  5. More intelligent placement algorithms, possibly based on the fabric cutting problem.
  6. Accept aperture macro parameters and operators

Credits

Thanks to Jace Browning for major contributions to this code. This help file is based on a template for the help file for mxTools by M.A. Lemburg. This software was created with VIM; thanks to the authors of this program and special thanks for the Python syntax support. Thanks to M.A. Lemburg for his mxBase package, Mike Fletcher for his SimpleParse package, and the authors of gerbv, a great Gerber file viewer for Linux/Mac OS X, and, of course, to the Python developers and support community.

Thanks to Joe Pighetti for making me start writing this program, and to the Grand Valley State University Firefighting Robot Team for making me finish it.

Thanks to Matt Kavalauskas for identifying Eagle's annulus and thermal macros and supporting the development of the aperture macro code.

Thanks to Bohdan Zograf for the Belorussian translation of this documentation.

Copyright © 2019 Jarl Nicolson. All Rights Reserved

Copyright © 2013 ProvideYourOwn.com. All Rights Reserved.

Portions (version 1.8 & prior): Copyright © 2003-2011, Copyright by Rugged Circuits LLC; All Rights Reserved. mailto: [email protected]

gerbmerge's People

Contributors

jnicolson avatar scottdky avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

gerbmerge's Issues

Installation fails

When I try to install with Python 3, I get the following error, which I think is a python 2/3 compatibility. I solved it using one of the suggestions here: https://stackoverflow.com/questions/43728431/relative-imports-modulenotfounderror-no-module-named-x - specifically adding sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) to gerbmerge.py before the imports, but this seems shady...

    ERROR: Command errored out with exit status 1:
     command: /home/ckemere/anaconda3/bin/python -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/home/ckemere/Code/gerbmerge/setup.py'"'"'; __file__='"'"'/home/ckemere/Code/gerbmerge/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-xo3qj9t7
         cwd: /home/ckemere/Code/gerbmerge/
    Complete output (7 lines):
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/home/ckemere/Code/gerbmerge/setup.py", line 2, in <module>
        from gerbmerge.gerbmerge import VERSION_MAJOR, VERSION_MINOR
      File "/home/ckemere/Code/gerbmerge/gerbmerge/gerbmerge.py", line 29, in <module>
        import aptable, config, drillcluster, fabdrawing
    ModuleNotFoundError: No module named 'aptable'

Split large functions

A lot of functions look to be unnecessarily large and could be split into smaller, testable, single purpose functions

Hellen81 test case

TL, DR: can we have https://github.com/rusefi/gerbmerge/tree/rusefi-tests/examples/hellen81-a work on this fork? in that folder there is full input and expected output. that test passes on https://github.com/rusefi/gerbmerge with based on all the random fixes we've picked from around and made ourselves.

Longer story: https://github.com/rusefi/rusefi is an open source project for internal combustion engine control unit. In order to facilitate plug-in boards for different vehicles/different connectors with reusable functional blocks @andreika-git has created https://github.com/andreika-git/hellen-one/ with is GerbMerge+PdfMerge+SomethingElseMerge+actual reusable modules to use

https://github.com/andreika-git/hellen81 would be a specific ECU which was developed using that framework

I believe that hellen81 specifically has only Altium Designer gerber files as opposed to other rusEFI boards which often use KiCAD 6.

Is this fork trying to be compatible or has unique configuration approach?

What is the idea of this fork in terms of compatibility?
it looks like one of the arguments layoutfile --random-search --full-search is required is different from some of the other forks - is this a feature or a bug?

debian@debian:~/gerbmerge.jnicolson/examples/hellen81-a$ python3 ../../gerbmerge --place-file=board_place.txt board.cfg
error: one of the arguments layoutfile --random-search --full-search is required
usage: gerbmerge [options] configfile [layoutfile]

gerbmerge is a utility to combine various gerber + excellon files into a single file

positional arguments:
  configfile            config file to read (see help for format)
  layoutfile            file containing layout of gerbers defined in config file (default: None)

optional arguments:
  -h, --help            show this help message and exit
  --random-search       Automatic placement using random search (default: False)
  --full-search         Automatic placement using exhaustive search (default: False)

Unable to launch the tool

previous versions / other forks allow me to execute gerbmerge.py from other folders like for instance

https://github.com/rusefi/gerbmerge/blob/rusefi-tests/examples/hellen81-a/run.sh

I am not a Python power user and I am unable to launch this version:

rusefi@DESKTOP-57S88S8:~/gerbmerge.jnicolson$ python3 gerbmerge/gerbmerge.py
Traceback (most recent call last):
  File "gerbmerge/gerbmerge.py", line 29, in <module>
    from . import (aptable, config, drillcluster, fabdrawing, jobs, parselayout,
ImportError: attempted relative import with no known parent package
rusefi@DESKTOP-57S88S8:~/gerbmerge.jnicolson$

Is there a new requirement for gerbmerge.py to be located in current folder due to "from ."?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.