AnsweredAssumed Answered

Using PIthon to pull InterpolatedValues

Question asked by gfmalek on Nov 5, 2020
Latest reply on Nov 5, 2020 by James Devine

I am trying to write a Python function that pulls InterpolatedValues using the call below, with a given list of strings that represent PIPoint names. I am using the clr module (which is part of the pythonnet package I think) to import the PI AF SDK into a Python environment.


PIPoint.FindPIPoints Method (PIServer, IEnumerable(String), IEnumerable(String)) 


As you can see, this call takes three inputs: a PIServer and two IEnumerable<string>'s.


Passing Python lists to this function does not work.  The second and third arguments have to be objects from the .NET 'System.Collections.Generic' namespace that implement IEnumerable.  Therefore, I use the code below to convert the python list that contains the PIPoint names to a .NET list.




import sys

import clr





from System.Collections.Generic import List


taglist = [ 'tag1', 'tag2' ]


pitagnamelist = List[str]()


for pitag in taglist:


###  From here, I pass pitagnamelist to the FindPIPoints call.

###  I have omitted some parts of the script (such as import of PI AF SDK) that do not pertain to this specific          ###  problem.



The problem is, I would like to hand this script to others to use.  For this approach, they will need to install .NET libraries on their computer - specifically "System.Collections.dll" - in order to add this reference to their Python projects and create .NET IEnumerables.  I am concerned that this may be too much overhead, and could make this program impractical for them.


Is there a way to achieve what I'm trying to do, without requiring so much work from the end user?


Thanks for your help,