Created
February 7, 2019 18:33
-
-
Save TCWORLD/10b0d251d896e97a0162208bd3c7ee4a to your computer and use it in GitHub Desktop.
Eagle Swap ULP (Modified)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* swap.ulp | |
* Jan 2013 , By Cruz Monrreal II ([email protected]) | |
* | |
* Modified by Thomas Carpenter 2018 | |
* | |
* Swaps part names. | |
* | |
*/ | |
#usage "<b>Swap Part Names</b>\n" | |
"<p>Usage: run swap A B" | |
"<p><p><b>Example:</b>" | |
"<p>run swap R2 R14" | |
"<p>This will swap parts R2 and R14 with eachother" | |
"<p><p>" | |
"<small><table>" | |
"<tr><td><i>Cruz Monrreal</i></td></tr>" | |
"<tr><td><i>[email protected]</i></td></tr>" | |
"<tr><td><i>http://www.innovativemaker.com</i></td></tr>" | |
"</table></small>" | |
string cmd = ""; | |
string A = ""; | |
string B = ""; | |
output("swapnames.log", "wt") | |
{ | |
if (schematic){ | |
if (argc != 3) { | |
int found = 0; | |
schematic(S) { | |
S.parts(P){ | |
P.instances(I) { | |
if (ingroup(I)) { | |
if (found == 0) { | |
A = P.name; | |
found = 1; | |
} else if (found == 1) { | |
B = P.name; | |
found = 2; | |
} | |
} | |
} | |
} | |
} | |
} else { | |
schematic(S) { | |
S.parts(P){ | |
if (P.name == argv[1]){ | |
A = argv[1]; | |
} | |
if (P.name == argv[2]){ | |
B = argv[2]; | |
} | |
} | |
} | |
} | |
}else if (library){ | |
library(L) { | |
L.packages(P){ | |
P.contacts(C){ | |
if (C.name == argv[1]){ | |
A = argv[1]; | |
} | |
if (C.name == argv[2]){ | |
B = argv[2]; | |
} | |
} | |
} | |
} | |
} | |
if (A != "" && B != ""){ | |
cmd += "name " + A + " _tmp_; "; | |
cmd += "name " + B + " " + A + "; "; | |
cmd += "name _tmp_ " + B + "; "; | |
} | |
exit(cmd); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment