forked from robertstarr/ulp_user
-
Notifications
You must be signed in to change notification settings - Fork 0
/
make-supply-symdev.ulp
454 lines (415 loc) · 15.7 KB
/
make-supply-symdev.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
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
#usage "<b>Make Connector Symbols</b> - v1.01 (4/13/11)<p>"
"This ULP generates various supply symbols in a library"
"<p>"
"<author>http://www.bobstarr.net</author>";
//////////////////////////////////////////////////////////////////////////////
//
// MAKE SUPPLY SYMBOL/DEVICE
//
// Copyright (C) 2011, Robert E. Starr (http://www.bobstarr.net)
//
// REVISION HISTORY:
//
// v1.00 - 02/13/2011 (RES) - Initial Release
//
// v1.01 - 04/13/2011 (RES) - Added config file to save/restore settings
// after each execution of the script.
//
//////////////////////////////////////////////////////////////////////////////
//
// THIS PROGRAM IS PROVIDED AS IS AND WITHOUT WARRANTY OF ANY KIND,
// EXPRESSED OR IMPLIED. IF YOU DON'T LIKE IT, DON'T USE IT!
//
//////////////////////////////////////////////////////////////////////////////
string Version = "1.01";
string fileName;
int fScriptExec = 1; // execute script automatically after generating
int fNegative = 0;
int nSymbolStyle = 0;
string strSymbolName = "V+";
string strIconImage = "<img src=make-supply-symdev0.png>";
string ConfigFileName = "make-supply-symdev.cfg";
//////////////////////////////////////////////////////////////////////////////
// Create the supply symbol
void CreateSupplySymbol()
{
printf("Grid mm;\n");
printf("Set Wire_Bend 2;\n");
printf("Edit '%s.sym';\n", strSymbolName);
if (nSymbolStyle==0) // BAR STYLE
{
if (fNegative)
{
printf("Pin '%s' Sup None Short R270 Off 0 (0 2.54);\n", strSymbolName);
printf("Layer 96;\n");
printf("Change Size 1.778;\n");
printf("Change Ratio 12;\n");
printf("Text '>VALUE' R0 (-3.175 -2.54);\n");
printf("Layer 94;\n");
printf("Wire 0.508 (1.905 0) (-1.905 0);\n");
}
else
{
printf("Pin '%s' Sup None Short R90 Off 0 (0 -2.54);\n", strSymbolName);
printf("Layer 96;\n");
printf("Change Size 1.778;\n");
printf("Change Ratio 12;\n");
printf("Change Font Proportional;\n");
printf("Text '>VALUE' R0 (-3.81 0.635);\n");
printf("Layer 94;\n");
printf("Change Style Continuous;\n");
printf("Wire 0.508 (-1.905 0) (1.905 0);\n");
}
}
else if (nSymbolStyle==1) // THIN ARROW
{
if (fNegative)
{
printf("Pin '%s' Sup None Short R270 Off 0 (0 2.54);\n", strSymbolName);
printf("Layer 96;\n");
printf("Change Size 1.778;\n");
printf("Change Ratio 12;\n");
printf("Text '>VALUE' R0 (-3.175 -3.81);\n");
printf("Layer 94;\n");
printf("Wire 0.254 (-0.635 0.635) (0.635 0.635) (0 -1.27) (-0.635 0.635);\n");
printf("Layer 94;\n");
printf("Change Spacing 1.27;\n");
printf("Change Pour Solid;\n");
printf("Polygon 0.1524 (0 -1.27) (-0.635 0.635) (0.635 0.635) (0 -1.27);\n");
}
else
{
printf("Pin '%s' Sup None Short R90 Off 0 (0 -2.54);\n", strSymbolName);
printf("Layer 96;\n");
printf("Change Size 1.778;\n");
printf("Change Ratio 12;\n");
printf("Change Font Proportional;\n");
printf("Text '>VALUE' R0 (-2.54 1.905);\n");
printf("Layer 94;\n");
printf("Change Style Continuous;\n");
printf("Wire 0.254 (0.635 -0.635) (-0.635 -0.635) (0 1.27) (0.635 -0.635);\n");
printf("Layer 94;\n");
printf("Change Spacing 1.27;\n");
printf("Change Pour Solid;\n");
printf("Polygon 0.1524 (0 1.27) (0.635 -0.635) (-0.635 -0.635) (0 1.27);\n");
}
}
else if (nSymbolStyle==2) // WAVE Symbol
{
if (fNegative)
{
printf("Pin '%s' Sup None Short R270 Off 0 (0 2.54);\n", strSymbolName);
printf("Layer 96;\n");
printf("Change Size 1.778;\n");
printf("Change Ratio 12;\n");
printf("Text '>VALUE' R0 (-3.175 -3.175);\n");
printf("Layer 94;\n");
printf("Wire 0.508 (-1.905 -0.3175) -80.0844 (0 0);\n");
printf("Wire 0.508 (1.905 0.3175) -80.0893 (0 0);\n");
}
else
{
printf("Pin '%s' Sup None Short R90 Off 0 (0 -2.54);\n", strSymbolName);
printf("Layer 96;\n");
printf("Change Size 1.778;\n");
printf("Change Ratio 12;\n");
printf("Change Font Proportional;\n");
printf("Text '>VALUE' R0 (-2.54 1.27);\n");
printf("Layer 94;\n");
printf("Change Style Continuous;\n");
printf("Wire 0.508 (1.905 0.3175) -80.0844 (0 0);\n");
printf("Wire 0.508 (-1.905 -0.3175) -80.0893 (0 0);\n");
}
}
else if (nSymbolStyle==3) // INVERTED Symbol
{
if (fNegative)
{
printf("Pin '%s' Sup None Point R270 Off 0 (0 2.54);\n", strSymbolName);
printf("Layer 96;\n");
printf("Change Size 1.778;\n");
printf("Change Ratio 12;\n");
printf("Text '>VALUE' R0 (-1.905 -3.175);\n");
printf("Layer 94;\n");
printf("Wire 0.1524 (0 2.54) (0 0.635) 0.4064 (1.27 -0.635);\n");
printf("Wire 0.4064 (0 0.635) (-1.27 -0.635);\n");
}
else
{
printf("Pin '%s' Sup None Point R90 Off 0 (0 -2.54);\n", strSymbolName);
printf("Layer 96;\n");
printf("Change Size 1.778;\n");
printf("Change Ratio 12;\n");
printf("Change Font Proportional;\n");
printf("Text '>VALUE' R0 (-2.54 1.5875);\n");
printf("Layer 94;\n");
printf("Change Style Continuous;\n");
printf("Wire 0.1524 (0 -2.54) (0 -0.635) 0.4064 (-1.27 0.635);\n");
printf("Wire 0.4064 (0 -0.635) (1.27 0.635);\n");
}
}
else if (nSymbolStyle==4) // THICK ARROW Symbol
{
if (fNegative)
{
printf("Pin '%s' Sup None Short R270 Off 0 (0 2.54);\n", strSymbolName);
printf("Layer 96;\n");
printf("Change Size 1.778;\n");
printf("Change Ratio 12;\n");
printf("Text '>VALUE' R0 (-3.175 -3.81);\n");
printf("Layer 94;\n");
printf("Wire 0.254 (-0.9525 0.635) (0 -1.27) (0.9525 0.635) (-0.9525 0.635);\n");
printf("Layer 94;\n");
printf("Change Spacing 1.27;\n");
printf("Change Pour Solid;\n");
printf("Polygon 0.1524 (0 -1.27) (-0.9525 0.635) (0.9525 0.635) (0 -1.27);\n");
}
else
{
printf("Pin '%s' Sup None Short R90 Off 0 (0 -2.54);\n", strSymbolName);
printf("Layer 96;\n");
printf("Change Size 1.778;\n");
printf("Change Ratio 12;\n");
printf("Change Font Proportional;\n");
printf("Text '>VALUE' R0 (-2.54 1.905);\n");
printf("Layer 94;\n");
printf("Change Style Continuous;\n");
printf("Wire 0.254 (0.9525 -0.635) (0 1.27) (-0.9525 -0.635) (0.9525 -0.635);\n");
printf("Layer 94;\n");
printf("Change Spacing 1.27;\n");
printf("Change Pour Solid;\n");
printf("Polygon 0.1524 (0 1.27) (0.9525 -0.635) (-0.9525 -0.635) (0 1.27);\n");
}
}
else if (nSymbolStyle==5) // ROUND Symbol
{
if (fNegative)
{
printf("Pin '%s' Sup None Point R270 Off 0 (0 2.54);\n", strSymbolName);
printf("Layer 96;\n");
printf("Change Size 1.778;\n");
printf("Change Ratio 12;\n");
printf("Text '>VALUE' R0 (-1.905 -3.175);\n");
printf("Layer 94;\n");
printf("Wire 0.1524 (0 2.54) (0 0.9525);\n");
printf("Layer 94;\n");
printf("Circle 0.4064 (0 0.0001) (0.8979 0.0001);\n");
}
else
{
printf("Pin '%s' Sup None Point R90 Off 0 (0 -2.54);\n", strSymbolName);
printf("Layer 96;\n");
printf("Change Size 1.778;\n");
printf("Change Ratio 12;\n");
printf("Change Font Proportional;\n");
printf("Text '>VALUE' R0 (-2.54 1.5875);\n");
printf("Layer 94;\n");
printf("Change Style Continuous;\n");
printf("Wire 0.1524 (0 -2.54) (0 -0.9525);\n");
printf("Layer 94;\n");
printf("Circle 0.4064 (0 -0.0001) (0.8979 -0.0001);\n");
}
}
else if (nSymbolStyle==6) // GND Symbol
{
printf("Pin '%s' Sup None Point R270 Off 0 (0 2.54);\n", strSymbolName);
printf("Layer 96;\n");
printf("Change Size 1.778;\n");
printf("Change Ratio 12;\n");
printf("Change Font Proportional;\n");
printf("Text '>VALUE' R0 (-2.2225 -2.54);\n");
printf("Layer 94;\n");
printf("Change Style Continuous;\n");
printf("Wire 0.254 (1.1113 1.5875) (0 1.5875) (-1.1113 1.5875);\n");
printf("Wire 0.1524 (0 2.54) (0 1.5875);\n");
printf("Wire 0.254 (0.635 0.7938) (-0.635 0.7938);\n");
printf("Wire 0.254 (0.1587 0) (-0.1588 0);\n");
}
else if (nSymbolStyle==7) // AGND Symbol
{
printf("Pin '%s' Sup None Point R270 Off 0 (0 2.54);\n", strSymbolName);
printf("Layer 96;\n");
printf("Change Size 1.778;\n");
printf("Change Ratio 12;\n");
printf("Text '>VALUE' R0 (-3.175 -2.54);\n");
printf("Layer 94;\n");
printf("Wire 0.254 (-0.9525 1.905) (0 0) (0.9525 1.905) (0 1.905) (-0.9525 1.905);\n");
printf("Wire 0.1524 (0 2.54) (0 1.905);\n");
}
else if (nSymbolStyle==8) // CGND Symbol
{
printf("Pin '%s' Sup None Point R270 Off 0 (0 2.54);\n", strSymbolName);
printf("Layer 96;\n");
printf("Change Size 1.778;\n");
printf("Change Ratio 12;\n");
printf("Text '>VALUE' R0 (-2.54 -2.54);\n");
printf("Layer 94;\n");
printf("Wire 0.254 (1.905 1.905) (0 1.905) (-1.905 1.905);\n");
printf("Wire 0.1524 (0 2.54) (0 1.905);\n");
printf("Wire 0.254 (1.905 1.905) (0 0) (-1.905 1.905);\n");
}
else if (nSymbolStyle==9) // EGND Symbol
{
printf("Pin '%s' Sup None Point R270 Off 0 (0 2.54);\n", strSymbolName);
printf("Layer 96;\n");
printf("Change Size 1.778;\n");
printf("Change Ratio 12;\n");
printf("Text '>VALUE' R0 (-3.175 -2.54);\n");
printf("Layer 94;\n");
printf("Wire 0.254 (1.27 1.5875) (0.9524 1.5875) (0.1587 1.5875) (-0.6352 1.5875) (-1.27 1.5875);\n");
printf("Wire 0.254 (-0.6352 1.5875) (-1.2701 0);\n");
printf("Wire 0.254 (0.1587 1.5875) (-0.4763 0);\n");
printf("Wire 0.254 (0.9524 1.5875) (0.3174 0);\n");
printf("Wire 0.1524 (0 2.54) (0 1.7463);\n");
}
printf("Grid mil;\n\n");
}
//////////////////////////////////////////////////////////////////////////////
// Create a supply device
void CreateSupplyDevice()
{
printf("GRID MIL\n");
printf("EDIT '%s.dev'\n", strSymbolName);
printf("Prefix 'V';\n");
printf("Description '<b>SUPPLY SYMBOL</b>';\n");
printf("Value Off;\n");
printf("Add %s 'G$1' Next 0 (0 0);\n", strSymbolName);
printf("Technology '';\n");
}
void OnTypeChange()
{
if (nSymbolStyle == 0)
strIconImage = "<img src=make-supply-symdev0.png>";
else if (nSymbolStyle == 1)
strIconImage = "<img src=make-supply-symdev1.png>";
else if (nSymbolStyle == 2)
strIconImage = "<img src=make-supply-symdev2.png>";
else if (nSymbolStyle == 3)
strIconImage = "<img src=make-supply-symdev3.png>";
else if (nSymbolStyle == 4)
strIconImage = "<img src=make-supply-symdev4.png>";
else if (nSymbolStyle == 5)
strIconImage = "<img src=make-supply-symdev5.png>";
else if (nSymbolStyle == 6)
strIconImage = "<img src=make-supply-symdev6.png>";
else if (nSymbolStyle == 7)
strIconImage = "<img src=make-supply-symdev7.png>";
else if (nSymbolStyle == 8)
strIconImage = "<img src=make-supply-symdev8.png>";
else if (nSymbolStyle == 9)
strIconImage = "<img src=make-supply-symdev9.png>";
}
int MainAppDialog()
{
string title = "Make Supply Symbol - v" + Version;
int nResult = dlgDialog(title)
{
dlgHBoxLayout
{
dlgVBoxLayout
{
dlgGroup("Symbol Style")
{
dlgRadioButton("Bar", nSymbolStyle) OnTypeChange();
dlgRadioButton("Thin Arrow", nSymbolStyle) OnTypeChange();
dlgRadioButton("Wave", nSymbolStyle) OnTypeChange();
dlgRadioButton("Inverted", nSymbolStyle) OnTypeChange();
dlgRadioButton("Thick Arrow", nSymbolStyle) OnTypeChange();
dlgRadioButton("Round", nSymbolStyle) OnTypeChange();
dlgRadioButton("Ground Style 1", nSymbolStyle) OnTypeChange();
dlgRadioButton("Ground Style 2", nSymbolStyle) OnTypeChange();
dlgRadioButton("Ground Style 3", nSymbolStyle) OnTypeChange();
dlgRadioButton("Ground Style 4", nSymbolStyle) OnTypeChange();
}
OnTypeChange();
}
dlgGroup("Preview")
{
dlgHBoxLayout
{
dlgSpacing(30);
dlgLabel(strIconImage, 1);
}
}
}
dlgHBoxLayout
{
dlgGroup("Symbol Name")
{
dlgGridLayout
{
dlgCell(1,0) dlgLabel("Name");
dlgCell(1,1) dlgStringEdit(strSymbolName);
dlgCell(1,2) dlgCheckBox("&Negative Supply Symbol", fNegative);
}
}
}
dlgSpacing(12);
dlgHBoxLayout
{
dlgPushButton("OK") dlgAccept();
dlgPushButton("-Cancel") dlgReject();
dlgCheckBox("&Execute Script", fScriptExec);
}
};
return nResult;
}
void LoadConfigSettings()
{
// load the last config settings saved
string a[];
// Should be 27 lines in config file
int n;
n = fileread(a, filedir(argv[0])+ConfigFileName);
if (n == 4)
{
int i = 0;
fScriptExec = strtol(a[i++]);
fNegative = strtol(a[i++]);
nSymbolStyle = strtol(a[i++]);
strSymbolName = a[i++];
}
}
void SaveConfigSettings()
{
// save the config settings
output(filedir(argv[0])+ConfigFileName, "wt")
{
printf("%d\n", fScriptExec);
printf("%d\n", fNegative);
printf("%d\n", nSymbolStyle);
printf("%s\n", strSymbolName);
}
}
//////////////////////////////////////////////////////////////////////////////
// Script Entry Point
if (library)
{
library(LBR)
{
LoadConfigSettings();
int nResult = MainAppDialog();
if (!nResult)
exit(0);
SaveConfigSettings();
fileName = filesetext(LBR.name, "_MakeSupplySymDev.scr");
output(fileName, "wtD")
{
printf("# Auto Generated at %s<br>\n", t2string(time()));
printf("# %s;\n\n", EAGLE_SIGNATURE);
printf("SET UNDO_LOG OFF;\n\n");
CreateSupplySymbol();
CreateSupplyDevice();
printf("SET UNDO_LOG ON;");
}
if (fScriptExec)
exit ("SCRIPT '" + fileName + "';");
else
exit(0);
}
}
else
{
dlgMessageBox("Start this ULP in the Library Editor!", "OK");
}
// End-Of-File