3 Replies Latest reply on Mar 7, 2017 11:35 PM by rsun

    Saving ProcessBook Displays to PDI

    vmjohnson

      I have a C# application which exports ProcessBook displays to PDI or SVG for use in Coresight. Saving to SVG works fine but when I save to PDI using 'PBObjLib.pbpdFILEFORMAT.pbpdFormatDisplay' an exception is thrown which reads 'Unable to Save.'. When I save from ProcessBook to PDI it works ok. I'm using OSIsoft.PBObjLib dated 9/2/2016 version 4.0.30319.

       

      Thanks

        • Re: Saving ProcessBook Displays to PDI
          John Messinger

          Can you share the full code snippet your are using to save the Display object?

          • Re: Saving ProcessBook Displays to PDI
            vmjohnson

            John, the code in BOLD is what's generating the exception.

             

            app = new PBObjLib.Application();

            PBObjLib.ProcBook tmpBook = app.ProcBooks.Open(txtProcessBook.Text);


            foreach (PBObjLib.Entry entry in tmpBook.Entries)
            {
                 if (entry.Type == 1 || entry.Type == 4)
                 {
                      try
                      {
                           PBObjLib.pbLinkOptions option = entry.Options;

                           if (Directory.Exists(txtLevel1OutputDirectory.Text) == false)
                                GrantAccess(Directory.CreateDirectory(txtLevel1OutputDirectory.Text));

                         

                           entry.Execute(false);
                           PBObjLib.Display display = app.ActiveDisplay;
                           if (display != null)
                           {
                                if (ExportToPDIChk.Checked == true)

                                {
                                     display.SaveAs(txtLevel1OutputDirectory.Text + "\\" + entry.Label,                                                                  PBObjLib.pbpdFILEFORMAT.pbpdFormatDisplay);

                                }
                                if (ExportToSVGChk.Checked == true)

                                {
                                        display.SaveAs(txtLevel1OutputDirectory.Text + "\\" + entry.Label,                                                                  PBObjLib.pbpdFILEFORMAT.pbpdFormatSVG);

                                }
                                display.Close(false);
                           }

                      }
                      catch (Exception ex)
                     {
                          //if (ex.Message.Contains("Internal application") == false)
                          //{
                               // MessageBox.Show(ex.Message, "Error");
                                //break;
                          //}
                     }
               }
            }