Difference between GhPython and GH_CPython


#1

Dear all,
I am recently using GhPython and I found that now we have a new plug-in call “GH_CPython”. Did anyone have use both and know the different or pro & con of these two plug-ins?
Thanks,
Jack


(Menno Deij - van Rijswijk) #2

There are different flavors of Python; GH_Python uses IronPython which is coupled to the .NET framework. The interface to .NET enables the use of the RhinoCommon library which allows you to use and modify geometry objects with Python code in the Grasshopper definition. But because of this dependency to the .NET framework, it is not possible to use Python libraries that have python-native (C++) dependencies, like the popular numpy library and others.

It looks like GH_CPython now provides an interface to these python-native libraries: the screenshots on Food4Rhino show the use of numpy. It does not, however, allow you to modify geometry objects in Grasshopper as far as I can see.


#3

Hi Menno,
I see…So GH_CPython can only deal with abstract data like number, string etc. but not geometries.
Thanks,
Jack


#4

Hi Jack,
Thanks so much for this subject…


Hi menno,
Thanks so much for explaining the differences between GhPython and GH_CPython,
GH_CPython still in the development process, one of its main advantages, is that you can use any scientific library such as Numpy, Scipy and matplotlib and so on… In addition, it works properly with any version of Python e.g. 2.7, 3.4, 3.5, or 3.6 … and can benefit from all of Python advantages including its efficiency.

As manno has said, It still doesn’t have RhinoCommon library, I’m still working on adding RhinoScriptSyntax to it. It will take some time, but I’m working hard on it and I expect it to be available in the Beta version.

I think that you can benefit from .NET framework by installing PythonNet library,

At the present version, I have tried communicating with Rhino using a module called Grasshopper but some fellows suggested that I include RhinoScriptSyntax as it will be easier and more familiar to developers. I’m working hard on solving this problem and I’ll try to release it as soon as possible it will take
a lot of effort, and I appreciate any contribution in developing this tool in order to be integrated with GhPython and to be useful to computational designers world wide:

Your feedback are most welcome and I appreciate it so much.

Sincere regards,
Mahmoud Abdelrahman


(Thomas Wortmann) #5

Maybe I’m wrong, but I believe that the RhinoScriptSyntax is built on top of RhinoCommon anyway.


#6

Yes, you are right,
I think it is impossible to access RhinoCommon from CPython, so I’ll just take the syntax of RhinoScriptSyntax and rewrite all the methods as possible. May be at the beginning, I’ll write only the basic methods curves, points, vectors, surfaces, nurbs, textures ...


#7

Dear Mahmoud,
Thanks for the informative descriptions!
And big thanks for your hard work on GH_CPython, it is a huge progress to let python be able to access those scientific libraries and really looking forward to more geometric functionalities adding!!:+1::+1:

Jack