7 Replies Latest reply on Sep 23, 2009 10:20 PM by spilon

    Different behaviour BatchGroup object casting


      Hello guys,


      I need to cast a Display Symbol object to a BatchGroup object.


      I did it successfully inside an "OpenDisplay" event with the following code (i.e. opening an existing file...):

      // Loading BatchGroup1
      foreach (PBObjLib.Symbol symb in theApp.ActiveDisplay.Symbols)
          switch (symb.Name)
              case "BatchGroup1":
                  if (symb.Type == (int)PBObjLib.pbSYMBOLTYPE.pbSymbolBGroup)
                      result = (BatchGroup)symb;

      but when I try to do it inside an "AfterSymbolAdded" event, I receive the following error:


      "Unable to cast object of type 'PBObjLib.SymbolClass' to type 'OSIsoft.ProcessBook.BatchView.BatchGroup"




      Again, it is exacly the same procedure called by two different events:


      - OpenDisplay - when opening an existing file containing the BatchGroup1


      - AfterSymbolAdded - when creating a new Display and inserting a new BatchGroup1




      Do you have some idea ?


      Many thanks for your help and have a nice evening!




      Best regards,