Grasshopper

To get COMPAS working in Grasshopper, you first have to install COMPAS for Rhino. In Grasshopper, COMPAS is imported from within a GhPython component. Rhino for Mac and Rhino 6+ all come with their own GhPython interpreter, but if you use Rhino 5 on Windows, please download and install GhPython here.

Verify setup

To verify that everything is working properly, simply create a GhPython component on your Grasshopper canvas, paste the following script and hit OK.

import compas
from compas.datastructures import Mesh
from compas_ghpython.artists import MeshArtist

mesh = Mesh.from_obj(compas.get('faces.obj'))

a = MeshArtist(mesh).draw()
../_images/gh_verify.jpg

Grasshopper components for COMPAS

When COMPAS for Rhino is installed, it also installs Grasshopper components for COMPAS. For example, the current environment information can be retrieved with the INFO component.

../_images/ghpython_component.jpg

Reloading changed libraries

If you change a Python library during a running Rhino application, which is imported in a GhPython component (e.g. via import compas_fab), it is necessary to reload the library so that the GhPython interpreter recognizes the changes. To avoid restarting Rhino, you can use the function unload_modules. The following example reloads the library compas_fab.

from compas_ghpython import unload_modules

unload_modules('compas_fab')