Although it’s derided for not being open source, EagleCAD is an extremely popular piece of schematic and PCB layout software. Most of the popularity is probably due to the incredible amount of part libraries – it’s certainly not the features Eagle has to offer or its horrible scripting capabilities. [Rob] had enough of the lack of good scripting support in Eagle, so he’s been spending his time making Eagle’s ULP work with Python. He’s only been at it a short time, but already it’s much more usable than the usual Eagle scripts.
Below you can check out a pair of videos of [Rob]’s Python tools for Eagle in action. The first video goes through aligning a few symbols and creating a board outline (with proper curves!) from a DXF file. The second video shows exactly how valuable these tools are when laying out a board: imagine hundreds of LEDs and resistors automatically aligned to each other with a single click of a mouse. Beautiful.
All the PyEagle stuff is available on [Rob]’s github, with a DXF importer, group manager, and alignment tool included. Now that everything’s Python, it’s easy to build your own tools without relying on Eagle’s odd ULP language.
Thanks [John] for the tip.
45 thoughts on “Extending EagleCAD With Python”
One day we’ll get non blocking scripting. One day…
OK, I’ll bite. What is it that’s “horrible” about Eagle’s scripting abilities?
Most of the negative Eagle reviews I’ve seen seem barely aware that such a thing even exists…
+1. Everyone just seems more concerned about the UI and forgets that the command line offers a lot of options. In fact most times I enter commands using it, since the cursor’s always active (I like how you don’t need to enter the full command – for example se wi 0.05 is the same as set width 0.05)
I had a hard time understanding the coordinate representation (e.g. I want to move something a specific distance), but it is very powerful, especially when you can simulate a right or left click (and even ctrl key, I think) with characters in the command line.
I kinda wondered that myself, its pretty powerful as scripting goes.
Except for the whole blocking thing, its really annoying having to execute a script after a ulp and not being able to do realtime changes
But this doesn’t help with that.
Instead of spending time improving a proprietary software like Eagle, people could help to improve open-source one (i.e. KiCAD). Take a look at Open Source Hardware definition: http://www.oshwa.org/definition/
“Ideally, open source hardware uses readily-available components and materials, standard processes, open infrastructure, unrestricted content, and open-source design tools to maximize the ability of individuals to make and use hardware.”
See: Ideally open source hardware uses open-source design tools.
You don’t _have_ to ;-)
Instead of complaining about people doing things to increase their productivity, you should use your time to improve the open source offerings.
I say that not because I want the open source offerings improved, but because I’d rather not see people whining about how other people spend their time.
You are whining about how he spends his time whining… so instead of complaining about people complaining about people doing things to increase their productivity you should use your time to… emmm… improve the open source tools…. ….. Yeah!
And I say it because I want to
Blah, blah, blah. Sbrubbles, sbrubbles, sbrubbles.
I’d love to help modelling a tool. But i need to USE a tool. Today.
While some folks do exceptional work using some of the open source PCB design software that is available I have never been able to manage that myself. So I run Eagle too. I keep giving the FOSS offerings a try but they just don’t work well for me. I also consider the board size limit that Eagle imposes with the freeware copy to be a positive feature too. Because I never want to make a board bigger than it allows anyways.
At this point having used both KiCAD and Eagle the FOSS far surpasses the proprietary version. You need to try an up to date version though, not one that is 6+ months old. Ever since CERN started helping develop KiCAD it has gotten leaps and bounds better. The only reason I can see to stick with Eagle at this point is footprint libraries.
I haven’t tried KICAD out in quite some time. It has been far longer than 6 months. I have a lot of circuits I’ve designed in Eagle at this point so there is that holding me there now too. Even some library parts I’ve made too. When I upgrade this PC I’ll have to give KICAD another shot.
Ah, vendor lock-in. Sucks doesn’t it? If you had gone open-source at the beginning you wouldn’t be suffering now.
Well I believe there’s importers for EAGLE files. I believe that they are almost all xml anyways, so parsing them is a relatively-painless procedure (in addition, the schematic and board files will store the library parts they use)
The Squirrel is correct. You apparently don’t know Eagle and are making assumptions. With Eagle v6 all the files are in XML format and can be easily worked with.
The Open Source choice was not viable at the outset for me. I’ve been at it for too long.
>If you had gone open-source at the beginning you wouldn’t be suffering now.
or suffered from beginning and stopped until 6 months ago with CERN’s improvement?
As far as I know, no sane packages out there would dissociate a symbol from a package. KiCAD is wacky like that. Don’t exactly want your layout person to use a SOT23 version of a LM317 when you want to use a TO-220. Seen that a few times when the layout person do something on his own and not tell you. There are also cases that a chip takes on quite a different pin out, different characteristics and functionality in different packaging e.g. more power/ground pins which changes the amount of decoupling caps you would want to put in or having enhanced thermal characteristics.
I’ve been using pcb design software every now and then as a hobbyist and I’ve been cursing on most of them. It started with “ultimate” in the dos stone ages. That was usable, and would have been pretty ok if it wasn’t so buggy. I even bought 2 versions of it back then (2nd was years later, for windows and even more buggy and unstable than the first one. They kept sending me new cd’s with software, more than half of the 10 or so cd’s were unusable because of the many bugs.
Over the years I’ve been experimenting with 10+ different brands, including eagle, kicad and geda and it always was a struggle.
Untill I tried KiCad again a few months ago. It also has plenty of little bugs and missing features. but it also has a pretty stable base and it’s very usable nowaday’s. I don’t give a darn about libraries. They always suck, It’s far more important that there is a good interface to build your own library and footprints. If that software works good and you’ve gotten used to it you can make a schematic symbol / footprint in a few minutes. And in KiCad it does work pretty good now. It’s the firs pcb design package I’ve really liked in 15+ years. Geda was also usable, but had to many inconstencies between the schematic and pcb part.
Dave Jone’s also had a little go at KiCad recently. He didn’t like it much, but unfortunately he did not even seem to have taken the time to get used to it or even read the manual. (A 10 or so pdf that get’s you going in a few hours). And he’s comparing it to the multi million dollar commercial altium which he’s been using for years. Well, KiCad is a bit different from Altium but that’s not a fair reason to give it a bad review.
I like this new KiCad. Read the manual and give it a try.
You can use Eagle footprints in KiCad.
Lindsay, I’ve been typing set width 16 for far too long! But really the command line, pretty-ok documentation, and XML are EAGLE’s best assets. The parts and library management, however, are abysmal.
But yeah, python would probably be a good language to bind to.
Having the files in text makes it easy enough to change them when there is a limitation in the software. Ideally a user shouldn’t need to do that, but it happens.
I have manually import pin out tables from big FPGA into excel and have it sort (to pin# and I/O banks)and split out the pin# and name connectivity and individual “pins”. Still have to manually edit the symbols to make them usable, but that beats having typos from manually transcribing them.
I had to create the stop mask for QFN packages out of rectangle and circle in Excel as their primitives cannot have round edge on one side and square on the other. Wish they would also let you control how far the stop mask is going over a pad and how much percentage the cream mask overage is.
“Most of the popularity is probably due to the incredible amount of part libraries – it’s certainly not the features Eagle has to offer..”
I assure you, its not. You think people like myself – an openly-out open-source zealot since Linux kernel 0.96 – payed > $1K for Eagle because of built-in parts libraries that I have never used? It’s because of a) features KiCad still does not or did not have like like real-time forward/back annotation, and b) because the user interface is significantly more intuitive. When I read this article, I went back and played with KiCad for a few hours and watched about another hour worth of tutorial videos. I’m still happy with my investment. I might try the parts library again one day, but most are usually wrong.
I have been using Fritzing for making my boards but i never see it mentioned.
Is there something i am missing or is fritzing just not popular yet?
(Looks at shoes).
While fritzing lets you make PCBs easily it is missing features that a PCB designer coming from another tool would expect. In addition to this, they don’t seem to be trying to implement these features but further hone the ones they have because they seem to want to bring in new people rather then cater to the ones already on this side of the fence.
Lately I’ve been spending my free time working on a design with rotational symmetry. If it was symmetric under 90 or 180 degree rotation, it’d be simple and easy in most CAD software, but it’s not (it’s symmetric under 72 degree rotations).
As a result, I’ve actually been generating my brd and sch directly from Python. I open it in EAGLE just to get a visual on how my code is doing, but literally every bit of the layout and routing is done from Python. It’s much easier with for-loops and polar coordinates.
It occurs to me now that I should whip up a script to render the brd and sch files (without EAGLE). I could open source it as a complete text based CAD package, which produces fully EAGLE-compatible documents.
Design rule checking doesn’t seem that difficult, either. It might be very computationally intensive if written naively, but I don’t know.
You seem like a smart fellow. Why not contribute your efforts to KiCAD?
Maybe he just needs more suffocating evangelism from the Kicad community!
Last time I tried, I couldn’t get it to run on my laptop. That was a while back, but still. I spent a lot of time working out installation issues, then when I finally had it installed, I couldn’t start anything without immediate crashes. To be fair, it definitely deserves another go by now.
That was my experience with KICAD. When I tried working through tutorials the application would crash after a few steps. It is tough to learn a program when it cannot run.
@Hypoon, @pcf11 – that must have been long ago. Even if you build KiCad from the source (which has been made super easy now, even on Windows it’s just a matter of running a bat file) you’re likely to get a very stable package.
@svofski It was probably a couple of years ago now. I’m glad to hear KICAD has improved lately. Maybe in a couple of years when I’m in the mood, and give it another shot it’ll work then? I’m in no rush.
@pcf11 take your time :)
In my personal experience, it’s scary at first, but once you get into it, it’s much easier than you probably expect. There’s a very active effort by CERN (which is really one or two guys actively working on it) that adds new features, most prominently push and shove router, but also new library manager and probably a ton of smaller things. The new router is fairly raw yet, compared to FreeRouting for example, but it shows great promise.
I actually tried writing a renderer for EAGLE’s XML files which would run on Android, as a part of a single-semester class. By the end of the semester (and maaaybe forty-eighty total hours of work on it; I was a slacker), I had something which could render parts, nets, and wires (but not rotate parts). Their language is actually fairly easy to parse/draw, and I believe the only license restrictions on using it are that if you generate it, it has to be able to be loaded by their program without error.
Its great to see someone making Eagle more usable. The more I use it the more I see why its not used very much professionally. What I would love to see someone do for Eagle is implement a stretch feature like Pads and Altium have. I see that as Eagles biggest short coming as it is next to impossible to manually pack traces next to each other without having to remove and redraw traces all the time. With out this feature BGA routing is a major pain.
Between move, split and grid, you should be able to manually move tracks in Eagle. Not sure if that answered your question.
There are times that tracks are lined up with a pin not your grid (imperial vs metric) and those are the time to rip them and redraw. What would be nice is have it packing track to DRC spacing for you. Also would be nice to have the DRC clearances in real time. I have to draw lines of the right widths on document layer for that as I use 1 mil grid.
Things I miss (vs big ECAD tools) are being able to define/manage different views e.g. sometime you want to only look at top or bottom without other distraction like refdes and sometime you so want to look at refdes to make sure they are in the right place. Also being able to view from the bottom side (with left/right flipped) is useful.
If you have tracks not lined up with your grid, control-click on a track endpoint to snap it to your current grid.
Real time DRC would be wonderful.
You can create different views. Click and hold the layer button. It gives you the option to add a new view with the currently selected layers.
Having real time drc, but have to be able to switch that off too as sometime you just need to move stuff aside to work on something and not have a nanny complain about things you don’t care about.
What I mean is user predefined “views” that are saved/managed. Tried what you said, but I cannot switch back and forth between these views without it adding layers that I purposely deselected. e.g. made a top only view, but it gets overwritten with top and bottom as I switch back and forth.
Thanks for the tips on the snapping to grid. Wouldn’t have figure that one as I learnt Eagle. I have used a lot of PCB software before (and most on the job without time to read the manual either), so I have figured out most of the ones I need without bother reading manual/help/ or watching youtube tutorials.
I’m not sure why the layer view would be doing that. Try adding a MENU section to your .eaglerc file, or whatever it is on Windows if you’re on that.
A sample of my MENU section, hopefully its readable here.
’50/25 mil : GRID mil 50 alt 25 mil;’\
’25/5 mil : GRID mil 25 alt mil 5;’\
‘5/1 mil : GRID mil 5 alt 1 mil;’\
‘3/0.5 mil : GRID mil 3 alt mil .5;’\
‘Notes : GRID mil 150 alt 25 mil; CHANGE Size 70; CHANGE Ratio 8; TEXT’\
‘Unrouted : DISPLAY None Unrouted Dimension;’\
‘Ratsnest Off : DISPLAY -Unrouted;’\
‘Ratsnest On : DISPLAY Unrouted;’\
‘All : DISPLAY All;’\
Stops Off : DISPLAY -tStop -bStop; |\
tStop On : DISPLAY tStop -bStop; |\
bStop On : DISPLAY -tStop bStop; |\
Voids On : DISPLAY tRestrict tKeepout bRestrict bKeepout vRestrict; |\
Voids Off : DISPLAY -tRestrict -tKeepout -bRestrict -bKeepout -vRestrict; |\
Clear Mark : MARK; |\
‘tSilk Algn (O) : DISPLAY None Pads Vias Dimension tOrigins tPlace tName tStop;’\
‘bSilk Algn (O) : DISPLAY None Pads Vias Dimension bOrigins bPlace bName bStop;’\
#- End Menu
I forgot to mention that you have to have ‘Command Texts’ on in the Options -> User Interface settings to see the menu. You can also add right-click menu commands for various objects. See ‘HELP SET’ for info on that, or I can post more of my .eaglerc file if need be.
yes the tracks can lengthen and shorted as you move the end points or a segment.
why eagle returns syntax error on line 47?
string PYTHON_EXECUTABLE = “C:\Python\Python27\pythonw.exe”;
path is correct.
Eagle works here on Linux. Although to be completely up front I did have to wrap it in a shell script for it to run on this system. It needed different versions of some libraries than I have. I probably could have just written an alias to do it too.
You need a semicolon on the line above..
Please be kind and respectful to help make the comments section excellent. (Comment Policy)