File: count.ulp

package info (click to toggle)
eagle 4.16-5
  • links: PTS
  • area: non-free
  • in suites: etch, etch-m68k
  • size: 36,508 kB
  • sloc: sh: 82; makefile: 32
file content (71 lines) | stat: -rw-r--r-- 1,333 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#usage "<b>Count Pads, Vias, Smds and Holes of a board</b>\n"
       "<p>"
       "<author>Author: support@cadsoft.de</author>"

// THIS PROGRAM IS PROVIDED AS IS AND WITHOUT WARRANTY OF ANY KIND, EXPRESSED OR IMPLIED

int i, j, k, h, l, s ;
i = j = k = h = l = 0;

if (board) {
board(B) {
   B.holes(L) {
     h++;
     }

   B.elements(E) {
     E.package.holes(H) {
       h++;
       }
     E.package.contacts(C) {

       if (C.pad)
          i++ ;
       if (C.smd && (C.smd.layer == 1))
          j++ ;
       if (C.smd && (C.smd.layer == 16))
          l++;
       }
   }

  B.signals(S) {
     S.vias(V) {
          k++;
     }
  }

string result;

 sprintf(result,
 " Number of Pads:  %d\n\
 Number of Vias:  %d\n\
 Number of Smds:  %d\n\
    Smds in Top:  %d\n\
    Smds in Bot:  %d\n\
 Number of holes: %d\n\
 Total number of drills: %d", i, k, j+l, j, l, h, i+k+h);

 dlgDialog("Layout Information") {
  dlgVBoxLayout {
    dlgHBoxLayout {
      dlgSpacing(200);}
     dlgTextView(result);
         dlgPushButton("+Ok") dlgAccept();
  }
 };

 string fileName ;

 fileName = dlgFileSave("Save Statistic File", filesetext(B.name, ".txt"), "*.txt");
   if (fileName == "") exit(0);

  output(fileName) {
    printf("%s",result);
    }
 }
}

else {
   dlgMessageBox("\n    Start this ULP in a Board    \n");
   exit (0);
 }