-
Notifications
You must be signed in to change notification settings - Fork 28
/
Copy pathAlignD.ulp
560 lines (482 loc) · 20.6 KB
/
AlignD.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
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
//======================================================
// AlignD v0.2 based on Align v 1.0.3 by Danny Danhave
//
// Eagle v6.0 or later is required. Only the board editor is supported.
//
// Aligns board components in group or listed at the command line
// The direction of alignment is autodetected. The components are aligned
// after the origins of the top or leftmost component
//
// This software is released under the BSD 4-clause license:
//
// Copyright (c) 2010-2011, Damhave Systems
// All rights reserved.
// Modified 2010-05-21 LJW - Correct group coordinate determination & quote output script name on exit
// Modified 2013-06-13 gh (IPG Automotive GmbH) - Adaptations to Eagle 6.x
// Modified 2013-06-13 gh (IPG Automotive GmbH) - Original Part order is now kept, independant from Part Name!
// Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
// * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the distribution.
// * Neither the name of the Damhave Systems nor the names of its contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS
// BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
// GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
// OF SUCH DAMAGE.
//======================================================
#usage "<B>Aligns board components in group or listed in the components field</B>"
"<P>"
"Align components along a line parallel to the x or y axis of the board.<br>"
"The direction of alignment is autodetected by looking at the position of the components. The alignment direction can also be forced.<br>"
"<b>Options:</b>"
/* Previous flags for reference "<b>blockquote>run alignd [*]<br>"
//" The presence of a flag causes the ULP to run without the dialog with the last options set.<br />"
"<br /><h3>Options:</h3>"
"d: Distribute components evenly between the outermost components<br>"
"e: use regular Expressions (regex) instead of wildcards<br>"
"g: align to Grid<br>"
"h: Force alignment on a horizontal line<br>"
"i: Increment position for each component by the specified value<br>"
"o: align to reference Object<br>"
"s: Snap to grid<br>"
"k: Keep original part order if parts are already in the correct order but not aligned<br>"
"v: Force alignment on a Vertical line"
"<I>The components in the selection group are used when no components are specified at the command line.<br>"
"The align to the bottommost/leftmost component flag -c is default set if no -g or -o flags are specified</I></blockquote>" */
"<P>"
"<b>Force Horizontal</b><br />"
" Forces horizontal alignment.<br />"
"<b>Force Vertical</b><br>"
" Forces vertical alignment.<br />"
"<b>Snap to Grid</b><br>"
" Forces components to nearest gridpoint. May be used with all other options.<br />"
"<b>Align to Grid</b><br>"
" Aligns components on a horizontal or vertical gridline but not to gridpoints.<br />"
"<b>Align to Reference Object</b><br>"
" Aligns component to a Reference Object. The reference object need not be selected or in the group selection.<br />"
"<b>Component List</b><br>"
" A list of components to align, separated by spaces. Components need not be selected. \"*\" is a wildcard.<br />"
"<b>Use Regular Expressions</b><br>"
" Uses regular expressions in the component list fields instead of asterisk wildcard.<br />"
"<b>Distribute</b><br>"
" Equally distributes components between the first and last selected component.<br />"
"<b>Increment</b><br>"
" Increments each component the amount shown in the field.<br />"
"<P>"
"AlignD Copyright (c) 2014 Paul Badger<br />"
"Align ULN on which AlignD is based: Copyright (c) 2010-2011 Damhave Systems<br />"
"<Author>Paul Badger & Danny Damhave<br>ModernDevice.com<br />"
"Damhave Systems www.damhave.com</Author><br>"
"This ulp is released under the BSD 4-clause license. See source code for details."
enum {false, true};
enum {ALIGN_ALONG_YAXIS, ALIGN_ALONG_XAXIS};
enum {GROUP, LIST};
string outputFileName = "aligntempfile.scr";
string partlist[];
int alignment, xRefObject = INT_MAX, yRefObject = INT_MAX, xAligned = INT_MAX, yAligned = INT_MAX,
xMin = INT_MAX, xMax = INT_MIN, yMax = INT_MIN, yMin = INT_MAX, noElements = 0, mode = GROUP,
firstInList = 1, alignToComponentFlag = false, keepFlag=false, alignToGridFlag = false,
alignToObjectFlag = false, alignOnVerticalLine = false, alignOnHorizontalLine = false, regexFlag = false,
snapFlag = false, distributeFlag = false, incrementFlag = false;
real distance, increment, xAvg = 0.0, yAvg = 0.0;
int Result = 0;
// this is a file where param values are stored - params would be better in static memory but
// that is not available to ULPs at this time
string ULPfilename = path_ulp[0] + '/' + "AlignD.ULP.txt";
// Checkboxes variables for the dialog
int horizontal = 0, vertical = 0, dlgIncrement = 0, distribute = 0, snapGrid = 0, alignToGrid = 0, align = 0, keepInOrder = 0;
int dlgRegEx = 0, alignToObject = 0, alignComponents = 0, flagsSet = 0, numberOfComponents, IncrementAmtInMils = 0;
int DBbools[];
string ObjectString = "";
string ComponentText = "Components sep. by spaces";
string ComponentList[]; // two dim text array (list)
string boolParams = "000000000000000000";
//string compParams = "Components sep. by spaces";
string incrmntParm = "000000";
string str_DBbools= "000000000000";
string inString;
string CompHistory[]; //history for component box
// Align ULP 1.0.3 by Danny Damhave Damhave Systems www.damhave.com
// Dialog box implementation by Paul Badger 2014
void initParamFile(){
int size = filesize(ULPfilename);
if (!size){output(ULPfilename,"wt")
printf("00000000000000000000");
}
}
void saveParams(){
DBbools[0] = horizontal;
DBbools[1] = vertical;
DBbools[2] = snapGrid;
DBbools[3] = alignToGrid;
DBbools[4] = keepInOrder;
DBbools[5] = alignToObject;
DBbools[6] = alignComponents;
DBbools[7] = dlgRegEx;
DBbools[8] = dlgIncrement;
DBbools[9] = distribute;
DBbools[10] = 0; //unused
DBbools[11] = 0; //unused
for (int i = 0; i < 12; i++){
if (DBbools[i]) str_DBbools[i] = '1';
else str_DBbools[i] = '0';
}
output(ULPfilename,"wt"){
printf("Bools:%s\n", str_DBbools);
printf("ObStr:%s\n", ObjectString);
printf("CmpSt:%s\n", ComponentText);
printf("IncMs:%d\n", IncrementAmtInMils);
}
}
void help(void) {
dlgDialog("HELP AlignD") {
dlgLabel(usage);
dlgHBoxLayout {
dlgStretch(0);
dlgPushButton("+OK") dlgAccept();
dlgStretch(0);
}
};
}
void getParams(){
int i = 0;
string Sarray[];
int nStrings = fileread(inString, ULPfilename);
nStrings = strsplit(Sarray, inString, '\n');
ObjectString = strsub(Sarray[1], 6, strlen(Sarray[1]));
ComponentText = strsub(Sarray[2], 6, strlen(Sarray[2]));
IncrementAmtInMils = strtol(strsub(Sarray[3], 6, strlen(Sarray[3])));
//Parse out Boolean checkbox info
horizontal = Sarray[0][i++ + 6] - '0';
vertical = Sarray[0][i++ + 6] - '0';
snapGrid = Sarray[0][i++ + 6] - '0';
alignToGrid = Sarray[0][i++ + 6] - '0';
keepInOrder = Sarray[0][i++ + 6] - '0';
alignToObject = Sarray[0][i++ + 6] - '0';
alignComponents = Sarray[0][i++ + 6] - '0';
dlgRegEx = Sarray[0][i++ + 6] - '0';
dlgIncrement = Sarray[0][i++ + 6] - '0';
distribute = Sarray[0][i++ + 6] - '0';
DBbools[9] = Sarray[0][i++ + 6] - '0';
DBbools[10] = Sarray[0][i++ + 6] - '0';
DBbools[11] = Sarray[0][i++ + 6] - '0';
}
void dlgLogic(int selected){
if (selected == 1){ //alignToGrid
alignComponents = 0;
alignToObject = 0;
}
if (selected == 2){ //alignToObject
alignToGrid = 0;
alignComponents = 0;
}
if (selected == 3){ //alignComponents
alignToGrid = 0;
alignToObject = 0;
}
dlgRedisplay();
}
// ULN begins here
initParamFile();
getParams();
Result = dlgDialog("AlignD ULP") {
dlgVBoxLayout {
dlgStretch(0);
dlgGroup("AlignD ULP by Paul Badger v0.2") {
dlgStretch(1);
dlgGridLayout {
dlgCell(1, 1) { dlgCheckBox("&Force Vertical", vertical) if (vertical) horizontal = 0; };
dlgCell(2, 1) { dlgCheckBox("&Force Horizontal", horizontal) if (horizontal) vertical = 0; };
dlgCell(3, 1) { dlgCheckBox("&Keep Parts In Order", keepInOrder); };
dlgCell(4, 1) { dlgCheckBox("&Snap to Grid ", snapGrid); };
dlgCell(5, 1) { dlgCheckBox("&Align to Grid", alignToGrid) if (alignToGrid) dlgLogic(1); };
dlgCell(6, 1) { dlgCheckBox("&Reference Object to which to Align", alignToObject) if (alignToObject) dlgLogic(2); };
dlgCell(7, 1) { dlgStringEdit(ObjectString); };
dlgCell(8, 1) { dlgRadioButton("&Align Components in Group", alignComponents) if (alignComponents ) /*dlgLogic(3)*/; };
dlgCell(9, 1) { dlgRadioButton("&Align Components in List", alignComponents) if (alignComponents ) /*dlgLogic(3)*/ ;};
dlgCell(10, 1){ dlgLabel("<font size=-1>Components separated by spaces. "*" is wildcard. </font>"); };
dlgCell(11, 1){ dlgStringEdit(ComponentText); };
dlgCell(12, 1){ dlgCheckBox("&Use Regular Expressions", dlgRegEx); };
dlgCell(13, 1){ dlgCheckBox("&Distribute", distribute) if (distribute) dlgIncrement = 0; };
dlgCell(14, 1){ dlgCheckBox("&Increment (in mils)", dlgIncrement) if (dlgIncrement) distribute = 0; };
dlgCell(15, 1){ dlgIntEdit(IncrementAmtInMils, -40000, 40000); }
dlgRedisplay();
}
}
dlgHBoxLayout {
dlgPushButton("+OK"){
saveParams();
dlgAccept(1);
}
dlgStretch(1);
dlgSpacing(10);
dlgPushButton("&HELP") help();
dlgSpacing(10);
dlgStretch(1);
dlgPushButton("-CANCEL") dlgReject(-1);
dlgStretch(0);
}
dlgStretch(0);
dlgRedisplay();
}
};
if (Result == -1){
exit (0);
}
if (Result == 1){ // dialog exited with "OK"
numberOfComponents = strsplit(ComponentList, ComponentText, ' '); // parse out component list
}
// dialog box ends here
int isMatch(string s, string test, int useRegex)
{
int j;
//dlgMessageBox(s + ' ' + test + j++ );
string regex = !useRegex ? "^" : test;
if (!useRegex)
{
for(int i = 0; test[i];)
{
switch(test[i])
{
case '[': regex += strsub(test, i, strchr(test, ']', i) - i + 1), i += strchr(test, ']', i) - i + 1; break;
case '?': regex += ".", i++; break;
case '*': regex += ".*", i++; break;
case '+': case '^': case '$': case '.': case '{': case '}': case '(': case ')': case '|': case '\\':
regex += "\\" + test[i], i++; break;
default: regex += test[i], i++;
}
}
regex +='$';
}
return strxstr(s, regex, 0) == 0;
}
// argv is a list - two-dimensional text array
int inList(string name)
{
//dlgMessageBox(name);
for(int i = 0 /*firstInList*/; (i < numberOfComponents) && (ComponentList[i] != "") /* argc && argv[i] != ""*/ ; i++)
{
if (regexFlag)
{
if (isMatch(name, ComponentList[i] /*argv[i]*/ , regexFlag)) return true;
}
else
{
if (isMatch(strupr(name), strupr(ComponentList[i] /*argv[i]*/), regexFlag)){ /*dlgMessageBox("true");*/ return true; }
}
}
// dlgMessageBox("false");
return false;
}
int snapToGrid(UL_BOARD brd, real coordinate)
{
real gSize;
if (brd.grid.unitdist == GRID_UNIT_MIC) gSize = mic2u(brd.grid.distance);
else if (brd.grid.unitdist == GRID_UNIT_MM) gSize = mm2u(brd.grid.distance);
else if (brd.grid.unitdist == GRID_UNIT_MIL) gSize = mil2u(brd.grid.distance);
else if (brd.grid.unitdist == GRID_UNIT_INCH) gSize = inch2u(brd.grid.distance);
// printf("# old coordinate=%f gSize=%f brd.grid.distance=%f\n", coordinate, gSize, brd.grid.distance);
// printf("# new coordinate = %f mm2u=%d\n", (round (coordinate / gSize) * gSize), mm2u(1));
return (round (coordinate / gSize) * gSize);
}
real input2u(UL_BOARD brd, real inputValue)
{
real convFactor;
if (brd.grid.unitdist == GRID_UNIT_MIC) convFactor = mic2u(1);
else if (brd.grid.unitdist == GRID_UNIT_MM) convFactor = mm2u(1);
else if (brd.grid.unitdist == GRID_UNIT_MIL) convFactor = mil2u(1);
else if (brd.grid.unitdist == GRID_UNIT_INCH) convFactor = inch2u(1);
return (round (inputValue * convFactor));
}
// Liste nach den Koordinatien sortieren, um ursprüngliche Reihenfolge beizubehalten
int SortPartList (UL_BOARD brd, int nEls, int DirIsX, int reverse)
{
real coord[], c;
int getauscht = 0;
string t;
int i, j;
if (keepFlag == false) return 0;
for (i=0; i < nEls; i++)
{
brd.elements(e1)
{
if (e1.name == partlist[i]) {
coord[i] = (DirIsX==1) ? e1.x : e1.y;
}
}
}
do {
getauscht = 0;
for (i=0; i<nEls-1; i++)
{
j = i+1;
if ((reverse == 0 && coord[i] > coord[j]) || (reverse == 1 && coord[i] < coord[j]))
{
getauscht = 1;
t = partlist[i];
partlist[i] = partlist[j];
partlist[j] = t;
c = coord[i];
coord[i] = coord[j];
coord[j] = c;
// printf ("# Getauscht: %d=%s %d=%s\n", i, partlist[i], j, partlist[j]);
}
}
} while (getauscht == 1);
return 0;
}
// ***** The ulp begins here *****
if ((!board && !library ) && !dlgMessageBox("Can only be used in the board editor.\n")) exit(1);
if (EAGLE_VERSION < 6 && !dlgMessageBox("Requires Eagle v5.7 or later.\n")) exit(1);
// parse out dialog box attributes the logic in the flag list below
// and the "illegal flag test has been moved to the dialog box
if (distribute) distributeFlag = true;
if (dlgRegEx) regexFlag = true;
if (horizontal) alignOnHorizontalLine = true;
if (keepInOrder) keepFlag = true;
if (dlgIncrement) incrementFlag = true;
if (alignToGrid) { alignToGridFlag = true; }
if (alignComponents) alignToComponentFlag = true;
if (alignToObject){ alignToObjectFlag = true; }
if (snapGrid) snapFlag = true;
if (vertical) alignOnVerticalLine = true;
// this is kind of clunky - needed to trigger flag parsing below - PAB
if ( distribute || dlgRegEx || horizontal || keepInOrder || keepInOrder || dlgIncrement || snapGrid || alignComponents || alignToObject || vertical){
flagsSet = 1; }
if (flagsSet)
{
/*for (int i = 1; flags[i]; i++) // flags from original code - for reference
{
switch (flags[i])
{
case 'c' : alignToComponentFlag = true; break;
case 'd' : distributeFlag = true; break;
case 'e' : regexFlag = true; break;
case 'g' : alignToGridFlag = true; alignToComponentFlag = false; break;
case 'h' : alignOnHorizontalLine = true; break;
case 'k' : keepFlag = true; break;
case 'i' : incrementFlag = true; break;
case 'o' : alignToObjectFlag = true; alignToComponentFlag = false; break;
case 's' : snapFlag = true; break;
case 'v' : alignOnVerticalLine = true; break;
//default : dlgMessageBox("No such flag.\n"); exit(3);
}
} */
firstInList++; // what does this do? Pointer to flag?
if (((alignOnHorizontalLine && alignOnVerticalLine) || (incrementFlag && distributeFlag) || (alignToGridFlag && alignToObjectFlag) || (alignToComponentFlag && alignToObjectFlag) || (alignToGridFlag && alignToComponentFlag)) && !dlgMessageBox("Illegal flag combination.\n")) exit(1);
if (incrementFlag)
{
if (incrementFlag && !(IncrementAmtInMils) && !dlgMessageBox("No increment specified.\n")) exit(1);
board(brd) {
if (IncrementAmtInMils != 0) increment = input2u(brd,real(IncrementAmtInMils)); //PAB
}
//firstInList++;
}
if (alignToObjectFlag)
{
if (alignToObjectFlag && (ObjectString == "") && !dlgMessageBox("No object specified.\n")) exit(1);
board(brd) { brd.elements(element) { if (element.name == ObjectString) xRefObject = element.x, yRefObject = element.y; } }
if ((xRefObject == INT_MAX && yRefObject == INT_MAX) && !dlgMessageBox("No such object.\n")) exit(1);
//firstInList++;
}
else; // There are no flags therefore use the default align to bottommost/leftmost object in the direction with the most spread
}
if (alignToComponentFlag){
mode = LIST;
}
else{
mode = GROUP;
}
board(brd)
{
int nEls = 0;
int i;
outputFileName = filedir(brd.name)+outputFileName;
output(outputFileName, "wtD")
{
status("Aligning Objects...");
brd.elements(element)
{
if ((mode == GROUP && ingroup(element)) || (mode == LIST && inList(element.name))) // inList(element.name)))
{
noElements += 1;
if (element.x < xMin) xMin = element.x;
if (element.x > xMax) xMax = element.x;
if (element.y < yMin) yMin = element.y;
if (element.y > yMax) yMax = element.y;
xAvg += element.x;
yAvg += element.y;
partlist[nEls] = element.name;
nEls ++;
}
}
if ((noElements < 2) && !dlgMessageBox("Minimum 2 objects in group/list required.\n")) exit(1);
xAvg = xAvg / noElements;
yAvg = yAvg / noElements;
if (alignOnHorizontalLine) alignment = ALIGN_ALONG_XAXIS; // Alignment in X direction forced by -h flag ?
else if (alignOnVerticalLine) alignment = ALIGN_ALONG_YAXIS; // Alignment in Y direction forced by -v flag ?
else alignment = ((xAvg - xMin) > (yMax - yAvg)) ? ALIGN_ALONG_XAXIS : ALIGN_ALONG_YAXIS; // Alignment autodetected on basis of spread
if (alignment == ALIGN_ALONG_YAXIS)
{
if (alignToObjectFlag) xAligned = xRefObject; // Align on a vertical line going through the reference object ?
else brd.elements(element) // Align on a vertical line going through to the leftmost bottommost object
{
if ((mode == GROUP && ingroup(element)) || (mode == LIST && inList(element.name))) //inList(element.name)))
{
if (element.y == yMin) xAligned = (snapFlag || alignToGridFlag) ? snapToGrid(brd, element.x) : ((element.x < xAligned) ? element.x : xAligned);
}
}
if (distributeFlag)
distance = (yMax - yMin)/(noElements-1);
else if (incrementFlag)
distance = increment;
SortPartList (brd, nEls, 0, 0);
}
else
{
if (alignToObjectFlag) yAligned = yRefObject; // Align on a horizontal line going through the reference object ?
else brd.elements(element) // Align on a horizontal line going through to the leftmost bottommost object
{
if ((mode == GROUP && ingroup(element)) || (mode == LIST && inList(element.name))) //inList(element.name)))
{
if (element.x == xMin) yAligned = (snapFlag || alignToGridFlag) ? snapToGrid(brd, element.y) : ((element.y < yAligned) ? element.y : yAligned);
}
}
if (distributeFlag)
distance = (xMax - xMin)/(noElements-1);
else if (incrementFlag)
distance = increment;
SortPartList (brd, nEls, 1, 0);
}
int n = 0, totalDistance;
for (i=0; i<nEls; i++) {
brd.elements(element)
{
if (element.name == partlist[i])
{
if (distributeFlag || incrementFlag)
{
totalDistance = ((alignment == ALIGN_ALONG_YAXIS) ? yMin : xMin) + distance * n;
if (alignment == ALIGN_ALONG_YAXIS)
yAligned = (snapFlag || alignToGridFlag) ? snapToGrid(brd, totalDistance) : totalDistance;
else
xAligned = (snapFlag || alignToGridFlag) ? snapToGrid(brd, totalDistance) : totalDistance;
printf("MOVE %s (%fmm %fmm)\n", element.name, u2mm(xAligned), u2mm(yAligned));
n++;
}
else
{
if (alignment == ALIGN_ALONG_YAXIS)
printf("MOVE %s (%fmm %fmm)\n", element.name, u2mm(xAligned), u2mm(snapFlag ? snapToGrid(brd, element.y) : element.y));
else
printf("MOVE %s (%fmm %fmm)\n", element.name, u2mm(snapFlag ? snapToGrid(brd, element.x) : element.x), u2mm(yAligned));
}
}
}
}
}
}
exit("script '" + outputFileName + "'; move");