I’ve been successfully using Rhino.Runtime.PythonScript to run IronPython scripts directly in C#:
private void RunScript(ref object a)
{
var script = Rhino.Runtime.PythonScript.Create();
script.ExecuteScript("import sys\na=sys.version");
a = script.GetVariable("a");
}
Now, I’m attempting to execute Python 3 code directly from C# using the RhinoCodePlatform.Rhino3D.Languages.Python3Script class:
private void RunScript(ref object a)
{
var script = RhinoCodePlatform.Rhino3D.Languages.Python3Script.Create();
script.ExecuteScript("import sys\na=sys.version");
a = script.GetVariable("a");
}
PythonInCSharp.gh (9.4 KB)
It seems that despite using Python3Script, it still executes Python 2 code. @eirannejad, could you please advise if there’s a method to execute Python 3 code directly from C# in Rhino? Any help or alternative methods would be greatly appreciated.
3 posts - 2 participants
