4 Replies Latest reply on Dec 4, 2018 12:34 AM by tramachandran

    AFElement. FindElements is not working in Python

    Krishna3068

      import sys

      sys.path.append('C:\\Program Files (x86)\\PIPC\\AF\\PublicAssemblies\\4.0\\')

      import clr 

      clr.AddReference('OSIsoft.AFSDK') 

      from OSIsoft import AF 

      from win32com.client.dynamic import Dispatch

      import System 

      from OSIsoft.AF.PI import * 

      from OSIsoft.AF.Search import * 

      from OSIsoft.AF.Asset import * 

      from OSIsoft.AF.Data import * 

      from OSIsoft.AF.Time import *

      from OSIsoft.AF import *

      import OSIsoft

      piServers = PIServers() 

      piServer = piServers.DefaultPIServer

      db= AF.PISystems().DefaultPISystem.Databases.DefaultDatabase

      searchroot=()

      namestring=System.String("ET Template")

      elemtemp=AFSearchField.Template

      searchFullHierarchy= System.Boolean(True)

      sortField=AFSortField.Name

      sortOrder=AFSortOrder.Ascending

      maxCount=10000

       

      I am getting following error

       

      foundattribute=AF.Asset.AFElement.FindElements(db,searchroot,namestring,elemtemp,searchFullHierarchy,sortField,sortOrder,10000) 

      File "<ipython-input-21-c6b3e3d75fc0>", line 1, in <module>

          foundattribute=AF.Asset.AFElement.FindElements(db,searchroot,namestring,elemtemp,searchFullHierarchy,sortField,sortOrder,0,100,10000)

       

       

      TypeError: No method matches given arguments

       

      Can you please help me out how to solve this. Same code is running in C but not in python