Passing and retrieving objects using pythonnet

1.7k views Asked by At

How do , In general pass and return objects using pythonnet. For example, this works fine if I'm to return a number:

 dynamic par = Python.Runtime.Py.Import("mypackage.pythonfile");
 var t = par.GetPPMError(100, 100.001);

where I import a package which as a file called'pythonfile'

This returns a number using the pythonfile.GetPPMError() method

How do I do this:

 //C# arrays var double x = new double[500]
 //C# array var double y = new double[500]
 dynamic par = Python.Runtime.Py.Import("mypackage.pythonfile");
 var p = par.GetPeak(x,y)

where GetPeak is a python method in the 'pythonfile.py' and p is a class as such for example:

class Peak:
def __init__(self):
    self.FileID = ""
    self.RT = 0
    self.Intensity = 0
    self.MZ = 0

which can then be converted to a C# object?

0

There are 0 answers