16 Replies Latest reply on Dec 22, 2010 12:53 PM by night2day

    Show/Hide Trendline-Feature

    night2day

      Hello community,

       

      i'd like to know if it is possible to use the "new" hide-trendline-feature

       

      within vba code. Background is the wish to hide or show traces under

       

      different conditions without using remove/add.

       

       

       

      Greetings

       

      Wolfgang

        • Re: Show/Hide Trendline-Feature
          hanyong

          Hi Wolfgang,

           

          There is a boolean property for Trend object, Trend.ShowTrace, that allows you to programmatically show/hide the current trace. An example here can be used to show/hide the 1st trace (or trendline).

          Sub HideTrace()
              Dim trend1 As Trend
              Set trend1 = ThisDisplay.trend1
              trend1.CurrentTrace = 1
              trend1.ShowTrace = False
          End Sub

          Sub ShowTrace()
              Dim trend1 As Trend
              Set trend1 = ThisDisplay.trend1
              trend1.CurrentTrace = 1
              trend1.ShowTrace = True
          End Sub

           

          What's next would be to determine which trace(s) to show and hide based on your requirement.

            • Re: Show/Hide Trendline-Feature
              night2day

              Hello Han,

               

              thank you very much.

               

              Greetings

               

              Wolfgang

              • Re: Show/Hide Trendline-Feature
                wpurrer

                Hello Wolfgang,

                 

                which Trend object do you use?

                 

                I use "PBSimLib.Trend" and I couldn't find any property ShowTrace!

                 

                 

                 
                Symbol sym = null;
                
                foreach( Symbol s in this.Application.ActiveDisplay.SelectedSymbols )
                {
                       sym = s;
                }
                
                Trend t = (Trend)sym;
                

                 

                 

                 

                 

                  • Re: Show/Hide Trendline-Feature
                    night2day

                    Hello Wollfgang,

                     

                    working code

                     
                    Private Sub TrendVisible(ByVal strDirection As String, 
                                                          ByVal lngNumber As Long, 
                                                          ByVal blnVisible As Boolean)
                    
                    Dim objTrend As PBSymLib.Trend
                    
                     If strDirection = "MD" Then
                       Set objTrend = ThisDisplay.TrendMD
                     Else
                       Set objTrend = ThisDisplay.TrendCD
                     End If
                    
                     objTrend.CurrentTrace = lngNumber
                     objTrend.ShowTrace = blnVisible
                     Set objTrend = Nothing
                    
                    End Sub
                    

                     

                     

                    Witch version of Processbook do you use?

                     

                    Greetings

                     

                    Wolfgang

                      • Re: Show/Hide Trendline-Feature
                        wpurrer

                        I have changed the example above.

                         

                        we use processbook 3.2 with visualstudio 2008 and c#

                         

                        (we are developing a plugin for the processbook)

                          • Re: Show/Hide Trendline-Feature
                            night2day

                            Hello Wolfgang,

                             

                            bool b = t.ShowTrace;

                             

                            is aviable if you bind

                             

                            using PBSymLib;

                             

                            using PBObjLib;

                             

                            You need references to PI-ProcessBook Symbol Library and PI-Processbook Type Library

                             

                            Greetings

                             

                            Wolfgang

                              • Re: Show/Hide Trendline-Feature
                                wpurrer

                                Hallo Wolfgang

                                 

                                We have referenced

                                 

                                C:\Program Files (x86)\PIPC\Procbook\OSIsoft.PBObjLib.dll

                                 

                                C:\Program Files (x86)\PIPC\Procbook\OSIsoft.PBSymLib.dll

                                 

                                Fehler     1     "PBSymLib.Trend" enthält keine Definition für "ShowTrace", und es konnte keine Erweiterungsmethode "ShowTrace" gefunden werden, die ein erstes Argument vom Typ "PBSymLib.Trend" akzeptiert. (Fehlt eine Using-Direktive oder ein Assemblyverweis?)     C:\Users\ltgsju\Desktop\LAG_PBAddin_DetailGridView\LAG_PBAddin_DetailGridView\PBDetailGridComponent.cs     79     18     LAG_PBAddin_DetailGridView

                                 

                                mfg

                                 

                                Wolfgang

                                  • Re: Show/Hide Trendline-Feature
                                    wpurrer

                                    We see the "ShowTrace" Property inside the VBA object browser, but not inside the visual studio 2008 c# object browser.

                                     

                                    The file date from OSIsoft.PBSymLib.dll is the 28.08.2009

                                    • Re: Show/Hide Trendline-Feature
                                      night2day

                                      Hallo Wolfgang,

                                       

                                      are you sure you have set the using directives i wrote befor?

                                       

                                      In my example the property ShowTrace exists (also shown at

                                       

                                      the intellisense) at object t (trace).

                                       

                                      Tooltip says bool IDualTrend.ShowTrace

                                       

                                      with boolean type.

                                       
                                      using System;
                                      
                                      using System.Windows;
                                      
                                      using PBSymLib;
                                      
                                      using PBObjLib;
                                      
                                      namespace PIAccessTest
                                      
                                      {
                                      
                                         /// 
                                      
                                         /// Interaktionslogik für MainWindow.xaml
                                      
                                         /// 
                                      
                                         public partial class MainWindow : Window
                                      
                                         {
                                      
                                             private ProcBooks  objPB = new ProcBooks();
                                      
                                             public MainWindow()
                                      
                                             {
                                      
                                                 InitializeComponent();
                                      
                                             }
                                      
                                             private void button1_Click(object sender, RoutedEventArgs e)
                                      
                                             {
                                      
                                                 Symbol sym = null;
                                      
                                                 foreach (Symbol s in this.objPB.Application.ActiveDisplay.SelectedSymbols) 
                                      
                                                 { 
                                      
                                                     sym = s; 
                                      
                                                 } 
                                      
                                                 Trend t = (Trend)sym;
                                      
                                                 bool a = false;
                                      
                                                 t.ShowTrace = a;
                                      
                                             }
                                      
                                         }
                                      
                                      }
                                      

                                       

                                       

                                      Gruß

                                       

                                      Wolfgang