#usage "Convert a CAM job to a PRINT command\n" "
"
"Usage: RUN cam2print [ filename [ outputfile ]]
"
"Use PDF for outputfile to print in a PDF."
"
"
"Tip: Assign a funktion key with"
"
"
"ASSIGN Shift+Ctrl+Alt+P 'run cam2print.ulp;';"
"
"
"ASSIGN Shift+Ctrl+Alt+P 'run cam2print.ulp PDF;';"
"
"
"ASSIGN Shift+Ctrl+Alt+P 'run cam2print.ulp myjob.cam;';"
"
"
"ASSIGN Shift+Ctrl+Alt+P 'run cam2print.ulp myjob.cam PDF;';"
"
"
" \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";
else cmd += " -BLACK";
if(solid[sectab]) cmd += " SOLID";
else cmd += " -SOLID";
if(mirror[sectab]) cmd += " MIRROR";
else cmd += " -MIRROR";
if(rotate[sectab]) cmd += " ROTATE";
else cmd += " -ROTATE";
if(upside[sectab]) cmd += " UPSIDEDOWN";
else cmd += " -UPSIDEDOWN";
/*
if(poscoord[sectab]) ; // not use to print
if(quickplot[sectab]); // not use to print
if(optimize[sectab]); // not use to print
*/
if (fileprintout) {
cmd += " FILE '" + sec_Out_put[sectab] + ".pdf'";
}
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(8);
dlgIntEdit(pageLimit[tpn] , 0, 100);
dlgStretch(1);
}
dlgLabel("* preset page limit for all pages start this ULP from command line by:
run " + filename(argv[0]) + " n
");
}
// *** 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) { // incl. layer 100, 25.03.2008
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);
dlgLabel(checkbackslash(CAMfileName));
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) {
string r;
sprintf(r, "run '%s' '%s' %s;\n", filesetext(argv[0], ""), CAMfileName, fileprintout);
exit (r);
}
}
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 += ";\nSET DISPLAY_MODE REAL;\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", "Cancel") != 0) exit (-1);}
// output("c:/tmp/cam2print.scr", "wt") printf("%s", cmd);
exit (cmd);