File: del-empty-devices.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 (50 lines) | stat: -rw-r--r-- 1,084 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
#usage "<b>Delete empty devices</b>\n"
       "<p>"
       "To delete devices without a symbol from a library, "
       "run this ULP and click EXECUTE."
       "<p>"
       "Before executing the DELETE commands you can edit them "
       "in the appearing editor window."
       "<p>"
       "<author>Author: support@cadsoft.de</author>"

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

if (library) {
int empty;
string cmd = "", h;

cmd += "set undo_log off;\n";
library(L) {
  L.devicesets(D) {
    h = "";
    empty = 1;
    D.gates(G) {
      empty = 0;
      }
    if (empty) { // device w/o gates found!
      sprintf(h,"REMOVE %s.dev;\n",D.name);
      cmd += h;
      }
    }
  }
cmd += "set undo_log on;\n";

//  EditBox
int Result = dlgDialog("Edit and Execute") {
   dlgTextEdit(cmd);
   dlgHBoxLayout {
      dlgPushButton("+Execute") dlgAccept();
      dlgPushButton("-Cancel") dlgReject();
      }
   };
if (!Result)
   exit(0);

exit(cmd);
}

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