public override void Execute(EventDescription token) { if (code == "") { code = "None"; } for (int i = 0; i < input_count; i++) { AppGlobals.PySetVar("in" + (i + 1).ToString(), InputNodes[i].Object); } object result = null; AppGlobals.PyExecute(code, Microsoft.Scripting.SourceCodeKind.Statements); for (int i = 0; i < output_count; i++) { var name = "out" + (i + 1).ToString(); if (AppGlobals.PyVarExists(name)) { result = AppGlobals.PyGetVar(name); if (result.GetType() == typeof(IronPython.Runtime.List)) { IronPython.Runtime.List lst = (IronPython.Runtime.List)result; //var tmp = new List<object>(); //foreach (var item in lst) //{ // tmp.Add(item); //} result = lst;// tmp.ToArray(); } var tmp = PyToNET(result); if (tmp != null) { OutputNodes[i].Object = (double[])tmp; } else { OutputNodes[i].Object = result; } } AppGlobals.PyRemVar(name); } for (int i = 0; i < input_count; i++) { AppGlobals.PyRemVar("in" + (i + 1).ToString()); } }