Installing Additional Libraries
You have access to the following APIs by default with DrawScript-Python:
RhinoCommon: Rhino’s lower-level API that can be used in Python.
RhinoScriptSyntax: a Python library that abstracts away a lot of the complicated processes in RhinoCommon.
Eto: the UI library Rhino uses. Shape Machine uses this library to make popups, and you can too!
Shape Machine’s API: all the classes and functions Shape Machine uses internally can also be used within DrawScript-Python.
Any other library you install into the default Rhino Python environment.
To use anything in these libraries, you will need to import them as you would in any other Python program.
To install additional libraries, do the following:
Run
ScriptEditor
to open the Script Editor.Make a new Python 3 script.
At the top of the script, add the following line, replacing
<library>
with any library you would like to install:
# r: <library>
Run the script, and Rhino should install the library. It can now be used in DrawScript-Python.
Note
You can specify multiple libraries by creating multiple comment lines or by putting multiple in one line, separated by spaces.
Warning
If something happens to the virtual environment that makes Rhino recreate it, you will no longer have access to the libraries you installed manually. You will need to repeat this process, so it could be a good idea to save the blank install script just in case. That way you can run it again if needed, without having to recreate it.