Print organizer key-ins

Hello

I have some code where I call print organizer key-ins. I'm trying to set the print destination to my pdf file to c:\temp\.

I have already made a pset file where I set the default print definition name to <model name> and the output file name to <design name>. Here is the code:

private void toolStripButtonPrint_Click(object sender, EventArgs e)

{

PrintFrm form = new PrintFrm(toolStripComboBoxPages);

DialogResult dr;

string model;

int count = 0;

 

dr = form.ShowDialog();

if (dr == DialogResult.OK)

{

RunProgressBar rpb = new RunProgressBar();

rpb.progressbar.Minimum = 0;

rpb.progressbar.Step = 1;

if (mainAddin.Instance._language.ToLower().CompareTo("norsk") == 0)

rpb.Text = "Skriver...";

else

rpb.Text = "Printing...";

 

rpb.Show();

rpb.Refresh();

if (form.page == 0)

rpb.progressbar.Maximum = 9;

else if (form.page == 1)

rpb.progressbar.Maximum = form.pageTo - form.pageFrom + 9;

else

rpb.progressbar.Maximum = toolStripComboBoxPages.Items.Count + 8;

rpb.progressbar.PerformStep();

// Initialize print organizer

BIM.Session.Instance.Keyin("mdl load bentley.microstation.printorganizer.dll");

rpb.progressbar.PerformStep();

// Finds pset file

string organizerFileName = mainAddin.Instance.ActiveSettings.Printers[form.printerDriver].OrganizerFile;

string printerDriverFileName = mainAddin.Instance.ActiveSettings.Printers[form.printerDriver].PrinterDriver;

string fullFileName = ISYSettingsMicroStationMethods.FindFileUsingConfigVarValue("TCPLOT_PLOTCFG", organizerFileName);

rpb.progressbar.PerformStep();

// Adds pset file

if (fullFileName == null)

BIM.Session.Instance.Keyin("PRINTORGANIZER NEW");

else

BIM.Session.Instance.Keyin("PRINTORGANIZER OPEN " + fullFileName);

rpb.progressbar.PerformStep();

// Adds printer driver

BIM.Session.Instance.Keyin("PRINTORGANIZER PRINTERDRIVER " + printerDriverFileName);

rpb.progressbar.PerformStep();

if (isSystemPrinter(printerDriverFileName))

{

// Adds printer

BIM.Session.Instance.Keyin("PRINTORGANIZER PRINTERNAME " + form.printer);

// Adds # of copies

BIM.Session.Instance.Keyin("PRINTORGANIZER PRINTCOPIES " + form.copies);

}

else

{

// Adds print destination

string desname;

desname = "C:\\temp\\";

BIM.Session.Instance.Keyin("PRINTORGANIZER PRINTDESTINATION " + desname);

}

rpb.progressbar.PerformStep();

// Adds models

if (form.page == 0)

{

model = "PRINTORGANIZER ADD MODEL \"" + _attachedLibrary + "\" \"" + toolStripComboBoxPages.Text + "\"";

BIM.Session.Instance.Keyin(model);

rpb.progressbar.PerformStep();

}

else if (form.page == 1)

{

foreach (object item in toolStripComboBoxPages.Items)

{

if (count >= form.pageFrom && count <= form.pageTo)

{

model = "PRINTORGANIZER ADD MODEL \"" + _attachedLibrary + "\" \"" + item.ToString() + "\"";

BIM.Session.Instance.Keyin(model);

rpb.progressbar.PerformStep();

}

count++;

}

}

else

{

foreach (object item in toolStripComboBoxPages.Items)

{

model = "PRINTORGANIZER ADD MODEL \"" + _attachedLibrary + "\" \"" + item.ToString() + "\"";

BIM.Session.Instance.Keyin(model);

rpb.progressbar.PerformStep();

}

}

 

//Adds paper size

BIM.Session.Instance.Keyin("PRINTORGANIZER APPLYPRINTSTYLE ALL " + form.paperSize);

rpb.progressbar.PerformStep();

// Other

BIM.Session.Instance.Keyin("PRINTORGANIZER SUBMITAS SINGLE");

BIM.Session.Instance.Keyin("PRINTORGANIZER PRINT ALL");

rpb.progressbar.PerformStep();

if (mainAddin.Instance._language.ToLower().CompareTo("norsk")==0)

rpb.Text = "Print ferdig.";

else

rpb.Text = "Print Complete.";

 

rpb.Refresh();

 

BIM.Session.Instance.Keyin("PRINTORGANIZER EXIT");

rpb.Close();

}

form.Close();

}

:end code

 Even though I set (PRINTORGANIZER DESTINATION C:\temp\) the pdf file still goes to

MS_DGNOUT. Can anyone tell me what I'm doing wrong?

 

regards,

Øyvind Olsen

Norconsult Informasjonssystemer AS

 

  • I keyin the following command sequence after I open my test.pset in Print Organizer

    PrintOriganizer PrintDestination C:\Temp
    PrintOrganizer Print All

    The output pdf files are really created into C:\Temp folder. Please make sure if the C:\Temp folder exists in your box.

     



  • Hello

    I found out what was wrong. When the "SUBMITAS" keyin came after the

    "PRINTDESTINATION" keyin, the "SUBMITAS" keyin overwrote the print destination...

     

    This Worked:

    BIM.Session.Instance.Keyin("PRINTORGANIZER SUBMITAS SINGLE");

    // Adds print destination
    string desname = mainAddin.ComApp.ActiveDesignFile.FullName;
    desname = desname.Replace(".dgn", ".pdf");
    model = "PRINTORGANIZER PRINTDESTINATION \"" + desname + "\"";
    BIM.Session.Instance.Keyin(model);

    BIM.Session.Instance.Keyin("PRINTORGANIZER PRINT ALL");

     

    Thank you for helping

    Regards,

    Øyvind Olsen

    Norconsult Informasjonssystemer AS

  • Hello

    I have one more question to this issue.

    Is the "SUBMITAS" keyin nessary when the "PRINTDESTINATION" keyin is used...?

    Seems to me that they overwrite eachother...

    Regards,

    Øyvind Olsen

    Norconsult Informasjonssystemer AS

  • Hi,

    The SUBMITAS option only plays a role for PDF output because here you can create a single composite PDF file or separate PDF files.

    For this workflow, PRINTDESTINATION and SUBMITAS are related. If SUBMITAS is SINGLE then PRINTDESTINATION must be a file name. If SUBMITAS is SEPARATE then PRINTDESTINATION must be a folder name.

    This is the problem I saw in the initial snippet of code you posted. You set SUBMITAS to SINGLE but then specified a folder name for PRINTDESTINATION. In the more recent snippet you posted, PRINTDESTINATION was correctly set to a file name.

    As to the order of the keyins, currently you must specify SUBMITAS before PRINTDESTINATION. One could argue that the order should not matter, and I agree. I will file a Trouble Report (TR) for this so that it is fixed for the next release.

    Thanks.

    Dennis Abreo

     

  • Dennis,

    Thank you for your reply. That clarified my problem...

     

    regards,

    Øyvind Olsen

    Norconsult Informasjonssystemer AS