forked from robertstarr/ulp_user
-
Notifications
You must be signed in to change notification settings - Fork 0
/
drillplan3_1.ulp
313 lines (263 loc) · 8.68 KB
/
drillplan3_1.ulp
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
/*
* THIS VERSION ONLY WORKS WITH EAGLE 4.XX
*
* This EAGLE User Language Program generates a script
* which places a drill legend on the current board.
* After executing the ULP update the drill diameter
* symbols with Options - Set - Drill - Set
* NEW MODIFICATION- PLACES THE SCRIPT IN ANY DIRECTORY
* BY ANY NAME YOU WISH.
*
*
* Filename: drillplan2_0.ulp
* Edited by: Jeff Moore <[email protected]>
* Date: February 5th 2001
* Options - Set - Drill - Set
*
* Edited by: Brad Goodman <[email protected]>
* Date: January, 30, 2002
* Added separate counts and reporting for plated drills.
* Changed order of drawing, to smallest drills are first.
*
* Origonal Filename: drillplan.ulp
* by: Frank Hoffman
*
* Dieses ULP generiert ein Script, das eine Bohrlegende
* im Layout plaziert.
* Aktualisieren Sie anschließend die Symbole für die
* Bohrdurchmesser mit
*
* Options - Set - Drill - Set
*/
int Drilling[];
int Counts[];
int Index[];
int Plating[];
int imax = 0;
int totalDrills = 0;
int totalPlates = 0;
string strTmp;
string strCmd; // script command text
int nUnits = 0; // 0=metric, 1=emperial
void AddDrilling(int Size,int plated)
{
for ( int i = imax; --i >= 0; )
{
if (Drilling[i] == Size)
{
Counts[i]++;
totalDrills++;
if (plated == 1)
{
Plating[i]++;
totalPlates++;
}
return;
}
}
Drilling[imax] = Size;
if (plated == 1)
{
Plating[imax]=1;
totalPlates++;
}
else
Plating[imax]=0;
Counts[imax++] = 1;
totalDrills++;
}
board(B)
{
int Result = dlgDialog("Add Drill Plan")
{
dlgHBoxLayout
{
dlgVBoxLayout
{
dlgGroup("Drill Plan Display Units")
{
dlgRadioButton("Metric (mm)", nUnits);
dlgRadioButton("Emperial (mil)", nUnits);
}
dlgStretch(1);
}
}
dlgHBoxLayout
{
dlgPushButton("OK") dlgAccept();
dlgPushButton("-Cancel") dlgReject();
}
};
if (!Result)
exit(0);
real ylegend;
real xlegend = u2mil(B.area.x2) + 40;
real drill = 0;
B.holes(H) AddDrilling(H.drill,0);
B.signals(S) S.vias(V) AddDrilling(V.drill,1);
B.elements(E)
{
E.package.contacts(C)
{
if (C.pad)
AddDrilling(C.pad.drill,1);
}
E.package.holes(H) AddDrilling(H.drill,0);
}
sort(imax, Index, Drilling, Counts );
ylegend = u2mil(B.area.y1) + (imax* 200);
sprintf(strTmp, "GRID mil 50 ON;\n");
strCmd += strTmp;
sprintf(strTmp, "CHANGE SIZE 70;\n");
strCmd += strTmp;
sprintf(strTmp, "CHANGE RATIO 8;\n");
strCmd += strTmp;
sprintf(strTmp, "CHANGE LAYER 48;\n");
strCmd += strTmp;
sprintf(strTmp, "WINDOW FIT;\n");
strCmd += strTmp;
for (int i = 0; i < imax; ++i)
{
sprintf(strTmp, "HOLE %f (%f %f);\n", u2mil(Drilling[Index[i]]),
xlegend + 200, ylegend - 100);
strCmd += strTmp;
sprintf(strTmp, "WIRE 5 (%f %f) (%f %f);\n",
u2mil(B.area.x2) + 40, ylegend,
u2mil(B.area.x2) + 3140, ylegend );
strCmd += strTmp;
if (nUnits == 0)
{
// Metric Units
sprintf(strTmp, "TEXT '%5.3f mm' (%f %f);\n",
u2mm(Drilling[Index[i]]),
xlegend + 440,
ylegend - 135 );
strCmd += strTmp;
sprintf(strTmp, "TEXT '+/-0.075 mm' (%f %f);\n",
xlegend + 1250, ylegend - 135 );
strCmd += strTmp;
}
else
{
// Emperial Units
sprintf(strTmp, "TEXT '%5.3f in' (%f %f);\n",
u2inch(Drilling[Index[i]]),
xlegend + 440,
ylegend - 135 );
strCmd += strTmp;
sprintf(strTmp, "TEXT '+/-0.003 in' (%f %f);\n",
xlegend + 1250, ylegend - 135 );
strCmd += strTmp;
}
sprintf(strTmp, "TEXT '%4d' (%f %f);\n",Counts[Index[i]],
xlegend + 2200, ylegend - 135 );
strCmd += strTmp;
if (Counts[Index[i]] == Plating[Index[i]])
{
sprintf(strTmp, "TEXT 'Yes' (%f %f);\n",
xlegend + 2600, ylegend - 135 );
strCmd += strTmp;
}
else
{
if (!Plating[Index[i]])
{
sprintf(strTmp, "TEXT 'NO' (%f %f);\n",
xlegend + 2600, ylegend - 135 );
strCmd += strTmp;
}
else
{
sprintf(strTmp, "TEXT '%4d' (%f %f);\n", Plating[Index[i]],
xlegend + 2600, ylegend - 135 );
strCmd += strTmp;
}
}
ylegend -= 200;
}
ylegend = u2mil(B.area.y1) + (imax* 200);
sprintf(strTmp, "WIRE 5 (%f %f) (%f %f);\n",
u2mil(B.area.x2) + 40, u2mil(B.area.y1),
u2mil(B.area.x2) + 3140, u2mil(B.area.y1));
strCmd += strTmp;
sprintf(strTmp, "WIRE 5 (%f %f) (%f %f);\n",
u2mil(B.area.x2) + 40, ylegend + 400,
u2mil(B.area.x2) + 3140, ylegend + 400 );
strCmd += strTmp;
sprintf(strTmp, "WIRE 5 (%f %f) (%f %f);\n",
u2mil(B.area.x2) + 40, u2mil(B.area.y1),
u2mil(B.area.x2) + 40, ylegend + 400 );
strCmd += strTmp;
sprintf(strTmp, "WIRE 5 (%f %f) (%f %f);\n",
u2mil(B.area.x2) + 3140, u2mil(B.area.y1),
u2mil(B.area.x2) + 3140, ylegend + 400 );
strCmd += strTmp;
sprintf(strTmp, "WIRE 5 (%f %f) (%f %f);\n",
u2mil(B.area.x2) + 40, ylegend + 200,
u2mil(B.area.x2) + 3140, ylegend + 200 );
strCmd += strTmp;
sprintf(strTmp, "WIRE 5 (%f %f) (%f %f);\n",
u2mil(B.area.x2) + 40, ylegend,
u2mil(B.area.x2) + 3140, ylegend );
strCmd += strTmp;
sprintf(strTmp, "WIRE 5 (%f %f) (%f %f);\n",
u2mil(B.area.x2) + 410, u2mil(B.area.y1),
u2mil(B.area.x2) + 410, ylegend + 200 );
strCmd += strTmp;
sprintf(strTmp, "WIRE 5 (%f %f) (%f %f);\n",
u2mil(B.area.x2) + 2140, u2mil(B.area.y1),
u2mil(B.area.x2) + 2140, ylegend + 200 );
strCmd += strTmp;
sprintf(strTmp, "WIRE 5 (%f %f) (%f %f);\n",
u2mil(B.area.x2) + 2540, u2mil(B.area.y1),
u2mil(B.area.x2) + 2540, ylegend + 200 );
strCmd += strTmp;
sprintf(strTmp, "CHANGE SIZE 150;\n");
strCmd += strTmp;
sprintf(strTmp, "TEXT 'DRILL PLAN' (%f %f);\n",
xlegend + 800, ylegend + 225);
strCmd += strTmp;
sprintf(strTmp, "CHANGE SIZE 100;\n");
strCmd += strTmp;
sprintf(strTmp, "TEXT 'SYM' (%f %f);\n",
xlegend + 50, ylegend + 50);
strCmd += strTmp;
sprintf(strTmp, "TEXT 'SIZE' (%f %f);\n",
xlegend + 460, ylegend + 50);
strCmd += strTmp;
sprintf(strTmp, "TEXT 'TOL.' (%f %f);\n",
xlegend + 1250, ylegend + 50);
strCmd += strTmp;
sprintf(strTmp, "TEXT 'CNT' (%f %f);\n",
xlegend + 2190, ylegend + 50);
strCmd += strTmp;
sprintf(strTmp, "TEXT 'PLATE' (%f %f);\n",
xlegend + 2590, ylegend + 50);
strCmd += strTmp;
sprintf(strTmp, "CHANGE SIZE 70;\n");
strCmd += strTmp;
sprintf(strTmp, "TEXT 'TOTAL' (%f %f);\n",
xlegend + 1600, u2mil(B.area.y1) - 150 );
strCmd += strTmp;
sprintf(strTmp, "TEXT '%4d' (%f %f);\n",totalDrills,
xlegend + 2200, u2mil(B.area.y1) - 150 );
strCmd += strTmp;
sprintf(strTmp, "TEXT '%4d' (%f %f);\n",totalPlates,
xlegend + 2600, u2mil(B.area.y1) - 150 );
strCmd += strTmp;
//sprintf(strTmp, "TEXT '(Set the drill symbols with' (%f %f);\n",
// xlegend + 120, ylegend + 1000 );
// strCmd += strTmp;
//sprintf(strTmp, "TEXT 'Options - Set - Drill - Set)' (%f %f);\n",
// xlegend + 120, ylegend + 900);
// strCmd += strTmp;
//sprintf(strTmp, "TEXT 'Drill file will contain one extra of' (%f %f);\n",
// xlegend + 120, ylegend + 700 );
// strCmd += strTmp;
//sprintf(strTmp, "TEXT 'each drill, placed in above diagram.' (%f %f);\n",
// xlegend + 120, ylegend + 600);
// strCmd += strTmp;
sprintf(strTmp, "WINDOW FIT;\n");
strCmd += strTmp;
exit(strCmd);
}