[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: gEDA-user: scripting for pcb



Hi Karl,

On Thu, Dec 30, 2010 at 12:29:21PM +0100, Karl Hammar wrote:
> Tibor:
> > On Wed, Dec 29, 2010 at 08:51:19PM +0100, Stephan Boettcher wrote:
> ...
> > > And when that's the case, a clean C-API that can be exported to Guile,
> > > Python, Ruby, C++, Fortran, ... just dreaming.
> [the above is about gschem, now switching to pcb]
> > I once started to do that to PCB usign libgpmi, and got a plugin that 
> > exports a small portion of PCB internals through some sort of higher 
> > level APIs to any scripting language libgpmi supports (10 at the 
> > moment).
> 
> I took a quick look at libgpmi and it seems to be scarce on 
> documentation [1]. [2] have a note on gpmi. [2] also talks about a 
> function library and a perl-callable parser. [3] does not mention any
> scripting language. There is some scripting possible through
> src/action.c.

Libgpmi doesn't have much documentation, true. I've just found I even 
broke the website. Will fix it soon. Meanwhile, list of languages 
supported:

- awk (using libmawk)
- lua
- scheme (guile)
- stutter (a lisp dialect)
- pascal (ghli - may be broken at the moment)
- perl
- php
- python
- ruby
- tcl
- of course you can write your module in C and load it as a shared 
object

You can find a more detailed list at 
http://repo.hu/projects/pcb-gpmi/languages.txt 
 
> Is there any plans or needs for a scripting language (like guile/perl/
> ...) for pcb?

On the above list you can find both of those languages. 

Anyway you won't find references of this in pcb sources. The whole thing 
is a plugin and a set of gpmi packages. The design is like this:

[PCB] -> [pcb-gpmi plugin] -> [scripts] -> [interface packages]
 ^                                                  |
 |                                                  |
 +--------------------------------------------------+
 

Or in text: PCB loads a plugin called pcb-gpmi, which will load a config 
file and according to that, will load a set of scripts. Scripts will in 
turn load interface packages. Interface packages are tiny shared object 
files which provide an interface between PCB internals and scripting 
languages. The idea is to have some sort of higher level API which does 
not change much and is more convenient.

How powerful the whole thing can get depends on how many languages it 
supports and how much of the PCB internals are exposed. I believe the 
list of languages is impressive. Unfortunately interface packages are 
only a few, and thin, only as much as I needed for proof-of-concept or 
to fulfill my daily needs on missing PCB features. Here is a short list 
of already working packages:
- actions: scripts can create actions usign this package.
- dialogs: create dialog boxes using the current hid; your script can 
pop up data entry windows, give warnings, etc.
- hid: allows the script to regiester an exporter hid with dynamic 
attributes
- layout: query or draw objects on the current layout


There are a set of example scripts written in different languages to 
demonstrate ease of use of PCB internals with pcb-gpmi:
- carc: custom angle arc support written in lua; registers an action 
that pops up a dialog where user can set angles and other properties of 
an arc that will be then placed on the layout using the current 
layer/style.
- SVG exporter written in tcl; proof-of-concept but already can export a 
somewhat good looking SVG. 
- HPGL exporter written in awk; cares only about lines but can repeat 
lines by layer. I own an old pen plotter I drive with this hid.

You can find the scripts at http://repo.hu/projects/pcb-gpmi/plugins/

pcb-gpmi is documented; you can read the on-line documentation at 
http://repo.hu/projects/pcb-gpmi/doc/ ; gpmi, as you mentioned, is 
largely undocumented. However, if you are interested in using pcb-gpmi 
for scripting your plugins, you don't need to know anything about gpmi, 
the same way as using PCB GTK hid for drawing your layouts doesn't imply 
you need to know how GTK works. Of course this is no good excuse for 
missing doc, I just wanted to point out that missing documentation of 
gpmi is not a show stopper.

On the other hand, since user count of the project is exaclty 1 (that is 
me) for the past ~4 years, don't expect it to be user-friendly. For 
example current svn HEAD of gpmi probably won't work out-of-the-box with 
pcb-gpmi, and you will need to use the last release instead. If I had 
users I would have made a branch for the big cleanup I am doing on gpmi 
lately, but as I didn't have users I just started it on trunk.

If you are still interested in the project, I can support compiling and 
installing.

Regards,

Tibor Palinkas


_______________________________________________
geda-user mailing list
geda-user@xxxxxxxxxxxxxx
http://www.seul.org/cgi-bin/mailman/listinfo/geda-user