File: export-class.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 (76 lines) | stat: -rw-r--r-- 1,946 bytes parent folder | download | duplicates (2)
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
72
73
74
75
76
#usage "<b>Export Net-Classes</b>\n"
       "<p>"
       "<author>Author: support@cadsoft.de</author>"

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

string grid[] = { "MIC", "MM", "MIL", "INCH" };
int Gridval = 1;              // 0=mic 1=mm 2=mil 3=inch    ***
                              // choose the value for the units you're working with

string cmd, s;
string projectm;

real u2u(int val) {
  switch(Gridval) {
    case 0 : return u2mic(val);
    case 1 : return u2mm(val);
    case 2 : return u2mil(val);
    case 3 : return u2inch(val);
  }
}

void savescr(string projectname) {
  string file = dlgFileSave("save CLASS script", filesetext(projectname, "-class.scr"), "*.scr");
  if (file) {
    output(file, "wt" ) printf("%s", cmd);
    exit(0);
  }
  else return;
}

void menue(string projectname) {
  int Result = dlgDialog("Export Net CLASSes") {
     dlgStretch(0);
     dlgHBoxLayout dlgSpacing(500);
     dlgHBoxLayout {
       dlgVBoxLayout dlgSpacing(200);
       dlgTextEdit(cmd);
     }
     dlgStretch(0);
     dlgHBoxLayout {
        dlgStretch(0);
        dlgPushButton("+&Cancel") dlgAccept();
        dlgPushButton("&Save script") savescr(projectname);
        dlgStretch(1);
        }
     dlgStretch(0);
     };
  if (Result == 0) exit (0);
  return;
  }

void class(UL_CLASS C) {
  if (C.name) {
    sprintf(s, "CLASS %d '%s' %.4f %.4f %.4f;\n", C.number, C.name, u2u(C.width), u2u(C.clearance), u2u(C.drill) );
    cmd += s;
  }
}

// main
if (board) board(B) {
   projectm = B.name;
   sprintf(cmd, "# export from: %s\nGRID %s;\n", B.name, grid[Gridval] );
   B.classes(C) class(C);
}

else if (schematic) schematic(S) {
   projectm = S.name;
   sprintf(cmd, "# export from %s\nGRID %s;\n", S.name, grid[Gridval] );
   S.classes(C) class(C);
}

else if (library) dlgMessageBox("start this ULP in Board or Schematic", "OK");

cmd += "GRID LAST;\nCLASS";
menue(projectm);