3
\$\begingroup\$

I currently use EagleCAD to capture my schematics and route my circuit boards. Eagle isn't very pleasant to work with, so I've started working with schematics and boards outside of Eagle's GUI by directly editing the SCH and BRD files; calling Eagle commands from the system command line when needed. (Just to be clear, I mean calling Eagle commands from an external script or a CMD or terminal window, not from the little textbox "command window" inside the Eagle GUI.)

I'd like to be able to handle DRC and ERC from outside of the Eagle GUI, but I'm unsure how. I can, for instance, call the Eagle DRC from the command line with "eaglecon -C DRC;QUIT; [board name]", but this just opens the Eagle GUI, lists any DRC errors in a dialog window inside the GUI, and then closes the GUI. I would like to get the list of DRC errors as text in the command window, so they can be piped to a file.

Any ideas if this is feasible? Thanks

\$\endgroup\$
1
  • \$\begingroup\$ Ask this questions at EAGLE Exchange in Element14 community. Looking through GUI, scripts and ULPs I do not see such functionality. When you view DRC error list in GUI, it instantly shows the location of the issue on the board, and does not list any location details or elements involved in the table (but I use v6, probably in newer versions it looks differently). \$\endgroup\$
    – Anonymous
    Commented Nov 16, 2016 at 16:58

1 Answer 1

3
\$\begingroup\$

Okay, I figured it out (and the anonymous comment pointing out the Eagle Exchange forum helped).

You can't pipe the DRC output by running it directly from the command line, but starting with Eagle 7.x you can access a UL_ERROR object in User Language Programs (ULPs). Cadsoft's ULP manual (v7.2) gives the details. Here is a sample program to print all DRC errors for a given board:

string errstring;
string errheader;
string errlist[];
int errcnt = 0;
real xadj, yadj, finest_unit;
finest_unit = 0.000000123031496; //assuming grid is in inches

errheader = "code\tstate\tdescription\tlayer\tsignature\tx\ty";

if (board) {
    board(B) {
        if (B.checked) {
            B.errors(ER) {
                if (ER.state == ERROR_STATE_ACTIVE) {
                    xadj = ER.x * finest_unit;
                    yadj = ER.y * finest_unit;
                    sprintf(errstring, "%d\t%d\t%s\t%d\t%s\t%f\t%f", ER.code, ER.state, ER.description, ER.layer, ER.signature, xadj, yadj);
                    errlist[errcnt++] = errstring;
                }
            }
        }

        string filepath = [full path to desired output text file];
        output(filepath) {
            printf("Grid size=%f\n", B.grid.distance);
            printf("Grid unit=%d\n\n", B.grid.unit); //compare to grid constants in manual
            printf("%s\n", errheader);
            for (int i = 0; errlist[i]; ++i){
                printf("%s\n", errlist[i]);
            }
        }
    }
}
exit (0);

Save this in (for example) Eagle's ULP directory as foobar.ulp. This can then be called from the command line with something like

eaglecon -C "DRC; RUN ../ULP/foobar.ulp;QUIT;" [full path to board]

The quotes in that command are necessary.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.