Page Tree
Other Releases
...
Must use for .Net developers, the Python namespace can be used in any script editor inside your project environment (Tasks, Classes and CodeBehind). Basically, all you need is to install Python for .NET.
The Python namespace provides several .Net methods to interact with Python codes and objects. See some of those methods below:
...
Code Block |
---|
string ExecuteCode(string code, string workingDirectory = null, Dictionary<string, object> locals = null, bool keepValuesAsPython = false) string code = py file name string workingDirectory = Working directory. It will be added in 'sys.path' Dictionary<string, object> locals = Local variables inside Python code. Default is null. bool keepValuesAsPython = Keep retuned values as Python objects or convert to .NET objects. Default is false. string return = If success return null else string contains error. |
Code Block |
---|
public static object FromPython(object value) object value = Python value object returns = NET value |
Code Block |
---|
public static void CopyPythonObjectToTag(object source, string tagName) object source = Python object. string tagName = Tag Array or User Template. |
Code Block |
---|
public static void CopyTagToPythonObject(string tagName, object target) string tagName = Tag Array or User Template. object target = Python object. |
Code Block |
---|
public static object CreatePythonObjectFromPyFile(string pyFileName, string className, object[] parameters = null, string tagName = null) string pyFileName = Python file name containg the definition of Python class. string className = Python class name. object[] parameters = Parameters for Python class while creating Python object. string tagName = Tag name (Optional, Tag Array or User Template). If tag exists then copy all values to new Python object. object returns = Reference to new Python object. |
Code Block |
---|
public static IDictionary<string, object> GetAttributesPythonObject(object pythonObject, bool keepValuesAsPython = false) object pythonObject = Python object/ bool keepValuesAsPython = Keep retuned values as Python objects or convert to .NET objects. Default is false. IDictionary<string, object> = Dictionary contains attributes (name and value). |
Code Block |
---|
public static void SetAttributesPythonObject(object pythonObject, IDictionary<string, object> dic) object pythonObject = Python object. IDictionary<string, object> = Dictionary contains attributes (name and value) for setting. |
Code Block |
---|
public static string DumpPythonObjectToString(object pythonObject) object pythonObject = Python object. string returns = Dump information of object. |
Note |
---|
If you need others other Python modules and libraries (such as numpy, pythonnet, matplotlib, etc.) must be installed at same location Python Engine (python.exe). |
...