Pyhull in rhino python

Hi,

I would love to use the pyhull module in Rhino Python. But after some research I found out that the pyhull module needs the numpy module.
Here is the problem: numpy is not available for Rhino Python anymore, because numpy is not working with Iron Python.
Is that still true?

  1. Is there any other way to implement the pyhull module in Rhino Python?

Thanks a lot

this post may help. Haven’t tried it myself but might point you in the right direction - http://stevebaer.wordpress.com/2011/06/27/numpy-and-scipy-in-rhinopython/

You can definitely get numpy working, as @stevebaer details in the post @andheum mentioned. As its a normal cpython module, I would assume a similar process is necessary to get pyhull working.

Thanks for your reply @andheum and @defterGoose. There is also another person (see in the comments of stevebear link) who has problems to get numpy work with Ironpython. As I understand that installing modules only works in 32 bit Rhino, because of the necessary DLLs.
Maybe I’m wrong, but is it possible to get bumpy and pyhull work, when I try to install a IDE such as pycharm and than to couple it with Rhino Python. Is that possible?

I just found a way to execute a Python script from a C# component in Grasshopper!
(Not with IronPython, but with Python 2.7). So numpy and scipy should work.
(I just tested importing the libaries, but haven’t used them yet).

Here’s the code for the C# component:

private void RunScript(object x, object y, ref object A)
{
string cmd = “C:s\Python_Scripts\reverse.py”;
string args = “Hello!”;
Print(run_cmd(cmd, args));
}

private static string run_cmd(string cmd, string args)
{
System.Diagnostics.ProcessStartInfo start = new System.Diagnostics.ProcessStartInfo(“C:\Python27\python.exe”);
start.Arguments = string.Format(“{0} {1}”, cmd, args);
start.UseShellExecute = false;
start.RedirectStandardOutput = true;

using (System.Diagnostics.Process process = System.Diagnostics.Process.Start(start))
{
using (System.IO.StreamReader reader = process.StandardOutput)
{
string result = reader.ReadToEnd();
return result;
}
}
}

And here’s the Python script:

import numpy
import scipy
import sys
from types import *

input = sys.argv[1]
assert type(input) is StringType, “name is not a string: %r” % input

print input
print input [::-1]

So the output of the component should be:

Hello!
!olleh

Right now I’m looking into suppressing the python window.
(It pops up for a second when you run this.)

Add this statement before starting the process to have no pop-up window:

start.CreateNoWindow = true;

Thank you @ParamDesSing. That’s a clever idea. I have to try it.
But the workflow is very intricate. You can’t use the python debugger and i also have to save the script every time to run it.
Do you think that that there is a solution to stay in the Rhino Python IDE?

Maby you can find some information here: https://github.com/localcode/rhinopythonscripts/blob/master/README.md

I have not tested it but i have plans on using this later. i did like Stevebears solution, have you tested it extensively?

@ZweiP, it’s true that this approach is a little tricky. But maybe it’s not as bad as you might think:

Export a point set from Rhino as a *.txt or *.csv (maybe with a hull that you know), and use that for debugging. For that you can use an external IDE. (Many people like Eclipse, I recently had a look at PyCharm, which seems very nice, especially if you need a lot of libraries.)

If you want to stay purely inside of IronPython, I guess there should be a way to replicate what I did. (Although I don’t know how.)