Author Topic: New ULP to measure distance between contacts from Board/Library editor  (Read 4766 times)

0 Members and 1 Guest are viewing this topic.

Offline YTusernameTopic starter

  • Regular Contributor
  • *
  • Posts: 83
  • Country: tr
    • Atadiat
Hi

Measuring distance between footprint objects(lines, pads,smds,...etc) is not straight forward, as it needs to use the measurement tool and change grid to a fine grid size, or you need to get coordination of each object and do the distance measurement manually.

I decided to make a new ULP to automate the process and show the distance between selected objects inside a group.

https://github.com/yahyatawil/ContactsRuler/

And here is an example of using the new ULP. What do you think of it ?

 

Offline Quarlo Klobrigney

  • Frequent Contributor
  • **
  • Posts: 967
  • Country: pt
  • This Space For Rent
The standard ruler tool is a pain in the ass through Eagle.
This would be a good tool to fix their problem, but it's not working in version 7. It gives an error 74.

I can help you with the readme, here is an improvement to the English syntax in the .md file if you wish:

# ContactsRuler
This ULP makes measuring distances between footprint contacts easier
You can use this in the Library and board editors

## Usage in the Library editor:

* Using
the group tool, select any 2 of the following: pads, smds, holes and lines.
* Run ContactsRuller.ulp
* You will have the X and Y result difference in 3 different units: mm, mil and inch.
Note: Don't select more than 2 objects in the group.

## Usage in the Board editor:
* Using
the Group tool, select the part you want to measure, for the distance between its pads.
* You will will then have a dialog with check box beside each contact name.
* Select any 2 contacts.
* Press OK. Next you will have a dialog with the difference in X and Y in 3 units: mm, mil and inch.

Note: Don't select more than 1 part in the group, and don't check more than 2 boxes in the dialog screen.



Sorry the animated picture runs too fast to grasp everything. Perhaps a YouTube video? No speaking is needed if you don't want to.
« Last Edit: July 07, 2020, 07:17:36 pm by Quarlo Klobrigney »
Voltage does not flow, nor does voltage go.
 

Offline YTusernameTopic starter

  • Regular Contributor
  • *
  • Posts: 83
  • Country: tr
    • Atadiat
Thanks for the incompatibility with Eagle version 7 feedback, I had to make a simple change to make it work. This is because Eagle team made a change of one of the used ulp functions from 9.1 version. Please try it now.

However, I will add soon an icon to call the ulp from the toolbar directly, and maybe enhance a little the user experience especially for Library usage.

Thanks for the Readme language check, I updated it  :D .

I will make a post on my blog soon, to explain usage, but I wanted to get feedback first before doing the post.
« Last Edit: July 07, 2020, 11:42:06 pm by YTusername »
 

Offline Quarlo Klobrigney

  • Frequent Contributor
  • **
  • Posts: 967
  • Country: pt
  • This Space For Rent
The revised version works in the library, but it crashes Eagle in the board mode.
Voltage does not flow, nor does voltage go.
 

Offline YTusernameTopic starter

  • Regular Contributor
  • *
  • Posts: 83
  • Country: tr
    • Atadiat
Hmmm .. what Eagle version exactly ? I tried with V7.1-light from board and library editors.
Also, did you try it with different parts ? Could it be because of a bug in the ULP for a certain part ?
 

Offline Quarlo Klobrigney

  • Frequent Contributor
  • **
  • Posts: 967
  • Country: pt
  • This Space For Rent
7.3
Voltage does not flow, nor does voltage go.
 

Offline jpanhalt

  • Super Contributor
  • ***
  • Posts: 3398
  • Country: us
I have ever needed that function, but one could simply draw a wire between the two pads (it starts and stops at the centers).  Then click on the properties of that wire.  Alternatively, just get the X-distance from the properties menu and do a subtraction.

Eagle 7.2.0 and 7.7.0


The latter may be what you are doing with the ULP, but unfortunately the demo started too soon for me to read it.

Anyway, I can't see having too many ULP's even if I never use them.

Thank you for that effort.
 

Offline Quarlo Klobrigney

  • Frequent Contributor
  • **
  • Posts: 967
  • Country: pt
  • This Space For Rent
That's how I have done it in the library editor for years now. It's just a few more steps to do. Then there's the not ready for prime time Kicad. One day when it is ready, (Crashes on Win 7 and Linux, 3 different machines) then I will invest in a learning curve. I've been using paid Eagle since the 3.xx days.

Quote from: jpanhalt on Today at 04:18:17
I have ever needed that function, but one could simply draw a wire between the two pads (it starts and stops at the centers).  Then click on the properties of that wire. 
Voltage does not flow, nor does voltage go.
 

Offline westfw

  • Super Contributor
  • ***
  • Posts: 4196
  • Country: us
I usually just use the "mark" command and than watch the relative and/or polar coordiate display...
 

Offline YTusernameTopic starter

  • Regular Contributor
  • *
  • Posts: 83
  • Country: tr
    • Atadiat
jpanhalt and westfw, thanks for you inputs, great tricks! There are many ways indeed to do the measurement, but I find it too much steps, especially that will need changing grid size usually. Maybe this ULP is useful for revising a board to check many footprints, without going back and  forth between footprint and library editors, assuming that we have all components library. 

Quarl, I will look for it in 7.3 version.
« Last Edit: July 11, 2020, 02:42:09 am by YTusername »
 

Offline jpanhalt

  • Super Contributor
  • ***
  • Posts: 3398
  • Country: us
I do not know about versions after 8.0. One thing I would like in 7.x would be the ability to toggle between grid settings.  One can, of course, set up keys to show grid settings and and to switch grid on and off, but changing the settings always requires keyboard entries.

I didn't use to do that much, but as devices have gotten smaller and metric more common, I need to do it more and more, particularly when editing a library.  What I would envision is simply setting up 2 grids, imperial and metric, then assigning a function key to toggle between them. 

The closest one can do now is to assign the alternate grid as metric, but then one loses the ability to switch between coarse and fine grids.

« Last Edit: July 11, 2020, 09:39:50 am by jpanhalt »
 

Offline westfw

  • Super Contributor
  • ***
  • Posts: 4196
  • Country: us
>
Quote
Changing the settings always requires keyboard entries.
1021772-0You know you can set up a GUI menu as well, right?  I have one that doubles or halves the grid size, that I really like...
 

Offline jpanhalt

  • Super Contributor
  • ***
  • Posts: 3398
  • Country: us
I didn't know that.   Is that capability in version 7.x?  Where is it located? 
 

Offline YTusernameTopic starter

  • Regular Contributor
  • *
  • Posts: 83
  • Country: tr
    • Atadiat
You can set the grid settings, then save the setting by clicking on grid icon using left right mouse key and save it (from "New..."). The same applies to layer button (I used to use this trick in old Eagle version to switch fast between Top and Bottom layers while reviewing).

What @westfw mentioned is to add buttons to tool bar using Eagle scripts. In the attachments a picture of a menu script example to add few buttons. You can duplicate the same example and add your own commands.

BTW, in the past I gathered some of like tricks in series of article published on AllAboutCircuits, please have a check here: https://www.allaboutcircuits.com/technical-articles/eagle-cad-tips-and-tricks/
« Last Edit: July 13, 2020, 08:30:31 am by YTusername »
 

Offline westfw

  • Super Contributor
  • ***
  • Posts: 4196
  • Country: us
Quote
I didn't know that.   Is that capability in version 7.x?  Where is it located? 
Yeah, it goes way back to Version 4 - I'm stuck on a non-profit 7.x license, myself.)
See "Help Menu", and you may have to check "Command Texts" in the Options/UserInterface panel.
The customizability (scripts, ULPs, menus) of eagle is one of the major reasons I've been unmotivated to try KiCAD.
 
The following users thanked this post: jpanhalt

Offline jpanhalt

  • Super Contributor
  • ***
  • Posts: 3398
  • Country: us
As mentioned earlier, I use 7.x (mostly 7.2).  Here is the Grid menu:
1022248-0

There is no "new" button.  I saw the AAC articles before.  They relate to a new version.  Of course one can use grid to set a dimension when drawing a complicated package or PCB outline.  I simply use a regular CAD program, which is far simpler, and import it.  Then with the command line or by grid settings, I get it centered.  Usually the command line is easier to use, but doing it with grid setting is pretty intuitive and only a slightly longer process as you have to set each axis separately.

I have been using Eagle for a long time and am comfortable with most of its capabilities.  The use of a  script for setting up a GUI is something I have not gotten into.  I spent a fair bit of time on Google yesterday and every link pertaining to how to do that for older versions is broken or redirects to Autodesk.  One comment, maybe by Jorge, suggests it is done with a "C-type language."  That is as far as I got.


 

Offline jpanhalt

  • Super Contributor
  • ***
  • Posts: 3398
  • Country: us
Quote
I didn't know that.   Is that capability in version 7.x?  Where is it located? 
Yeah, it goes way back to Version 4 - I'm stuck on a non-profit 7.x license, myself.)
See "Help Menu", and you may have to check "Command Texts" in the Options/UserInterface panel.
The customizability (scripts, ULPs, menus) of eagle is one of the major reasons I've been unmotivated to try KiCAD.

Sorry, we cross posted.  We have the same license.  Mine is non-profit 7.x too.  My experience with any high level language is virtually nil.  I do not do C.  All of my microcontroller work is in Assembly.  I have done a little scripting with MPLab SIM, but that just a short list in notepad.  I also do some simple command line entries in Eagle, but nothing I have tried to save as a ulp or scr.
 
What I was looking for was a description of the Eagle script -- maybe a tutorial.  The User's Manual for 7.3 (page 13) is way over my head.

Would you be willing to share what you wrote for the grid that could be used as a model for modification? 

The only time I really use the grid as a tool is for designing a package and routing a PCB.  For the package, grid changes are dependent on the package, and I am not too worried about having "1-click" changes. For the PCB, I find it convenient to have a regular and fine grid in both imperial and metric. It's relatively uncommon that I change any of those four settings.  Being able to switch easily between imperial coarse/fine and metric coarse/fine would  be an asset.

Regards, John
 

Offline YTusernameTopic starter

  • Regular Contributor
  • *
  • Posts: 83
  • Country: tr
    • Atadiat
As mentioned earlier, I use 7.x (mostly 7.2).  Here is the Grid menu:
Sorry, I made a typo in the last reply. you can save the grid setting by clicking on grid icon using right mouse key and save it (from "New...").
 
The following users thanked this post: jpanhalt

Offline jpanhalt

  • Super Contributor
  • ***
  • Posts: 3398
  • Country: us
@YTusername

I got it to work and noticed an interesting quirk.  I use classic icons.  If I go to View, the grid icon works as shown in my previous post.  There is no "new" or other option.  But, if I go to the grid icon in the header, then a right click gives the options you show. 

Frankly, I hadn't even noticed that icon before as it with all the element14 stuff (e.g., BOM quote) that I wish I could remove and is identical to the icon in the dropdown.

1) I set up Imperial and Metric grids.
2) Assigned each to a function key (Options>Assign....>Change>Fn  Grid Imperial, rinse and repeat for Metric).   

Now, I can simply select which grid to use with a single key stroke.

Thanks to you both. 

PS: I would still like to see what the script looks looks like.

John
 

Offline Quarlo Klobrigney

  • Frequent Contributor
  • **
  • Posts: 967
  • Country: pt
  • This Space For Rent
Yes it works, but how convoluted. I had to make an alias. Numbers cannot be used as leading characters, so the alias 005 or .005 is out of the question, however oo5 is acceptable. To recall it, you have to right click the grid icon and drop down and left click it.
Typical "look what we have done" "we've improved it" software. Eagle was stagnant for many years, probably out of money.
Just like now that it's in the cloud, we are all saved. NOT. I refuse to upgrade to ver. 8 and above. My designs are mine not the company cloud.

Thanks for the tip on the grid though.  :-+
Lots of the stuff on the allaboutcircuits link is either simple previously known stuff or non functional in ver. 7, I saw that quite a while ago and tried a lot of it.

>Quote from: jpanhalt on Today at 16:23:43
As mentioned earlier, I use 7.x (mostly 7.2).  Here is the Grid menu:
Sorry, I made a typo in the last reply. you can save the grid setting by clicking on grid icon using right mouse key and save it (from "New...").
Voltage does not flow, nor does voltage go.
 

Offline jpanhalt

  • Super Contributor
  • ***
  • Posts: 3398
  • Country: us
Yes it works, but how convoluted.



To what does your "it" refer.  The grids I set up are 1 keystroke, e.g., F4 (special function) gives me one grind; F3 another.  The alternate key while routing with either gives me the corresponding fine or alternate version.

No problem saving them either.

As for a restriction on the first character of a "name/identifier" being a numeral, that restriction is fairly common.
 

Offline Quarlo Klobrigney

  • Frequent Contributor
  • **
  • Posts: 967
  • Country: pt
  • This Space For Rent
I was speaking in terms of the grid icon and mouse functions. I can't use macro keys due to spies listening to the usual macro keys while I use other technical software. Nothing bad, just a PIA.
I don't and won't use a scrolling mouse. It's trackball all the way. Nice for drawing without sliding off the mousepad.
Voltage does not flow, nor does voltage go.
 

Offline westfw

  • Super Contributor
  • ***
  • Posts: 4196
  • Country: us
Quote
The use of a  script for setting up a GUI is something I have not gotten into.  I spent a fair bit of time on Google yesterday and every link pertaining to how to do that for older versions is broken or redirects to Autodesk.  One comment, maybe by Jorge, suggests it is done with a "C-type language."
Quote
My experience with any high level language is virtually nil.  I do not do C. ... I also do some simple command line entries in Eagle, but nothing I have tried to save as a ulp or scr.
So you already know that for any GUI action on your project can also be entered as a text command in the CLI window.  That's a start.
Quote
What I was looking for was a description of the Eagle script -- maybe a tutorial.
Would you be willing to share what you wrote for the grid that could be used as a model for modification? 

Sure, I'll try.  I don't know how far you'll get without C or other HLL experience.
-
EAGLE extensions are very "clever."  Which is not at all the same as "elegant", but it does fit my personality.Everything is tied to the "cli commands."
-
The "menu" command lets you tie any text command to some menu buttons."initialization" scripts load at startup, and can distinguish between SCH/BRC/LBR...
So, for example, in the schematic editor I added a menu that has my favorite parts, so I don't have to keep going to the ADD panel:

Code: [Select]
menu    'R {1/4 W TH : add R-US_0207/10 | \
       SMT1206: add R-US_R1206 \
    }' \
    'C: add C-US*' \
    'CPOL: add CPOL-US*' \
    'WIRE: add WIRE-via8@mylib4' \
    'GND: add gnd@supply1' \
    'VCC: add vcc@supply1' \
    ;

    It ends up looking like:1022708-0

The syntax is a bit ugly, but relatively straightforward until you make your menus too deeply nested.
-
Since the menu buttons can have any EAGLE cli command, they can also invoke "Scripts" or "ULPs".
A "script" (.scr file) is just a file with a bunch of EAGLE cli commands in it.  It can "do things" to your project, but it does so "blindly", so it can't (for example) say "set the grid to half of its previous size" because while it has access to the "grid" command, it doesn't have any access to the old grid size.
-
"User Language Programs" are where you get to "C-like syntax."  Essentially "C with strings, objects, and libraries", you get your standard programing constructs, plus the ability to pop up dialog boxes (ugly, again), plus read-only access to much of the data that makes up your board, schematics, and a fair amount of EAGLE internal data structures.

To actually DO anything, a ULP generates a string or file that is a Script.For better or worse, there are MANY existing ULPs, and they're widely shared, so you can build up a useful menu that uses ULPs without actually having to write C-like code.
-
My Board "menu" looks like:
Code: [Select]
menu    'Layers {\
        Top : display NONE top torigins tKeepout tRestrict borigins pads vias dimension unrouted; | \
        Bottom : display NONE bottom borigins bKeepout bRestrict torigins pads vias dimension unrouted; | \
        All : display top bottom pads vias dimension unrouted tplace \
        torigins tnames tvalues bnames bvalues trestrict bplace borigins brestrict Document ?? Edit_history; | \
        NoNames : display -tnames -tvalues -bnames -bvalues; | \
        noDocu : display -tdocu -bdocu; | \
        AddDocu:  display tdocu bdocu Document ?? Edit_History; | \
        SilkScreen: display NONE tplace -tvalues -tdocu dimension top tStop; \
    }' \
    'TogScreen : run toglays 21 22 25 26 27 28 51 52;' \
    'DrawOn {\
        Top : change layer top; | \
        Bottom : change layer bottom; | \
        tPlace : change layer tPlace; | \
        Dim : change layer Dimension; | \
        History: change layer History; \
    }' \
    'Grid {\
      Toggle : run gridhalf 1 t ; info | \
      Smaller : run gridhalf 0.5; move | \
      Bigger : run gridhalf 2; move   | \
          OnOff : grid; move \
    }' \
    'Circle : run circle;' \
    'Count : run count;' \
    'DrlAid : run drill-aid;' \
    'RipPoly : ripup @;' \
    ;

Note "Count" and "DrlAid" which simply run the EAGLE-provided ULPs.
The "Grid" menu (sub-menus Taggle, Smaller, Bigger) runs a ULP (gridhalf.ulp) I wrote with arguments that include a multiplier, and whether the units should change.  The ULP reads the current grid info from the board data structures, multiplies it by the factor provided, constructs a new "grid NNmm" command (or whatever) and returns that string, which is executed as a script and changes the grid.   There are some other complications associated with changing the units at the same time, but I don't remember exactly what they were :-(

gridhalf.ulp looks like:
Code: [Select]
#usage "<qt><b>gridmult.ulp <mult> m|i|t"
      "<p>Multiply the current grid setting by a factor."
      "<p>"
      "<author>Author: Bill Westfield xxxxxx@xxxxxx</author></qt>"

real griddistance;
real multiplier = 1.0;
string cmd = "";
string units;
string newgrid;
UL_GRID oldgrid;
char arg2;

string gu2str (int  unittype)
{
  switch (unittype) {
  case  GRID_UNIT_MIC:
    return " mic";
  case  GRID_UNIT_MM:
    return " mm";
  case  GRID_UNIT_MIL:
    return " mil";
  case  GRID_UNIT_INCH:
    return " inch";
  }
}

if (board) board(B) {
    oldgrid = B.grid;
} else if (library) library(L) {
    oldgrid = L.grid;
}

if (argc > 0) {
    if (argc > 2) {
    if (oldgrid.unit == GRID_UNIT_INCH) {
        newgrid = "grid mm;";
    } else {
        newgrid = "grid inch;";
    }
    } else newgrid = "";
   
    multiplier = strtod(argv[1]);

    griddistance = oldgrid.distance * multiplier;
    if (oldgrid.unit == oldgrid.unitdist) {
    /*
     * original units still being used.  No conversion necessary!
     */
    sprintf(cmd, "grid %f;%s\n", griddistance, newgrid);
    exit(cmd);
    } else {
    /*
     * We have to play with units.  We could convert, but let's
     * switch the commands around instead (gives us compatibility
     * with the menus, hopefully!)
     */
    sprintf(cmd, "grid %s; grid %f; grid %s;%s\n", gu2str(oldgrid.unitdist),
        griddistance, gu2str(oldgrid.unit), newgrid);
    exit(cmd);
    }
}
(look at that lovely comment about needing to "play with units" but not WHY.  Sigh.)
« Last Edit: July 13, 2020, 09:07:13 pm by westfw »
 
The following users thanked this post: jpanhalt

Offline jpanhalt

  • Super Contributor
  • ***
  • Posts: 3398
  • Country: us
Wow, that is so much more help than I had hoped for.  I will definitely learn from it.

John
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf