element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet & Tria Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Autodesk EAGLE
  • Products
  • More
Autodesk EAGLE
EAGLE User Chat (English) Cadsoft Eagle with Python Scripting
  • Blog
  • Forum
  • Documents
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Autodesk EAGLE to participate - click to join for free!
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • Replies 54 replies
  • Subscribers 183 subscribers
  • Views 9821 views
  • Users 0 members are here
Related

Cadsoft Eagle with Python Scripting

Former Member
Former Member over 12 years ago

Hi,

 

I've only started using Eagle a few weeks ago, and as much as I like it, I have found what I consider some pretty fundamental features just missing. As the built in scripting language is extremely restrictive (when compared to a 'real' language like python, lua or ruby), I made an attempt to get python running with Eagle.

 

http://www.youtube.com/watch?v=_w7CECR7Dv8

 

The above is a video of a project I have been working on for the pas 3-4 days, which basically involves exposing the Cadsoft ULP and SCR to python (albeit in not the fastest way). But it does allow me to now use 90% of the ULP and all of the SCR directly from python, including the Object Heirarchies, board.grid... schematic... which have all be exposed in a pythonic way.

 

as an example, to get all the Instances in the schematic..

 

instances = Eaglepy.ULSchematic().instances()

 

or loop,

 

for instance in Eaglepy.ULSchematic().instances():

     print instance.name()

 

etc..

 

The tools in the video were very quick to knock out.. the slowest bit was figuring out the papers for approximating cubic/quadratic bezier curves with arcs, for the DXF Importer. These should be the first of many tools to come, next on the list is a group manager so I can save my selectsion.

 

Hopefully when I have had time to test this a bit more I will release the code to the community, along with any tools I have built. for others who might want this funtionality. (something that should be out of the box with proper bindings to a proper language imo...)

 

Cheers

 

Rob.

  • Sign in to reply
  • Cancel
  • AnalogNotes
    AnalogNotes over 11 years ago in reply to Former Member

    Sorry guys, I got side-tracked with work again.  I finally figured out how to make the repository public:

     

    https://bitbucket.org/AnalogNotes/eagle-python

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • autodeskguest
    autodeskguest over 11 years ago in reply to AnalogNotes

    Doug Wellington scribbled thus:

     

    Sorry guys, I got side-tracked with work again.  I finally figured out

    how to make the repository public:

     

    https://bitbucket.org/AnalogNotes/eagle-python

     

    --

    To view any images and attachments in this post, visit:

    http://www.element14.com/community/message/118779

     

    NO !  It requires a password and login name...

     

    --

    Best Regards:

                          Baron.

     

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • Former Member
    Former Member over 11 years ago in reply to autodeskguest

    Look at the post above Dougs. I got round to cleaning up, and putting it on github myself.. I asked Doug to remove the version I sent him, to ease confusion.

     

    Here is the complete code.

     

    https://github.com/rmawatson/PyEagle

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • AnalogNotes
    AnalogNotes over 11 years ago in reply to autodeskguest

    Baron wrote:

    NO !  It requires a password and login name...

     

    Sorry mate, Robin's original message didn't get propagated to the NNTP group and for some reason, even though he posted after me, his message shows up before mine on the Element14 forum.  If I had known that he was putting a repository up, I wouldn't have made mine public.  Once he created his, I set mine back to private.  Since he's the author of the code, it's better that you use his repo...

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • autodeskguest
    autodeskguest over 11 years ago in reply to AnalogNotes

    Doug Wellington scribbled thus:

     

    Baron wrote:

     

    NO !  It requires a password and login name...

     

    Sorry mate, Robin's original message didn't get propagated to the NNTP

    group and for some reason, even though he posted after me, his message

    shows up before mine on the Element14 forum.  If I had known that he

    was putting a repository up, I wouldn't have made mine public.  Once

    he created his, I set mine back to private.  Since he's the author of

    the code, it's better that you use his repo...

     

    --

    To view any images and attachments in this post, visit:

    http://www.element14.com/community/message/118806

     

    OK !  Thanks for update.

     

    --

    Best Regards:

                          Baron.

     

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • autodeskguest
    autodeskguest over 11 years ago in reply to Former Member

    Hi Robin

     

    That's a lot of work you have done.

    Thanks for sharing

     

    Warren

    --

    Web access to CadSoft support forums at www.eaglecentral.ca.  Where the CadSoft EAGLE community meets.

     

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • Former Member
    Former Member over 11 years ago

    Excellent work!

     

    I've been trying to import eagle schematics into Python now that they in XML format.

     

    So far I have a script that can import and return iterable objects for layers and parts.

    segments can be itstill need some work

    libraries are broken.

     

    If this is at all helpful, you can find it here:

    https://github.com/uid89626/Eagle

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • autodeskguest
    autodeskguest over 11 years ago in reply to Former Member

    That's great foxx00!

     

    Here are a couple quick tools I wrote to explore EAGLE files.  The first is

    a short Python script that just displays the top few node levels.  Save it

    to an executable file (add a shebang if you need it) and put the EAGLE file

    name on the command line:

     

    import sys

    import xml.etree.ElementTree as ET

     

    if len(sys.argv)  - read EAGLE XML file" % sys.argv[0]

      sys.exit()

     

    input_file = sys.argv[1]

    try:

      input_string = open(input_file).read()

    except:

      print "Couldn't read %s..." % input_file

      sys.exit()

     

    try:

      tree = ET.fromstring(input_string)

    except:

      print "Couldn't parse file, is this an EAGLE 6 document?"

      sys.exit()

     

    print "%s consists of:" % input_file

    for child in tree:

      print child.tag

      for grandchild in child:

        print "  ", grandchild.tag

        if grandchild.tag == "schematic" or grandchild.tag == "board":

          for greatgrandchild in grandchild:

            print "    ",  greatgrandchild.tag

     

    I've been playing around with functional programming lately, so the second

    is a quick Scala (Scala is rapidly becoming my favorite language!) script

    that gives you node sequences for each of the main file sections, along

    with a couple examples of iterating through them (the filename is

    hard-coded in this one at the moment, sorry):

     

    import xml.XML

     

    val fileName  = "test.brd"

    val eagleFile = XML.loadFile(fileName)

     

    // search for drawing node, then for each child node

    // length is zero if not found (e.g. you won't find a

    // schematic in a board file...).  Comment out as

    // desired to speed things up.

    val settings  = eagleFile \ "drawing" \ "settings"

    val grid      = eagleFile \ "drawing" \ "grid"

    val layers    = eagleFile \ "drawing" \ "layers"

    val board     = eagleFile \ "drawing" \ "board"

    val schematic = eagleFile \ "drawing" \ "schematic"

     

    print("\n\nUsing xpath to search for layers:\n\n")

    for (l <- layers \ "layer" ) println(l)

    println

     

    val allLayers = (layers
    "layer")

    print("\n\nNow iterating through layers in a loop:\n\n")

    allLayers.foreach{ l =>

      val layerNumber = (l \ "@number").text

      val name = (l \ "@name").text

      val visible = (l \ "@visible").text

      println(s"Layer $layerNumber, $name, is visible: $visible")

    }

     

    I've been using XML Copy Editor and Firstobject XML Editor to display and

    edit the files...

     

    Regards,

    Doug

    --

    Web access to CadSoft support forums at www.eaglecentral.ca.  Where the CadSoft EAGLE community meets.

     

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • Former Member
    Former Member over 11 years ago in reply to AnalogNotes

    Doug Wellington wrote:

     

    Sorry guys, I got side-tracked with work again.  I finally figured out how to make the repository public:

     

    https://bitbucket.org/AnalogNotes/eagle-python

    Doug,

     

    When I click on the link (I am already logged into my Bitbucket account), I get the following message:

     

    You do not have access to this repository.

    Use the links at the top to get back.

     

    ----------

    Second question:

    Do these links contain the same content?

    https://bitbucket.org/AnalogNotes/eagle-python vs https://github.com/rmawatson/PyEagle

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • autodeskguest
    autodeskguest over 11 years ago in reply to Former Member

    Anton,

     

    You can find the repository at http://https://github.com/rmawatson/PyEagle

     

    Regards,

    Doug

    --

    Web access to CadSoft support forums at www.eaglecentral.ca.  Where the CadSoft EAGLE community meets.

     

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
<>
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube