Difference between import "Rhino" or "rhinoscriptsyntax"?

Hi guys,

These days I start to learn python in Rhino. However, the first question I have to ask is:
what is the difference between import “Rhino” and “rhinoscriptsyntax” (also “scriptcontex”)? Aren’t they the same thing? And when to use which? And which is better to use?
I know it maybe a silly question, but I am eager to know the answer.
Thanks in advance!

importing Rhino means you can directly interact with RhinoCommon. This way you can generate geometry without necessarily adding it to the document.

RhinoScriptSyntax, as the name implies was made based of RhinoScript and tries to mimick Rhinoscript using python and RhinoCommon. In fact, if you study the rhinoscriptsyntax methods (using debug mode and step into…) You will see it uses both Rhino methods as well as scriptcontext methods.

scriptcontext is like a bridge between RhinoCommon and the Rhino document. So you generate geometry using Rhino methods (For example my_sphere = Rhino.Geometry.Sphere(center, radius)) and add it to your Rhino Document using scriptcontext (For example scriptcontext.doc.Objects.AddSphere(my_sphere)

2 Likes

Thank you so much, @Gijs!

There is another question:
If I import ghpythonlib.components, how can I easily find the funciton I want to call?
For rhinoscriptsyntax, there is a website (rhinoscriptsyntax) where I can easily search; while for ghpythonlib.components, I have to guess which function should be in the python editor.
Is there a similar website for ghpythonlib.components, or do you have a convinient way to do so?
Thanks!

if you have somthing like:
import ghpythonlib.components as gc
then typing gc. will bring up all the components available. If you want to know what’s available, look at the components native to gh :slight_smile:

1 Like

Thank you again, @Gijs!