Numpy and Scipy in RhinoPython
Disclaimer: I have very little experience with numpy and scipy so you are going to do better by searching google for support with these libraries. This blog is about getting these libraries to run in Rhino.
Yes it is possible now!!!
Okay, here’s what I did to get numpy/scipy running in Rhino
1 – Install Rhino 5 (32bit version)
numpy/scipy uses C++ DLLs which need to be compiled for a specific platform. Currently numpy/scipy for IronPython will only run in 32bit applications on Windows. I contacted the guys at Enthought and they do plan on releasing a 64bit version for Windows, but they want to make sure everything is working on 32bit first. They have some doubts about being able to release a mono version for you Mac guys out there.
2 – Install numpy/scipy for IronPython
Follow the instructions on this site http://www.enthought.com/repo/.iron/
3 – Modify settings in RhinoPython
Start Rhino 5 – 32bit version and run “EditPythonScript” to bring up the editor. Go to the options dialog by selecting Tools->Options from the menu
Check the “Frames Enabled” option since numpy/scipy requires this to be turned on.
I decided to make the “Frames Enabled” an optional engine feature since it does have a performance impact on scripts. Numpy/scipy requires this feature to be turned on.
4 – Run a test
# For now, we need to manually load mtrand before using numpy or scipy # I'm still trying to figure out why mtrand is not automatically getting # loaded when numpy/scipy imports it. If I can fix this, we won't need # the following two lines import clr clr.AddReference("mtrand") import numpy import rhinoscriptsyntax as rs x_coord = [ 0, 1, 2, 3, 4, 5, 6] y_coord = [0.0,0.1,0.5,2.5,2.5,2.5,4.0] xyz = zip(x_coord,y_coord,*len(x_coord)) rs.AddPoints(xyz) degree = 5 eq = numpy.polyfit(x_coord, y_coord, degree) fitfunc = numpy.poly1d(eq) fit_points =  for i in range(61): x = i/10.0 y = fitfunc(x) fit_points.append((x, y, 0)) rs.AddPolyline(fit_points)
If you get a polyline in rhino fit through a series of points then you are all all set; if not go back to step 1 and repeat.
This looks like a good place to start if you want to learn more about numpy/scipy