#usage "Trace layer, to display layers step by step.
"
"RUN trace-layer +
"
"RUN trace-layer -
"
"Layers 17 Pad, 18 Via, 19 Unrouted, 23 tOrigin and 24 bOrigin are not separated displayed"
// Version 1.0 - 2007.06.06 support@cadsoft.de
int supplyLayer[];
int usedLayer[];
int mLayer = 0;
int lastUsed;
string cmd;
string message = "";
string layerFile = filesetext(argv[0], ".trl");
string f[];
int isFile = fileglob(f, layerFile);
void checkLayer(void) {
if (argv[1] == "+") {
if (mLayer == 23 || mLayer == 24) mLayer = 25;
if (mLayer == 17 || mLayer == 18 || mLayer == 19) mLayer = 20;
lastUsed = mLayer;
}
if (argv[1] == "-") {
if (mLayer == 23 || mLayer == 24) mLayer = 22;
if (mLayer == 17 || mLayer == 18 || mLayer == 19) mLayer = 16;
lastUsed = mLayer;
}
return;
}
if (isFile) {
string rLayer;
int n = fileread(rLayer, layerFile);
mLayer = strtol(rLayer);
}
if (argv[1] == "-") {
mLayer --;
if (board) {
if (mLayer < 1) {
if (!mLayer) message = "The first layer.";
mLayer = 1;
}
}
else if (schematic) {
if (mLayer < 91) mLayer = 91;
}
}
if (argv[1] == "+") {
mLayer ++;
if (mLayer >255) {
mLayer = 255;
if (!mLayer) message = "The last layer.";
}
}
checkLayer();
if (board) {
board(B) {
B.layers(L) {
if (L.used) {
usedLayer[L.number] = 1;
}
string ln = L.name;
if (ln[0] == '$') {
usedLayer[L.number] = 1;
supplyLayer[L.number] = 1;
}
}
if (argv[1] == "+") {
if (!usedLayer[mLayer]) {
do {
mLayer++;
if (usedLayer[mLayer]) break;
} while (mLayer < 256);
if (mLayer >= 255) message = "The last Layer.";
}
}
if (argv[1] == "-") {
if (!usedLayer[mLayer]) {
do {
mLayer--;
if (usedLayer[mLayer]) break;
} while (mLayer > 1);
}
}
checkLayer();
if (usedLayer[mLayer]) {
if (mLayer < 17) {
if (supplyLayer[mLayer]) {
sprintf(cmd, "DISPLAY NONE %d;\n", mLayer);
message ="ATTENTION this is a Supply layer, do not use this Layer in CAM-Job with Pad- and/or Via-Layer.";
}
else {
sprintf(cmd, "DISPLAY NONE %d 17 18;\n", mLayer);
}
}
else {
sprintf(cmd, "DISPLAY NONE %d;\n", mLayer);
}
lastUsed = mLayer;
}
}
}
checkLayer();
if (lastUsed) {
output(layerFile, "wtD") {
printf("%d", lastUsed);
}
}
if (message) {
string s;
sprintf(s, "RUN ulpmessage '%s';\n", message);
cmd += s;
}
exit (cmd);