Python in Rhino: rhinoscriptsyntax

Hello, I am a total Rhino newbie trying to understand scripting with python in Rhino… so I hope this is the right place to ask. :slight_smile:

I have a quite general question about libraries to use. It is recommended to use functions from “rhinoscriptsyntax” or use the rhino common functions (e.g. imported as “Rhino.Geometry as rg”)? Where are the advantages of rhinoscriptsyntax when I can address all Rhino functions? I am just wondering since sometimes it seems finding functions in Rhino Common is much easier than the equivalent one in rhinoscriptsyntax and I have a feeling not all rhino functions are converted to python functions. But I’m sure I’m missing something here and maybe rhinoscriptsyntax is really much more convenient using python in Rhino.

Thanks a lot in advance! So far coding in Rhino is exciting… but also hard when starting with it. :slight_smile:

Cheers,
Daniel

Rhinoscriptsyntax is a “higher level” set of functions that actually call RhinoCommon methods “under the hood”.

Depends on your programming abilities. People with less programming experience usually find rhinoscriptsyntax easier…

That is true, you can get a lot further into it with RhinoCommmon

You can actually use both together…

Rhinoscriptsyntax uses both Rhino Common as well as scriptcontext methods.
If you debug a script you can step into rhino script syntax methods to see which methods are used from Rhino common.
Most of the script syntax methods will end up creating geometry in the Rhino document. Sometimes this is handy, sometimes you don’t want this to happen, but just create geometry in memory to work with.
for example rhinoscriptsyntax.AddCircle() will add a circle to the Rhino doc.
Doing the same with Rhino common code would be something like:
Circle= Rhino.Geometry.Circle()
scriptcontext.doc.Add(Circle)
Only the last line will actually draw the geometry in your doc.

The above is just a simplified example, not complete code.

In addition to the great suggestions already mentioned, make sure to take advantage of the left hand tree pane of the Rhino Python Editor. Specifically, the rhinoscriptsyntax tree. When you expand a rhinoscript method, and highlight it, you will, (almost always), get a description of the method and a simplified example.
And, if you double click on a method, (in the left hand tree pane), it will take you to the help documentation!

Wow, thank you so much for the quick and excellent answers. That helps a lot having some orientation with this topic. Thanks! :slight_smile:

I was suspecting Rhinoscriptsyntax is such a “higher level” set, having the confimation is great. Good to know as well that using both libraries is not a wrong or “inelegant” way to script. :wink:

And much thanks for the tip of the Rhino Script Editor… somehow only tried scripting in Grasshopper so far. :smiley:

Cheers,
Daniel

Hello,

Yes, specifically rhinoscriptsyntax is strictly functional and is designed to mimic RhinoScript. It mainly refers to objects via their guid I.D.

Rhinocommon is object oriented in a dot net style. You can use this script to find the Rhino common source for a rhinoscriptsyntax method:

Hi Daniel,

In addition to other contributions have a look at this topic to get some insight in navigating from the scripteditor into rhinoscriptsyntax and
RhinoCommon: