File name generation by customized printer.pltcfg (include FormName in file name)

Hello,

a long time ago, a problem "how to include form name in plot file name" was solved in that thread: https://communities.bentley.com/products/microstation/microstation_printing/f/19568/t/63309.aspx

But it was about how to include form name in plot file name, using Print Organizer. Now I'd like to do it directly from printer driver. So, editing Printer Driver, in Default Print File name tab -> File name I'd like to have an expression like:

$(MS_PLTFILES)$(basename(_DGNFILE))-FormName

FormName shoud be taken from paper sizes defined by Windows printer and shown in "Paper:" drop-down list into Microstation's Print dialog.

PD SS3 09.397.

Thanks in advance, Wojtek

  • You'll need to create a named expression in a DGNLIB in your workspace.  Look for the documentation on named expressions if you're unfamiliar with this process.

    Give your named expression a descriptive name, for example "DgnBaseNameFormName".

    You'll need to add three symbol sets to the expression: "ConfigVar", "System.Path", and "PrintDefinition".

    For the expression itself, use

    ConfigVar.GetExpandedConfigVar("MS_PLTFILES") & System.Path.GetFileNameWithoutExtension (PrintDefinition.SourceFile) & "-" & PrintDefinition.FormName

    This is a bit different than when defining an expression for Print Organizer output file names, because the single-Print dialog expects the .pltcfg default output file name to specify both the directory and the file name (but not the extension).  Print Organizer only wants the base file name.

    Specify the named expression in the .pltcfg using the printer driver configuration editor.  Replace the File Name string under Default Print File Name with "<expr?name=DgnBaseNameFormName>" (not including the quotes and using your expression name).

     

          
    .

    Answer Verified By: WojtekM 

  • Hi Andrew, many thanks for your reply. Works like a charm.

    One more thing to mention: by default, "PrintDefinition" is not shown on drop-down list in Named Expression dialog (see image). But it's enough to show print dialog and close it, and PrintDefinition will show. Probably one more dll should be loaded.


    Regards, Wojtek

  • Yes, that's on purpose.  Publishing the PrintSet and PrintDefinition symbols unconditionally would result in a relatively large DLL loading at product startup that would not otherwise be needed if not printing.  For improved startup performance and reduced memory overhead in most work sessions, we decided to delay publishing the symbols until either the Print dialog or Print Organizer was opened.

    After I posted, I realized a better solution would be to keep the $(MS_PLTFILES) reference in the .pltcfg default output file value.  Simply replace the file name component with an <expr?name=xxx> token.  The <expr> token can be used in conjunction with literal strings or traditional configuration variable references.  That approach would allow you to use the same named expression in both the Print dialog and Print Organizer (the named expression would not specify a directory).

          
    .