#usage "Convert a CAM job to a PRINT command\n" "
" "Usage: RUN cam2print [ pagelimit [ filename ]]" "
" "Tip: Assign a funktion key with" "
" "ASSIGN Shift+Ctrl+Alt+P 'run cam2print.ulp;';" "
" "or" "
" "ASSIGN Shift+Ctrl+Alt+P 'run cam2print.ulp 0 myjob.cam;';" "
"
" \n" +
"If the layer list is empty after starting this ULP,\n" +
"you did not start it from the proper editor window (SCH/BRD). \n" +
"CAM jobs for the layout have to be started from the Layout Editor, " +
"jobs for a schematic from the Schematic Editor. \n" +
"CAM Jobs can be edited and save only by the CAM processor.";
// *** functions ***
void editsec(int sec) {
string num;
sprintf(num, "%d", sec);
dlgDialog("Section Editor") {
dlgLabel("Section " + num);
dlgHBoxLayout {
dlgPushButton("+&OK") dlgAccept();
dlgPushButton("-&Cancel") dlgReject();
dlgStretch(1);
}
};
return;
}
void commandPrint(int sectab) {
cmd += "PRINT ";
sprintf(s, " %.2f -%d", sec_Scale[sectab], pageLimit[sectab]);
cmd += s;
if(black[sectab]) cmd += " BLACK";
if(solid[sectab]) cmd += " SOLID";
if(mirror[sectab]) cmd += " MIRROR";
if(rotate[sectab]) cmd += " ROTATE";
if(upside[sectab]) cmd += " UPSIDEDOWN";
/*
if(poscoord[sectab]) ; // not use to print
if(quickplot[sectab]); // not use to print
if(optimize[sectab]); // not use to print
*/
cmd += ";\n";
return;
}
void viewDescript(void) {
string ds;
for (int n = 1 ; n < descrCnt; n++ ) {
if (ds[0] = ' ') {
ds = descriptionLine[n];
ds[0] = ' ';
descriptionLine[n] = ds;
}
}
descriptionLine[0] = "
");
dlgLabel("
");
dlgLabel("
");
dlgCheckBox("&Fill pads (board)", fillpads[tpn]);
dlgCheckBox("&Black", black[tpn]);
dlgCheckBox("Soli&d", solid[tpn]);
}
dlgStretch(1);
dlgLabel(Eagle);
dlgStretch(0);
}
}
dlgStretch(1);
dlgSpacing(10);
dlgHBoxLayout {
dlgLabel("&Scale factor ");
dlgRealEdit(sec_Scale[tpn] , .01, 1000);
dlgStretch(1);
}
dlgHBoxLayout {
dlgLabel("&Page limit ");
dlgSpacing(12);
dlgIntEdit(pageLimit[tpn] , 0, 100);
dlgStretch(1);
}
if (schematic) {
dlgStretch(0);
dlgGroup("Sheet") {
dlgVBoxLayout {
dlgHBoxLayout {
dlgRadioButton("&All ", sheetprint);
dlgLabel(" ");
dlgStretch(1);
}
dlgHBoxLayout {
dlgRadioButton("&From ", sheetprint);
dlgLabel("S&heet ");
dlgIntEdit(sheetprint_from[tpn], 1, lastsheet);
dlgLabel(" &to ");
dlgIntEdit(sheetprint_to[tpn], sheetprint_from[tpn], lastsheet);
dlgStretch(1);
}
dlgHBoxLayout {
dlgRadioButton(" ", sheetprint);
string sl;
sprintf(sl, "%d/%d", sec_Sheet[tpn], lastsheet);
dlgLabel(sl);
dlgStretch(1);
}
dlgHBoxLayout {
dlgRadioButton("Actua&l ", sheetprint);
dlgLabel(actualsheet);
dlgStretch(1);
}
}
}
} // if schematic
}
// *** Layer list to print ***
int Seleclayer;
string layer[] ;
int n = 0;
int ln = strsplit(layer, sec_Layers[tpn], ' ');
for (int x = 0; x < ln; x++) {
int num = strtod(layer[x]);
if (useLayer[num]) {
if(schematic) {
if (num >= 90) {
sprintf(sec_usedlayer[n], "%3s %s", layer[x], lNames[num]);
n++;
}
}
if(board) {
if (num < 90 || num > 100) {
sprintf(sec_usedlayer[n], "%3s %s", layer[x], lNames[num]);
n++;
}
}
}
}
sec_usedlayer[n] = ""; // clear last+1
dlgStretch(0);
dlgSpacing(10);
dlgVBoxLayout {
dlgHBoxLayout { dlgSpacing(100); }
dlgLabel("Printed layers");
dlgListBox(sec_usedlayer, Seleclayer);
}
// *** Layer list to print ***
}
}
dlgSpacing(10);
dlgStretch(1);
tpn++;
}
} // end off while
// ************ End of TAB | SHEET ***********
dlgTabPage("&Help") {
dlgSpacing(10);
dlgHBoxLayout {
dlgSpacing(10);
dlgVBoxLayout {
dlgHBoxLayout {
dlgLabel(Eagle);
dlgSpacing(10);
dlgVBoxLayout {
dlgLabel(EAGLE_SIGNATURE);
dlgSpacing(10);
if (description) {
dlgHBoxLayout {
dlgPushButton("&show Job-Description") viewDescript();
dlgStretch(1);
}
}
else dlgLabel("CAM-Job description is EMPTY");
}
dlgStretch(1);
}
dlgSpacing(10);
dlgLabel(help);
dlgStretch(1);
}
}
}
} // ************ End of all TABs ***********
dlgHBoxLayout {
dlgStretch(0);
dlgPushButton("+OK") dlgAccept();
dlgStretch(0);
dlgPushButton("-Cancel") dlgReject();
dlgStretch(1);
dlgPushButton("&Load CAM-File") {
CAMfileName = dlgFileOpen("select a File", path_cam[0]+"/*.cam", "");
if (CAMfileName) {
exit ("run " + filesetext(argv[0], " ") + " '" + PageLimit_all + "' '" + CAMfileName + "';\n");
}
}
dlgStretch(1);
}
};
if (Result == 0) exit (0);
// make print command
if (test) cmd = "# generatet by " + argv[0] + " from " + CAMfileName + "\n";
for (int tpn = 1; tpn <= sx; tpn++) {
string layer[] ;
int n = 0;
int ln = strsplit(layer, sec_Layers[tpn], ' ');
if (test) cmd += "# Section: " + sec_Name[tpn] + "\n";
if(board) {
if(fillpads[tpn]) {
cmd += "SET DISPLAY_MODE NODRILL;\n";
}
else {
cmd += "SET DISPLAY_MODE REAL;\n";
}
cmd += "RATSNEST;\n";
cmd += "DISPLAY NONE ";
for (int x = 0; x < ln; x++) {
int num = strtod(layer[x]);
if (num < 90 || num > 100) {
if (useLayer[num]) {
sprintf(s, " %s", layer[x]);
cmd += s;
if(num == 21) cmd += " -23 -25 -27 -51";
if(num == 22) cmd += " -24 -26 -28 -52";
n++;
}
}
}
cmd += ";\n";
commandPrint(tpn);
}
if(schematic) {
cmd += "DISPLAY NONE ";
for (int x = 0; x < ln; x++) {
int num = strtod(layer[x]);
if (useLayer[num]) {
if (num >= 90) {
sprintf(s, " %s", layer[x]);
cmd += s;
n++;
}
}
}
cmd += ";\n";
string sh;
switch (sheetprint) {
case 0 : schematic(S) {
S.sheets(SH) {
sprintf(sh, "EDIT '.s%d';\n", SH.number);
cmd += sh;
commandPrint(tpn);
}
}
break;
case 1 : for (int prn = sheetprint_from[tpn]; prn <= sheetprint_to[tpn]; prn++) {
sprintf(sh, "EDIT '.s%d';\n", prn);
cmd += sh;
commandPrint(tpn);
}
break;
case 2 : sprintf(sh, "EDIT '.s%d';\n", sec_Sheet[tpn]);
cmd += sh;
commandPrint(tpn);
break;
case 3 : sprintf(sh, "EDIT '.s%s';\n", actualsheet);
cmd += sh;
commandPrint(tpn);
break;
}
}
}
cmd += "DISPLAY ";
if(board) {
for(int l = 1; l < 90; l++) {
if (useLayer[l]) {
if (lVisible[l]) {
sprintf(s, " %d", l);
cmd += s;
}
else {
sprintf(s, " -%d", l);
cmd += s;
}
}
}
for(l = 100; l < 256; l++) {
if (useLayer[l]) {
if (lVisible[l]) {
sprintf(s, " %d", l);
cmd += s;
}
else {
sprintf(s, " -%d", l);
cmd += s;
}
}
}
cmd += ";\n";
}
if(schematic) {
for(int l = 91; l < 256; l++) {
if (useLayer[l]) {
if (lVisible[l]) {
sprintf(s, " %d", l);
cmd += s;
}
else {
sprintf(s, " -%d", l);
cmd += s;
}
}
}
cmd += ";\n";
sprintf(s, "EDIT '.s%s';\n", actualsheet);
cmd += s;
}
if (test) { if (dlgMessageBox(cmd, "OK", "ESC") != 0) exit (-1);}
exit (cmd);