From the course: Grasshopper and Rhino: Python Scripting

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Importing libraries

Importing libraries

From the course: Grasshopper and Rhino: Python Scripting

Start my 1-month free trial

Importing libraries

- [Instructor] As we've just learned how libraries relate to IronPython, let's try using the CLR module to import the Excel Interop DLL. This will allow us to access Excel directly from our Python scripts. In a new Grasshopper file, let's go ahead and place a Python component, and then double click to open it up. The first thing we need to do is replace the Rhino script syntax import with rhino.geometry, as RG. Next, let's import the CLR module by simply writing import clr. Now we can use the CLR module to add the Excel library, keeping in mind here that you'll need a copy of Excel installed on your machine. Don't worry if you don't, however. The main thing here is to understand how to add and use libraries. To do that, we use the Add Reference function from the CLR module. So let's access CLR dot AddReference, and then open parentheses, and here we can write the full name we want to import as a string. The CLR module will then search for this library on your machine. To work with…

Contents