Understanding scriptcontext vs ghdoc

Just one quick addition to the informative text by Djordje:

scriptcontext.doc is the variable that is used all the time by rhinoscriptsyntax to access the active document. You can imagine that, before running a script in Rhino, the EditPythonScript editor assigns the open model to that variable. Also, before GhPython runs, it assigns the active, hidden Grasshopper document to that variable, so that you will use a document that is better suited for Grasshopper (it’s not having to keep track of undo’s, so it’s more efficient for some operations. It also does not have some interface aids and does not per se allow picking, like Grasshopper. Also, geometry is not visualized by default in this document).

I hope this helps,

Giulio


Giulio Piacentino
for Robert McNeel & Associates
giulio@mcneel.com

3 Likes