10 Replies Latest reply on Feb 24, 2016 2:16 PM by xando

    Processbook toolbar problem

    xando

      Hi,

       

      I created a tool, a button in the toolbar off the Processbook and I have a problem with it.

      I start a picture, a PDI from a drive T:\Fabriksinfo\Start.pdi and the picture is loaded and it is Ok but the first time I click on my tool the only thing

      that is happens is that the same PDI is loaded from the UNC address \\fgssfimbul.forestproducts.sca.com\data_t\fabriksinfo\start.pdi and now I

      have two start.pdi loaded, I can see that in the VBA-editor. After this first time the tool is working as expected. Why is this happening?

       

      My Processbook-version is 2015, 3.5.0.284

       

      /Anders

        • Re: Processbook toolbar problem
          wehrich

          Hi Anders,

           

          Could you post your VBA code? Doing so would help determine the root of the problem.


          Thanks,

          Will

            • Re: Processbook toolbar problem
              xando

              Hi Will,

               

              It’s the definition off the tools and I tried from VBA like this:

               

              Public Sub SCAToolBar()
              
                  Dim pBscaToolbar As PBObjLib.PBCommandBar
                  'pBscaToolbar = Application.ActiveDisplay.Application.CommandBars.Item("SCA Toolbar")
                  Set pBscaToolbar = Application.ActiveDisplay.Application.CommandBars("SCA Toolbar")
                  If (pBscaToolbar Is Nothing) Then
              
                      Set pBscaToolbar = Application.ActiveDisplay.Application.CommandBars.Add("SCA Toolbar")
                      pBscaToolbar.Position = pbBarPosition.pbBarTop '
              
                      Dim scaButton As PBCommandBarButton
                      Set scaButton = pBscaToolbar.Controls.Add(pbControlType.pbControlButton)
                      scaButton.Style = pbButtonStyle.pbButtonIconAndCaption
                      scaButton.Caption = ""
                      scaButton.ToolTipText = "Detaljinformation för valt värde"
                      'scaButton.LoadFace (startupPath & toolbarDetailsBitmap)
                      scaButton.OnAction = "DetailedInfo"
              
                      Set scaButton = pBscaToolbar.Controls.Add(pbControlType.pbControlButton)
                      scaButton.Style = pbButtonStyle.pbButtonIconAndCaption
                      scaButton.Caption = ""
                      scaButton.ToolTipText = "Histogram för valt värde"
                      'scaButton.LoadFace (startupPath & toolbarHistogramBitmap)
                      scaButton.OnAction = "ExcelHistogram"
                  End If
              End Sub
              

              and from VB to a DLL

               

              Public Sub SCAToolBar(ByVal Disp As Display)
                      Dim pBscaToolbar As PBObjLib.PBCommandBar
                      pBscaToolbar = Disp.Application.CommandBars.Item(toolbarName)
                      If (pBscaToolbar Is Nothing) Then
              
                          pBscaToolbar = Disp.Application.CommandBars.Add(toolbarName)
                          pBscaToolbar.Position = pbBarPosition.pbBarTop
              
                          Dim scaButton As PBCommandBarButton
                          scaButton = pBscaToolbar.Controls.Add(pbControlType.pbControlButton)
                          scaButton.Style = pbButtonStyle.pbButtonIconAndCaption
                          scaButton.Caption = ""
                          scaButton.ToolTipText = "Detaljinformation för valt värde"
                          scaButton.LoadFace(startupPath & toolbarDetailsBitmap)
                          scaButton.OnAction = "DetailedInfo"
              
                          scaButton = pBscaToolbar.Controls.Add(pbControlType.pbControlButton)
                          scaButton.Style = pbButtonStyle.pbButtonIconAndCaption
                          scaButton.Caption = ""
                          scaButton.ToolTipText = "Histogram för valt värde"
                          scaButton.LoadFace(startupPath & toolbarHistogramBitmap)
                          scaButton.OnAction = "ExcelHistogram"
                      End If
                  End Sub
              

              The call if like this

               

              scaTools.SCAToolBar Application.ActiveDisplay

               

              /Anders

              Från: William Ehrich

              Skickat: den 5 februari 2016 00:09

              Till: Dohrman Anders (Sogeti)

              Ämne: Re:  - Processbook toolbar problem

               

              PI Square <https://pisquare.osisoft.com/?et=watches.email.thread>

               

               

              Processbook toolbar problem

               

              reply from William Ehrich<https://pisquare.osisoft.com/people/wehrich?et=watches.email.thread> in All Things PI - Ask, Discuss, Connect - View the full discussion<https://pisquare.osisoft.com/message/60272?et=watches.email.thread#60272>

                • Re: Processbook toolbar problem
                  Asle Frantzen

                  Hi Anders

                   

                  You'll have to post the VBA for the functions DetailedInfo and ExcelHistogram. The code you posted seems to create and register a toolbar with two buttons without any problems, so if there is an issue it'll have to be within any of the two functions.

                    • Re: Processbook toolbar problem
                      xando

                      Hi,

                       

                      Yes, of course, sorry…

                       

                      VBA

                      Public Sub ExcelHistogram()
                      
                          Dim tag As String
                          tag = scaTools.getTagAtMouse(Application.ActiveDisplay)
                          If (tag <> "") Then
                      
                              Application.ActiveDisplay.MousePointer = pbMPHourGlass
                      
                              If (scaTools.ExcelHistogram() = True) Then
                                  SendKeys (tag)  'Send tagnamn
                              End If
                      
                              Application.ActiveDisplay.MousePointer = pbMPDefault
                          End If
                      End Sub
                      
                      Public Sub DetailedInfo()
                          scaTools.DetailedInfo ThisDisplay.Application.ActiveDisplay
                      End Sub
                      
                      DLL (VB.NET)
                      
                      Public Sub New()
                      
                          Dim piscaPBokTools As PIModule
                          Try
                              Dim piSDK As New PISDK.PISDK
                              Dim piServer As Server = piSDK.Servers("spice.ortv.sca.se")
                              piscaPBokTools = piServer.PIModuleDB.PIModules.Item("Östrand\Konfig\scaPBokTools")
                          Catch ex As Exception
                              MsgBox("Construct Error " & ex.Message)
                              Return
                          End Try
                      
                          Try
                              startupPath = piscaPBokTools.PIProperties("startupPath").Value
                              histogramPath = piscaPBokTools.PIProperties("excelHistogram").Value
                              toolbarDetailsBitmap = piscaPBokTools.PIProperties("toolbarDetailsBitmap").Value
                              toolbarHistogramBitmap = piscaPBokTools.PIProperties("toolbarHistogramBitmap").Value
                              toolbarName = piscaPBokTools.PIProperties("toolbarName").Value
                              piDatalinkPath = piscaPBokTools.PIProperties("PiDatalinkPath").Value
                          Catch ex As Exception
                              MsgBox("Construct Error " & ex.Message)
                          End Try
                      End Sub
                      
                      Public Sub DetailedInfo(ByVal disp As Display)
                          If (disp.Application.DockWindows.Item("Details").Visible = True) Then
                              disp.Application.DockWindows.Item("Details").Visible = False
                          Else
                              disp.Application.DockWindows.Item("Details").Visible = True
                          End If
                      End Sub
                      
                      Public Function ExcelHistogram() As Boolean
                      
                          If (objExcel Is Nothing) Then
                      
                              Try
                                  objExcel = New Excel.Application
                                  If (objExcel Is Nothing) Then
                                      MsgBox("Kan inte starta Excel i modul scaPBokTools", vbExclamation)
                                      Return False
                                  End If
                      
                              Catch ex As Exception
                                  MsgBox("Error vid start av Excel i modul scaPBokTools: " & ex.Message)
                                  Return False
                              End Try
                          End If
                      
                          ' Register Pi Datalink
                          Try
                              objExcel.RegisterXLL(piDatalinkPath)
                          Catch ex As Exception
                              MsgBox("Error register PiDataLink: " & ex.Message)
                              Return False
                          End Try
                      
                          Try
                              With objExcel
                                  .Visible = True
                                  Dim objDoc As Excel.Workbook = .Workbooks.Open(startupPath & histogramPath, , 1)  'Read only
                                  objDoc = Nothing
                              End With
                          Catch ex As Exception
                              MsgBox("Error loading: " & startupPath & histogramPath & " " & ex.Message)
                              Return False
                          End Try
                      
                          Return True
                      End Function
                      

                      /Anders

                       

                      Från: Asle Frantzen

                      Skickat: den 9 februari 2016 09:53

                      Till: Dohrman Anders (Sogeti)

                      Ämne: Re:  - Processbook toolbar problem

                       

                      PI Square <https://pisquare.osisoft.com/?et=watches.email.thread>

                       

                       

                      Processbook toolbar problem

                       

                      reply from Asle Frantzen<https://pisquare.osisoft.com/people/af_amitec?et=watches.email.thread> in PI Visualization Development - View the full discussion<https://pisquare.osisoft.com/message/60442?et=watches.email.thread#60442>