Where can I learn ScriptContext's functions?

Where can I learn ScriptContext’s functions?
I can’t find it in “rhinocommon.chm” and “rhinoscript help”

Maybe this can help:


Thanks Mitch! That’s great!

You could also have a look at the source code (scriptcontext is just a regular Python module), it is located around here:

C:\Users\YOURUSERNAMEHERE\AppData\Roaming\McNeel\Rhinoceros\5.0\Plug-ins\IronPython (814d908a-e25c-493d-97e9-ee3861957f49)\settings\lib\scriptcontext.py

I’m getting a bit confused when looking at contents of scriptcontext.py. It doesn’t import any other python library like rhinoscriptsyntax.py does except for import RhinoPython.Host as __host. I understand that it “bridges” to RhinoCommon, but I was expecting python definitions that wrap RhinoCommon. Is it correct to assume then that scriptcontext is almost exactly the same as RhinoCommon?

If you look at the contents of C:\Users\You.rhinocode\python3.9-1.20\site-rhinopython\rhinoscript\ you can see the actual rhinoscript functions and how they use Rhinocommon.

1 Like

In a way I think the answer is yes, because all it does is that scriptcontext.doc provides you with functions to interact with the current rhinodoc, as in Rhino.RhinoDoc.ActiveDoc.

For example the scriptcontext.doc.Objects.AddPoint()) works exactly the same as Rhino.Rhinodoc.ActiveDoc.Objects.AddPoint()

1 Like

makes sense, thank you

I am just guessing with this one, but presumably scriptcontext has been designed to just give users a less overwhelming subset of RhinoCommon functions.

ActiveDoc is not reliable as Mac Rhino can have multiple docs open and there can be a pseudo doc used in the context of grasshopper. Using scriptcontext.doc is best as it lets you use the appropriate doc in the context of the script being run.


I don’t look at it exactly that way. I consider it the ‘bridge’ between your code and the current document that lets you access data from and write data to the document.

For example it allows access to all of the various tables where data is stored - the object table, the layer table, the view table, etc. i.e. everything in Rhino.DocObjects.Tables. But also stuff in the Rhino.RhinoDoc class such as units, tolerances, etc.