Hi all, I’m a long term user of RhinoScript, but am keen to make the most of the UI benefits of Python (I’m sure there are some others also).
Currently when I look at Rhino Python code, I’m a bit lost in deciphering what is Rhino, what is pure Python and what is RhinoCommon. Maybe the object orientated format is throwing me and it might also be because I’m impatient and haven’t wanted to start at “Hello Word!” again. Nothing like a real project to get in and learn.
Could anyone advise the best resources for me to methodically translate from Rhino to Python and make the most of what Python offers?
Hi @agmckenna ,
I would start with Rhino Python 101 primer book:
It starts addressing the basics of python first, and then the usage of RhinoScriptSyntax.
RhinoScriptSyntax is a wrapper around RhinoCommon. So you won’t find RhinoCommon in the upper primer, but for a RhinoScript user like yourself - this is perfect. Because the names of the functions will be the same like in RhinoScript.
Then one day, if you really want to, you can start learning RhinoCommon. But I would say for your current scope of work: rewriting from RhinoScript to Python, you don’t need RhinoCommon at all.
Excellent, thanks @djordje! That looks like a great way to ease into it, and I appreciate also the advice to focus on the transition first and then look at RhinoCommon down the track.
Cheers,
Adrian
Rhinoscriptsyntax methods are basically like the VB Rhinoscript methods. If you see anything that begins with rs… (the most common import shortcut for rhinoscriptsyntax), it’s a rhinoscriptsyntax method. Rhinoscriptsyntax is actually a set of wrapper functions that call RhinoCommon methods, you can see what they look like by going into the library here:
RhinoCommon is the common code base that allows several programming languages (Python, C#, VB.Net) to communicate with Rhino’s core functions. Like Python, RhinoCommon uses object oriented programming and is a bit difficult to get your head around at the beginning if you are not used to it. The API guide is here: https://developer.rhino3d.com/api/RhinoCommon/html/R_Project_RhinoCommon.htm
Everything else is pure Python. IMO it is very important to learn how Python itself works, independent of Rhino - for that I suggest a basic book or online course to get a good grasp of how it works. Things like strings and lists are quite a bit different (better!) than VB, the syntax is also different of course, but most importantly Python is object oriented programming and the basics of that are essential to understand.
The only thing I can really add to the above, since I’ve been through a similar process, is that most of the RhinoCommon items I’ve used were based on published code snippets from the locations below and from code published here. A fair few solutions come from stackoverflow too.
There’s no better way to learn this than to pick a project and go for it.