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
    About the element14 Community
  • 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
      •  Japan
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      •  Vietnam
      • 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 Support (English) Rename wires
  • 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
  • State Suggested Answer
  • Replies 34 replies
  • Answers 2 answers
  • Subscribers 189 subscribers
  • Views 5563 views
  • Users 0 members are here
Related

Rename wires

e14 Contributor
e14 Contributor over 12 years ago

Hello,

 

In an Eagle-shematic (50 pages) I need to change quite a lot of wire names. Select every single and change the name would do the job, but is quite time consuming...

 

The wires can have diferent names, some examples:

W500/01

W500/02

W500/xx

...

W501/01

W501/02

...

W502/01

...

W600/01

W600/02

...

W601/01

...

W700/BN

W700/BU

...

W135/1.5RD

...

 

Now as writen before, a lot of wire names should be changed. For example all W500/xx will be renamed to W512/xx and so on. Can somebody tell me how I can do that a bit more eficient? I tried this one: Renaming parts in Eagle CAD by editing the XML directly

Works quite well for part names, but the wire names are not recognised by this tool. I would have to change the source code (I think I'd be able to do that) and then recompile that, but I have no Idea about C++ and how to compile...

 

So it would be great if somebody had another simple and working idea how to do that.

 

Thank you

 

My configuration:

Eagle 6.5.2 Hobbyist licence

Win 8.1

  • Sign in to reply
  • Cancel
Parents
  • AnalogNotes
    0 AnalogNotes over 12 years ago

    Well, I'm going to show my Unix bias here, but there are a *lot* of tools available to do things like this built in to Linux and OS X and available for Windows.  It depends how deep you want to go down the rabbit hole!

     

    My first reaction would be to use "sed" the stream editor.  (Do a search for "sed for windows".)  Sed is used at the command line, and takes some input, modifies it, and sends it to some output.  For example,

     

    sed 's/W500/W512' schematic.sch > newschematic.sch

     

    which would change occurrences of W500 to W512 and create a new file called newschematic.sch without changing the original schematic.sch.  To make sure things look good, you could use the "diff" command on the two files to see exactly what was changed.  Of course, you wouldn't want to have to change that command line and re-run it for every substitution you want to make, so it's better to create a sed script file with all the commands you want (somewhat analogous to that CSV file in the referenced article), and then run the command:

     

    sed -f script.file schematic.sch > newschematic.sch

     

    Sed is a great tool and can be used over and over again without having to modify and recompile.  Now, if you want to learn something a little more sophisticated, there is a simple, yet amazing text processing language called AWK.  AWK knows how to read in a text file line by line, split the line into words and do things to those words.  You can do more testing and manipulating than you can in sed.  AWK is very much like the C programming language, so you can do things like printf to create new output.  Then, if you want to really go down the rabbit hole and get into more powerful scripting languages, the big three in my book are PERL, Python and Ruby.  Each has strengths and weaknesses and each has devout followers and detractors.  Let me know if you're interested or do a search to learn more...

     

    BTW, if you don't want to download and install any of these unix tools, you might consider using Windows PowerShell too...

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Reject Answer
    • Cancel
  • e14 Contributor
    0 e14 Contributor over 12 years ago in reply to AnalogNotes

    Thank you for your help.

     

    after some tests I found out that Win doesn't like the following command:

    sed 's/W500/W5000' 30c.sch 30d.sch

    But the following seems to work so far (thank you google):

    sed "s/W500/W5000/" 30c.sch 30d.sch


    Well, first everything seems to work fine, it reads and schows all data in the 30c file, but after everything has finished, the 30d.sch is still empty. Any idea what I am doing wrong? Sorry I have to admit that I'm not the shell-guy...

     

    As for the advice with the inconsistent board: Thank you for your advice, but there is no board, only the schematic. It is the shematic of my newly build camper. I know, eagle may not be the best solution for doing that, but works so far ok for me...

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • AnalogNotes
    0 AnalogNotes over 12 years ago in reply to e14 Contributor

    You need a greater than sign before the last file name.  The greater than sign is basically an arrow pointing to where the output should go...

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Reject Answer
    • Cancel
  • autodeskguest
    0 autodeskguest over 12 years ago in reply to AnalogNotes

    On 04/03/14 20:02, Doug Wellington wrote:

     

     

    That's English for "wise man who speaks truth"

    image

     

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • AnalogNotes
    0 AnalogNotes over 12 years ago in reply to autodeskguest

    Sorry to continue the off-topic hijack, but that's how these forum things seem to work...  image

    Lorenz wrote:

    There is a nice quote regarding nntp vs. web bases forums:

    Web based forums are like subscribing to 10 different newspapers and

    having to visit 10 different news stands to pickup each one. Email

    list-server groups and USENET are like having all of those newspapers

    delivered to your door every morning.

    I follow about 30-40 news groups and mailing list (using gmane.org as

    mailing list to nntp bridge) regularly.

     

    That wouldn't be possible using web based forums.

    Using my new client I can skim over the new posts during my morning

    coffee break.

     

    [curmudgeon]

    Indeed.  I've always hated forums, but it's the way of the world now for most of the topics I seem to be interested in.  I used to, and still do, love listservs (remember Bitnet?) and newsgroups because, as you say, they come to you instead of you having to remember to go to them.  It all seemed so simple back then.  I'm an old MH user too, so I have a *huge* directory structure of messages from both email and nntp.  Of course, for me at least, email isn't the best answer any more, as most people don't edit much, they just pile answers on top of the previous message(s) and most of them are RTF or HTML (in other words, much larger than they need to be).  How many times have you gotten a 90k message that only adds "+1" to all the previous quotes?  image  Forums like this seem to be nicer in that regard, as you have to explicitly click a button to quote the previous message...

    [/curmudgeon]

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • autodeskguest
    0 autodeskguest over 12 years ago in reply to AnalogNotes

    Doug Wellington wrote:

     

    CadSoft Guest (aka Lorenz) wrote:

     

    since when is element14 suppressing the sender of newsgroup post?

     

    Yeah, this site is a bit wonky, eh?  Do you post from the Stratford

    Digital EagleCentral site or do you post directly via NNTP?  I finally

    gave up on those and use Element14 because I can edit posts.  The down

    side is that the Jive software Element14 uses really just seems to

    suck.  For example, when I click on the "CadSoft Guest" title at the top

    of your message, it is linked to Drew Fustini, and I'm guessing you

    aren't Drew!  As far as I can tell, post edits don't propagate off this

    site, and in general, things are hard to find, which may be more of an

    organization thing than a Jive thing, but it doesn't reflect well on

    either.  There's a webinar about the site in less than an hour, so maybe

    things will clear up a bit...

     

    I'm posting directly via nntp (since I started using eagle, long long

    before farnell bought cadsoft).

     

     

    There is a nice quote regarding nntp vs. web bases forums:

     

    Web based forums are like subscribing to 10 different newspapers and

    having to visit 10 different news stands to pickup each one. Email

    list-server groups and USENET are like having all of those newspapers

    delivered to your door every morning.

     

     

    I follow about 30-40 news groups and mailing list (using gmane.org as

    mailing list to nntp bridge) regularly.

     

    That wouldn't be possible using web based forums.

    Using my new client I can skim over the new posts during my morning

    coffee break.

    --

     

    Lorenz

     

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • AnalogNotes
    0 AnalogNotes over 12 years ago in reply to autodeskguest

    CadSoft Guest wrote:

    since when is element14 suppressing the sender of newsgroup post?

     

    Yeah, this site is a bit wonky, eh?  Do you post from the Stratford Digital EagleCentral site or do you post directly via NNTP?  I finally gave up on those and use Element14 because I can edit posts.  The down side is that the Jive software Element14 uses really just seems to suck.  For example, when I click on the "CadSoft Guest" title at the top of your message, it is linked to Drew Fustini, and I'm guessing you aren't Drew!  As far as I can tell, post edits don't propagate off this site, and in general, things are hard to find, which may be more of an organization thing than a Jive thing, but it doesn't reflect well on either.  There's a webinar about the site in less than an hour, so maybe things will clear up a bit...

     

    strxstr?  Do we want to give this poor guy a brain cramp already?

    LOL!!! [...]

     

    I know 8-)

     

    I only mentioned it for completeness sake while pointing out that

    there are more possibilities beside strchr and substr

     

    Thanks.  Yeah, TIMTOWTDI as the Perl guys say...

     

    The fun thing is, when we come full circle in this discussion, we'll get back to sed, which is actually a great regular expression tool...  image

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • autodeskguest
    0 autodeskguest over 12 years ago in reply to AnalogNotes

    Doug Wellington wrote:

    CadSoft Guest wrote:

     

    since when is element14 suppressing the sender of newsgroup post?

     

     

    also have a look at strxstr, strrchr and strsplit / strjoin  could be

    an alternative

     

    strxstr?  Do we want to give this poor guy a brain cramp already? 

    LOL!!! [...]

     

    I know 8-)

     

    I only mentioned it for completeness sake while pointing out that

    there are more possibilities beside strchr and substr

    --

     

    Lorenz

     

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • AnalogNotes
    0 AnalogNotes over 12 years ago in reply to autodeskguest

    CadSoft Guest wrote:

    also have a look at strxstr, strrchr and strsplit / strjoin  could be an alternative

     

    strxstr?  Do we want to give this poor guy a brain cramp already?  LOL!!!

     

    Some people, when confronted with a problem, think “I know, I'll use regular expressions.” Now they have two problems.  -Jamie Zawinski*

     

    For the unknowing/unsuspecting, strxstr() is a very powerful function that uses a thing called a "regular expression" to search for a pattern of characters.  I think the line I quoted from Jamie is hilarious, but I actually *LOVE* regular expressions.  We use them in text processing, for example, building a compiler, which is one of the most advanced things you can do in computer science.  I taught a class on regular expressions and there are entire books devoted to just regular expressions.  image

     

    *There is a humorous web site devoted to this kind of quote: Two Problems

     

    EDIT: Here's an example of a regular expression ("regex"):

     

    ^[ \t]+|[ \t]+$

     

    quoted from Wikipedia: Regular expression  image

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • autodeskguest
    0 autodeskguest over 12 years ago in reply to AnalogNotes

    Doug Wellington wrote:

    Ursicin Caminada wrote:

     

    To keep the last part of the name the same, you will have to use the

    string functions of EAGLE.  First, use the strchr() function to find the

    location of the "/" character, then use the strsub() function to extract

    the last part of the string, so etwas:

     

    also have a look at strxstr, strrchr and strsplit / strjoin  could be

    an alternative

    --

     

    Lorenz

     

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • e14 Contributor
    0 e14 Contributor over 12 years ago in reply to AnalogNotes

    Wow, thank you for your huge work and patience.

     

    Unfortunately it doesn't look like a 5-minute-job to try out image I'll try to go through that step by step, but that has to wait till tomorrow evening. You know, there are such unimportant things like work, sleeping and so on who have to be done as well image

     

    I really apreciate your help and how you explain it step by step. Like that I have a small chance in understanding what I'm doing... Thank you very much.

     

    Good night

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • AnalogNotes
    0 AnalogNotes over 12 years ago in reply to AnalogNotes

    OK, let's look at how we would loop through everything.  In a previous message, I talked about how EAGLE can loop through every sheet of a schematic.  Let's make a test to see how that works.  Create a new ULP or you can use the one we created in the last message and delete everything in it.  Let's start with this code, so copy and paste this into the ULP:

     

    string sheetname;

    string message;

     

    schematic(S){

      S.sheets(SH){

        sprintf(sheetname, "Sheet: %d\n", SH.number);

        message += sheetname;

      }

    }

    dlgMessageBox(message);

     

    Save it and then run it by clicking the ULP button, or you can type "run" and the filename at the command line in the schematic.  (I called my ULP "rename.ulp", so I type "run rename.ulp" and press the enter key.)  You should get a dialog box with a line for every page of the schematic.  EAGLE dialog boxes are not very smart, so it may extend below the bottom of the screen.  Press the escape key or the space bar or click on the close button of the window.

     

    Now, let's make a list of all the nets on each page of the schematic.  Add in these lines after "message += sheetname;":

     

    SH.nets(N){

      message += N.name;

      message += " ";

    }

    message += "\n";

     

    The important things to know here are that we are going through all of the nets on the schematic page, and when we are using each one, it is called "N".  We add the name of the net to the message, then to make it readable, we are adding a space (" ").  After each page, we are adding a new line ("\n") to separate the pages.  So the whole thing should look like:

     

    string sheetname;

    string message;

     

    schematic(S){

      S.sheets(SH){

        sprintf(sheetname, "Sheet: %d\n", SH.number);

        message += sheetname;

        SH.nets(N){

          message += N.name;

          message += " ";

        }

        message += "\n";

      }

    }

    dlgMessageBox(message);

     

    Save that and run it.  Do you see all of the names of your wires?  If not, we are looking in the wrong place.  Let me know and we will try something else.  If you do see the names that you want to change, then we can proceed.

     

    Now it's time to add in the name changing code from my last message.  Let's remove the space and newline entries first, then we need to define some more variables:

     

    string oldname;

    string newname;

    string lastpart;

    char c = '/';

    int number = 100;

    int position;

     

    Put those lines below the sheetname and message variables.  Now the name changing lines:

     

    oldname = N.name;

    position = strchr(oldname, c);

    lastpart = strsub(oldname, position);

    sprintf(newname, "W%d", number);

    newname += lastpart;

    number += 1;

     

    Do you see how I got oldname from the name of the net this time?  The last line here is the magic bit that makes the wire number count up.  Now, let's put in the lines that show what we have done so far in the dialog box.  The whole thing should be:

     

    string sheetname;

    string message;

    string oldname;

    string newname;

    string lastpart;

    char c = '/';

    int number = 100;

    int position;

     

    schematic(S){

      S.sheets(SH){

        sprintf(sheetname, "Sheet: %d\n", SH.number);

        message += sheetname;

        SH.nets(N){

          oldname = N.name;

          position = strchr(oldname, c);

          lastpart = strsub(oldname, position);

          sprintf(newname, "W%d", number);

          newname += lastpart;

          number += 1;

          message += "Rename old: ";

          message += oldname;

          message += " to new: ";

          message += newname;

          message += "\n";

        }

      }

    }

    dlgMessageBox(message);

     

    Run that and see if that looks like what you are trying to accomplish.  In the next message, I'll show you how to generate the script that actually renames everything...

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • AnalogNotes
    0 AnalogNotes over 12 years ago in reply to e14 Contributor

    Ursicin Caminada wrote:

    Win fit? Hmm, not sure how this special command would help me on that right now...for that I use Ctrl+F2...But while I'm writing about; is it just to tell me there are powerfull commands in Eagle?

     

    Yes, that is just to point out that there are many powerful commands and learning them is a good thing.  Every command can be started from the command line instead of just the mouse...

     

    I think you understood me a bit wrong. I don't want to rename based on the page number.

    Right now I have the following (just an example):

                               Now                       Should be

    W100/1.5RD  on page 27                  1. W1xx wire on page 01

    W101/1.5RD  on page 32                  2. W1xx wire on page 01

    W102/50RD  on page 01                   3. W1xx wire on page 01

    W103/50BK  on page 45                   1. W1xx wire on page 02

    W104/1.5OR  on page 26                 2. W1xx wire on page 02

    W105/xxxx  on page 14                    1. W1xx wire on page 03

    ...                                                     ...

    W149/1.5OR  on page 06                  5. W1xx wire on page 26

    W150/1.5OR  on page 01                  1. W1xx wire on page 27

     

    Yes, I must be misunderstanding, because it is looking to me like you rename all the wires starting on page one, then going to page two, then three...

     

    Now the old W100 (on page 27) will be renamed to, W150 (assumed it is the 150iest W1xx wire in the shematic). But the last part of the name should be kept as it was before. The last part of the name is the dimension and the color of the wire, so it should stick to that wire where it is right now. So new we would have:

    W100/1.5OR  on page 01 (because the wire on Page 01 is a 1.5OR)

    W150/1.5RD  on page 27 (because the wire on page 27 is a 1.5RD)

     

    To keep the last part of the name the same, you will have to use the string functions of EAGLE.  First, use the strchr() function to find the location of the "/" character, then use the strsub() function to extract the last part of the string, so etwas:

     

    string oldname = "W154/1.5OR";

    char c = '/';

    int position = strchr(oldname, c);

    string lastpart = strsub(oldname, position);

     

    Now, lastpart should be "/1.5OR".  You can test this by going to the EAGLE control panel, then File->New->ULP and copy this and save it:

     

    string oldname = "W154/1.5OR";

    char c = '/';

    int position = strchr(oldname, c);

    string lastpart = strsub(oldname, position);

    dlgMessageBox(lastpart);

     

    Now open your schematic and then click the ULP button and choose the file you just saved.  the dlgMessageBox command will open a dialog box that should say "/1.5OR" and have an OK button.

     

    To generate the full new name, use the "sprintf" command, so:

     

    int number = 100;

    string newname;

    sprintf( newname, "W%d", number);

     

    Now, newname is "W100".  Then, add the last part to the wire name with "+=", so:

     

    newname += lastpart;

     

    Test:

     

    int number = 100;

    string oldname = "W154/1.5OR";

    char c = '/';

    int position = strchr(oldname, c);

    string lastpart = strsub(oldname, position);

    string newname;

    sprintf(newname, "W%d", number);

    newname += lastpart;

    dlgMessageBox(newname);

     

    OK, lunch time.  I will post later about how to use this in a loop to process all wires...

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
Reply
  • AnalogNotes
    0 AnalogNotes over 12 years ago in reply to e14 Contributor

    Ursicin Caminada wrote:

    Win fit? Hmm, not sure how this special command would help me on that right now...for that I use Ctrl+F2...But while I'm writing about; is it just to tell me there are powerfull commands in Eagle?

     

    Yes, that is just to point out that there are many powerful commands and learning them is a good thing.  Every command can be started from the command line instead of just the mouse...

     

    I think you understood me a bit wrong. I don't want to rename based on the page number.

    Right now I have the following (just an example):

                               Now                       Should be

    W100/1.5RD  on page 27                  1. W1xx wire on page 01

    W101/1.5RD  on page 32                  2. W1xx wire on page 01

    W102/50RD  on page 01                   3. W1xx wire on page 01

    W103/50BK  on page 45                   1. W1xx wire on page 02

    W104/1.5OR  on page 26                 2. W1xx wire on page 02

    W105/xxxx  on page 14                    1. W1xx wire on page 03

    ...                                                     ...

    W149/1.5OR  on page 06                  5. W1xx wire on page 26

    W150/1.5OR  on page 01                  1. W1xx wire on page 27

     

    Yes, I must be misunderstanding, because it is looking to me like you rename all the wires starting on page one, then going to page two, then three...

     

    Now the old W100 (on page 27) will be renamed to, W150 (assumed it is the 150iest W1xx wire in the shematic). But the last part of the name should be kept as it was before. The last part of the name is the dimension and the color of the wire, so it should stick to that wire where it is right now. So new we would have:

    W100/1.5OR  on page 01 (because the wire on Page 01 is a 1.5OR)

    W150/1.5RD  on page 27 (because the wire on page 27 is a 1.5RD)

     

    To keep the last part of the name the same, you will have to use the string functions of EAGLE.  First, use the strchr() function to find the location of the "/" character, then use the strsub() function to extract the last part of the string, so etwas:

     

    string oldname = "W154/1.5OR";

    char c = '/';

    int position = strchr(oldname, c);

    string lastpart = strsub(oldname, position);

     

    Now, lastpart should be "/1.5OR".  You can test this by going to the EAGLE control panel, then File->New->ULP and copy this and save it:

     

    string oldname = "W154/1.5OR";

    char c = '/';

    int position = strchr(oldname, c);

    string lastpart = strsub(oldname, position);

    dlgMessageBox(lastpart);

     

    Now open your schematic and then click the ULP button and choose the file you just saved.  the dlgMessageBox command will open a dialog box that should say "/1.5OR" and have an OK button.

     

    To generate the full new name, use the "sprintf" command, so:

     

    int number = 100;

    string newname;

    sprintf( newname, "W%d", number);

     

    Now, newname is "W100".  Then, add the last part to the wire name with "+=", so:

     

    newname += lastpart;

     

    Test:

     

    int number = 100;

    string oldname = "W154/1.5OR";

    char c = '/';

    int position = strchr(oldname, c);

    string lastpart = strsub(oldname, position);

    string newname;

    sprintf(newname, "W%d", number);

    newname += lastpart;

    dlgMessageBox(newname);

     

    OK, lunch time.  I will post later about how to use this in a loop to process all wires...

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
Children
  • AnalogNotes
    0 AnalogNotes over 12 years ago in reply to e14 Contributor

    I have been busy with other things too.  My son competed in a track meet and then he was home from college for spring break.  (He was third place in discus and hammer and fourth place in shotput.  It was only the second time he has competed at the college level.  I'm very proud!)

     

    I should have time in the next days to look at that script again.  I will let you know what I come up with...

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • e14 Contributor
    0 e14 Contributor over 12 years ago in reply to AnalogNotes

    Hi Doug,

     

    Sorry, I was a bit busy with other projects during the last 2 Weeks. This weekend I finally tried a little bit around on that again.

    As said before, I don't really know much about programming scripts, so if something works it is more or less accidentally ;-) Anyway, so far I have renamed all N$xx, and all WXXX in the higher range (W5xx-W9xx) with a combination of sed, your script and the c++ programm mentioned earlier in this thread (to export, rename manually and reimport).
    So far I am a big step further.

    Unfortunately I still don't get how to change the W1xx so they will start with W100 and continue one after the other, especially the problem that it renames the wire again if it is on more than one page is the biggest concern I have.

     

    I was afraid something like that might happen.  I think the answer will be to add each name to a list of the old names that we are going to change.  If we find the name again on a later page, we should ignore it.

    Do you have any piece of script doing that?

     

    Thx a lot

    Ursicin

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • AnalogNotes
    0 AnalogNotes over 12 years ago in reply to e14 Contributor

    Ursicin Caminada wrote:

    As long no wires start on one page and continue on another everything works great, but as soon the wires go to another page I get problems.

    [...]

    Is there any chance to correct this without to much work?

     

    I was afraid something like that might happen.  I think the answer will be to add each name to a list of the old names that we are going to change.  If we find the name again on a later page, we should ignore it.  This will apply to the N$xx nets as well...

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • e14 Contributor
    0 e14 Contributor over 12 years ago in reply to e14 Contributor

    While trying on in the original schematic I found an iussue:

    As long no wires start on one page and continue on another everything works great, but as soon the wires go to another page I get problems.

    As soon the Wires are continuing over more than one page, the script reserves a number for each section on each page. If I then chose to change name on all pages, I get a gap in numbering...hard to describe...

    Lets say the I'd like to get the new numbers as following:

    W100 on page 1

    W101 on page 1, continuing on page 3

    W102 on page 2, continuing on page 3

    W103 on page 2, continuing on page 3

    W104 on page 4

    W105 on page 4

    ...

     

    Now I get:

    W100 on page 1

    W101 on page 1, continuing on page 3 (on page 3 it asks me if I want to change W101 again, now to W104)

    W102 on page 2, continuing on page 3 (on page 3 it asks me if I want to change W102 again, now to W105)

    W103 on page 2, continuing on page 3 (on page 3 it asks me if I want to change W103 again, now to W107)

    W107 on page 4

    W108 on page 4

    ...

    (W101-103 are not used anymore)

     

    Is there any chance to correct this without to much work?

    Thanks

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • AnalogNotes
    0 AnalogNotes over 12 years ago in reply to e14 Contributor

    Ursicin Caminada wrote:

    Wow, thank you very much for your huge work.

     

    When I was reading about clicking, I was a bit concerned...clicking on every net...I wasn't aware that the ULP script can click as well. Anyway, you as a "unix-guy" wouldn't click on every wire, would you? ;-)

     

    You are welcome!  It was fun to figure out how to do it.  As a Unix guy, I believe in being lazy and making the computer do all the work! image

     

    Do you know what name will be given after all W1xx are used, will it go from W199/xx to W200/xx, W201/xx?

     

    Yes, the name will count up as far as it needs to for all the names.  It will go from 199, 200, 201,...,299, 300,...

     

    I tried to figure out what you are doing exactly, but especially for the following lines It would be nice if you cold give a short explanation (only if you have the time for it!):

     

    sprintf(line, "edit .s%d;\n", SH.number);

    sprintf(line, " (%f %f);\n", u2inch(W.x1), u2inch(W.y1));

    position = strchr(oldname, c);

    oldnumber = strsub(oldname, 1, position);

     

    I think the first 2 lines are some of these regular expressions? But what are they exactly doing?

    And what are the last 2 lines doing?

     

    In languages like "C", there is a command to print formatted output, "printf".  Instead of regular expressions, printf uses what is called a template language.  You create the format string that you want to print and put in format specifiers.  Sometimes we don't use any format specifiers at all, for example many C programming books start with the "Hello world" program, which says something like:

     

    printf("hello, world");

     

    Format specifiers are used to display variables.  If you want to display a decimal, like the number of the schematic page, you would need to use the specifier "%d", and then list the name of the variable after a comma.  So, with the format string "%d" and the variable SH.number, the command would be:

     

    printf("%d", SH.number);

     

    In the first line above, I wanted to create a string for the script that says "edit .s1;" or "edit .s2;" for each page of the schematic, so I used the %d in place of the number in the format string and the value of SH.number was substituted into that part of the output.  To put that string on its own line in the script, I put "\n" at the end of the format screen.  That gets replaced by the newline (return) character.

     

    You can see that there is an "s" in front of the printf, it is a different version of the command and it prints formatted output into a string.  In this case, the output is put into the "line" string variable.  I used the line variable as a temporary place to make the command, and then I added that to the end of "script" with the "script += line;" part.  If I had used sprintf to write directly to the script, everything already there would have been erased.

     

    The second line is very similar, but I used "%f" for a floating point number instead of a decimal.  The nice thing about printf and sprintf is that you can use commands instead of just variables, so the first %f is substituted with the output from the command "u2inch(W.x1)" and the second %f is substituted with the output from the command "u2inch(W.y1)".  These convert from the EAGLE internal units to inches.  I could have used other units, but I was lazy and since I'm in the US, I stayed with inches.  The important thing is to match the unit conversion with the grid specification so that the mouse clicks are put in the correct location.

     

    The last two lines are string functions.  The first one uses the "strchr" command to look for a character in a string.  In this case, we look for the contents of "c" which is a slash ("/") in the string "oldname".  The location is put into the variable "position".  The interesting/weird thing about ULP and other languages like C is that everything starts with zero as the first number.  So, if the slash was the first character of oldname, position would be 0.  If the slash was the second character, position would be 1...

     

    The last line uses the "strsub" command to pull a substring (part of a string) out of another string.  In this case, I am pulling a substring starting at 1 and going to "position".  I cheated a little here because I was planning that the first character in "oldname" is a "W", so I didn't want to start at 0 which would have included the "W", instead I started at 1, which is the next place after the W.  If oldname was "W128/1.5OR", this substr command would pull out "128" and put it into "oldnumber".  After that, I used the command "strtol" to convert that string of characters into a number that I could use in the range test.  (The string "100" is different from the number 100.)

     

    Can this script simply be changed, so it would rename a part (or all) of the N$xxx named wires to W1xx or W2xx or something like that? I was trying some things but right now I wasn't able to get that working... But please don't put to much work into that! If it is a simple thing ok, if not it's not that important!

    ...but while I am writing, I should maybe try sed for that again... Let's see if I find some time to try a few things on that during the weekend.

     

    Thank you very much and have a nice weekend.

     

    The script can definitely be changed for that.  I would use the strstr() function to look for the N$ in "oldname".  Something like:

     

    string prefix = "N$";

    position = strstr(oldname, prefix);

    if (pos >= 0) {

    // starts with N$, do the rename here...

    }

     

    If I have time this weekend, I will modify the script to do that.  It will probably take less than ten minutes...

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • e14 Contributor
    0 e14 Contributor over 12 years ago in reply to AnalogNotes

    Wow, thank you very much for your huge work.

     

    When I was reading about clicking, I was a bit concerned...clicking on every net...I wasn't aware that the ULP script can click as well. Anyway, you as a "unix-guy" wouldn't click on every wire, would you? ;-)

     

    I was trying your script and it looks very nice. As far I can say right now everything works like it should. Great. Thank you very much, you made it very easy to chenge all my wire-names.

    Do you know what name will be given after all W1xx are used, will it go from W199/xx to W200/xx, W201/xx?

     

    I tried to figure out what you are doing exactly, but especially for the following lines It would be nice if you cold give a short explanation (only if you have the time for it!):

    sprintf(line, "edit .s%d;\n", SH.number);

    sprintf(line, " (%f %f);\n", u2inch(W.x1), u2inch(W.y1));

    position = strchr(oldname, c);

          oldnumber = strsub(oldname, 1, position);

     

    I think the first 2 lines are some of these regular expressions? But what are they exactly doing?

    And what are the last 2 lines doing?

     

    Can this script simply be changed, so it would rename a part (or all) of the N$xxx named wires to W1xx or W2xx or something like that? I was trying some things but right now I wasn't able to get that working... But please don't put to much work into that! If it is a simple thing ok, if not it's not that important!

    ...but while I am writing, I should maybe try sed for that again... Let's see if I find some time to try a few things on that during the weekend.

     

    Thank you very much and have a nice weekend.

     

     

     


    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • AnalogNotes
    0 AnalogNotes over 12 years ago in reply to AnalogNotes

    OK, I did some testing on a schematic that I have here.  At first, I only had failures.  When I ran the script with the commands "name oldname newname", I got an error message "Unknown part".  I tried several different things, and finally sent a question to Cadsoft tech support.  Jorge pointed out that in the documentation for the name command, it says that "only parts, elements, pads, smds, pins and gates can be selected by their name using the old_name new_name syntax.  Nets, busses and signals have to be clicked first."  Oh no, that means we *have* to use a mouse click!

     

    Luckily, I had just learned something new that I could try.  You can read about it in another thread here on Element14: Re: How do I move/rotate values on a schematic?  I tested a couple commands using "name newname coordinates" by typing them on the command line in the schematic editor, and they worked!  So, then I just had to figure out where in the ULP to find the coordinates for the mouse click.  I looked in the help file, and found that nets have a segments() loop member and that segments have a wires() loop member and each wire has a start point (x1, y1).  Perfect!

     

    So here is the script:

     

    int minimum = 100;

    int maximum = 199;

    int newnumber = 100;

     

    string script = "grid inch;\n";

    string line;

    string oldname;

    string oldnumber;

    string newname;

    string lastpart;

    char c = '/';

    int position;

    int test;

     

    schematic(S){

      S.sheets(SH){

        sprintf(line, "edit .s%d;\n", SH.number);

        script += line;

        SH.nets(N){

          oldname = N.name;

          position = strchr(oldname, c);

          oldnumber = strsub(oldname, 1, position);

          test = strtol(oldnumber);

          if ( (test >= minimum) && (test <= maximum) ) {

            lastpart = strsub(oldname, position);

            sprintf(newname, "W%d", newnumber);

            newname += lastpart;

            N.segments(SEG)

              SEG.wires(W) {

                sprintf(line, " (%f %f);\n", u2inch(W.x1), u2inch(W.y1));

              }

            script += "name ";

            script += newname;

            script += line;

            newnumber += 1;

          }

        }

      }

      script += "edit .s1;\n";

      script += "grid last;\n";

      dlgMessageBox(script);

    }

    exit(script);

     

    I used the "grid inch" command to make sure I was working with the correct units to match the "u2inch" commands.  The "grid last" command near the bottom returns the grid setting to what it was before the script ran.  At the start of each schematic page loop, I add the command to the script to edit that page so that the mouse clicks match the parts on the correct page.  At the end, I put in the command "edit .s1" to return to the first page of the schematic.  The dlgMessageBox command shows you the script before it runs, and the very last line, "exit(script);" is what actually runs the script and makes the changes.  If you want to see what will run without making changes, comment out the exit line.  If you don't want the dialog box to show, you can comment out the dlgMessageBox line.

     

    Hopefully that works for you!  Let me know if you have any questions...

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • AnalogNotes
    0 AnalogNotes over 12 years ago in reply to e14 Contributor

    Ursicin Caminada wrote:

    Your code works perfectly, I'll check what is different and try to figure Out what didn't work with my code, unfortunately I'didnd have time to do that yet.

     

    As for the // I found out myself that they are used for comments...could have deleted these lines, but you know, because I don't really know what I am doing on a such script,

     

    I'm impressed, you are doing well!

     

    I just start somewhere and try if it works or not. I then comment out one line, have a look what changed, comment out the next line, try again....

     

    I think that's the best way to learn...

     

    Because of that I just comment out these lines, so if I need them again it is much faster to delete the // than to find and copy/paste the needed line.

     

    This is what "real" programmers do all the time.  image

     

    Gist GitHub: Because I use the Element14 Website instead of newsgroups, I didnt notice a problem with the code missing. What I noticed was that the code is not shown in the notification email, but this isn't a big problem for me. Copy and paste from the element14  website works peerfectly.
    Is there any concerns if I post the code directly on to the element14 website? Or why du you use GitHub?

     

    It was mostly an experiment.  When I paste code into a post on Element14, every line gets the same indentation, so I make a lot of changes in the editor here.  The Github Gist is nice because the indentation stays the way I created it, and the code is displayed with line numbers.  I could then explain things by line number.

     

    This forum is connected to the NNTP system and all of the posts are stored at the Eagle Central web site too.  Code doesn't transfer very well between them.  I think I will only post code directly here at Element14 in the future.

     

    I use Github and Bitbucket to store all of my programs and my EAGLE files.  That way I have a backup that is not on my own computer and they keep track of all of the changes I make to my files.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • e14 Contributor
    0 e14 Contributor over 12 years ago in reply to AnalogNotes

    Your code works perfectly, I'll check what is different and try to figure Out what didn't work with my code, unfortunately I'didnd have time to do that yet.

     

    As for the // I found out myself that they are used for comments...could have deleted these lines, but you know, because I don't really know what I am doing on a such script, I just start somewhere and try if it works or not. I then comment out one line, have a look what changed, comment out the next line, try again....
    Because of that I just comment out these lines, so if I need them again it is much faster to delete the // than to find and

    copy/paste the needed line.

    The commented out lines are basically your "old" script in what I copied the new part. I then commented these lines out because I tought they would basically do the same as the new ones...

     

    Gist GitHub: Because I use the Element14 Website instead of newsgroups, I didnt notice a problem with the code missing. What I noticed was that the code is not shown in the notification email, but this isn't a big problem for me. Copy and paste from the element14  website works peerfectly.
    Is there any concerns if I post the code directly on to the element14 website? Or why du you use GitHub?

     

    Thanks

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • AnalogNotes
    0 AnalogNotes over 12 years ago in reply to AnalogNotes

    Well, the gist looks very nice on the Element14 site, but it doesn't get through to NNTP.  image

     

    You can see what I posted at: https://gist.github.com/AnalogNotes/9377478

     

    At the top right of the code display is a button with "<>" on it.  That will let you view the "raw" code in a form that is very easy to copy and paste.  Let me know if that works for you...

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • 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 © 2026 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.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube