1
0
Fork 0
This repository has been archived on 2019-12-23. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
arduinisten/eagle-5.7.0/ulp/snap-pin-in-symbol.ulp

39 lines
1 KiB
Text
Raw Normal View History

2010-03-30 20:14:34 +02:00
#usage "<b>snap pins in symbol to grid<p>"
"Example: run snap-pin-in-symbol [100]"
"<author>Author: librarian@cadsoft.de</author>"
string cmd;
real Grid = 100; // default 100 Mil
string s;
real xoff, yoff;
if (argv[1]) Grid = strtod(argv[1]);
real snap(int n) { // returns next grid point
return round(u2mil(n) / Grid) * Grid;
}
int move = 0;
if (library) {
if (symbol) symbol(S) {
string name = S.name;
S.pins(P) {
xoff = snap(P.x) - u2mil(P.x);
yoff = snap(P.y) - u2mil(P.y);
if (xoff || yoff) {
move = 1;
sprintf( s, "MOVE (%.5f %.5f) (%.1f %.1f);\n", u2mil(P.x), u2mil(P.y), snap(P.x), snap(P.y));
cmd += s;
}
}
if (move) {
if (dlgMessageBox(cmd, "OK", "Cancel") != 0) exit (-1);;
exit("GRID MIL FINEST;\n" + cmd + "GRID MIL 100 1 ON;");
}
else dlgMessageBox("PINs in " + name + ".SYM on Grid", "OK");
}
else dlgMessageBox("Start this ULP in a Symbol-Editor", "OK");
}
else dlgMessageBox("Start this ULP in Library (Symbol)", "OK");