2 Replies Latest reply on Apr 16, 2012 11:25 AM by ConditionMonitoring

    Opening a PDI within a PIW, unable to modify

    ConditionMonitoring

      I have managed to open the display, insert a trend onto the display and then close the display. Seemingly working as it should, however when i double click on that entry to view the display the trend is not there, it just opens up a blank display. This is my code.

       

      app.ProcBooks.Open(oBook.Path & "!" & oEntry.Label)

       

                                 Dim PBDisplay As PBObjLib.Display = app.ActiveDisplay

       

                                 plottrend(UnitModel)

       

                                 PBDisplay.Close(PBDisplay.SaveAs(PBDisplay.Path))

       

      where the sub plottrend adds a trend to the display and changes the background of the display to white. Neither of these changes are picked up when i open up that entry. Should i be doing the SaveAs outside of the close method?

        • Re: Opening a PDI within a PIW, unable to modify
          andreas

          Tom, not sure what happens, your code works for me. However, you should do a PBDisplay.Close(True):

           
              Private Sub OpenPIW2Display()
                  Dim oBook As PBObjLib.ProcBook
                  Dim oEntry As PBObjLib.Entry
                  Dim directory As String
                  directory = "C:\Book1.piw"
          
                  app.ProcBooks.Open(directory)
                  oBook = app.ActiveProcBook
                  ' Book1.PIW contains a single entry:
                  ' a link to an empty PDI display
                  oEntry = oBook.Entries.Item(1)
          
                  app.ProcBooks.Open(oBook.Path & "!" & oEntry.Label)
                  Dim PBDisplay As PBObjLib.Display = app.ActiveDisplay
                  plottrend("sinusoid")
                  PBDisplay.Close(True)
              End Sub
          
              Private Sub plottrend(tagname As String)
                  Dim PBDisplay As PBObjLib.Display = app.ActiveDisplay
                  Dim PBTrend As PBSymLib.Trend = CType(PBDisplay.Symbols.Add(PBObjLib.pbSYMBOLTYPE.pbSymbolTrend), PBSymLib.Trend)
                  PBTrend.AddTrace(tagname)
                  PBDisplay.BackgroundColor = &HFFFFFF
              End Sub