When using GhPython, a plugin that can handle Python with Grasshopper, for example, commands such as GetObject () that can be used with rhinoscripts cannot be used. This is because when using a Rhino script on Rhino, the object on Rhino is handled, while when using a Rhino script on Grasshopper, the virtual object used by Grasshopper is handled. Then what do you do?
In order to be able to handle objects on the rhino, write the following in the python script.
sample.py
import scriptcontex as sc
sc.doc = Rhino.RhinoDoc.ActiveDoc
This way, if you use a rhino script in this script, you will be able to work with objects that are located in rhino space instead of grasshopper virtual objects.
If you want to undo
sample.py
import scriptcontext as sc
sc.doc = ghdoc
sc.doc = Rhino.RhinoDoc.ActiveDoc
Is used in the following situations.
Also,
sc.doc = ghdoc
Is used in the following situations.
You can get more detailed and correct information by looking here. A must-see for anyone who wants to use Python scripts with Grasshopper.
TIPS | SCRIPT CONTEXT IN GH PYTHON
Recommended Posts