Skip to content
February 25, 2011 / stevebaer

macrhinodebugging

Finally, a plug-in architecture for Mac Rhino!!!
The python plug-in for Mac was our first experiment to see if we could actually get .NET plug-ins to work on Mac Rhino and support this framework on Mac for plug-in development. Well… with the latest build of Mac Rhino, I think we’ve got enough support in the application to start telling people how they can write and debug .NET plug-ins on the Mac.

In order to RUN .NET plug-ins on the Mac, you are going to need:

With the above two items installed, you can test to see if everything is working by installing the python plug-in for Mac Rhino
http://wiki.mcneel.com/rhino/mac/python
If you can run the command “RunPythonScript”, then Mac Rhino is properly configured to use .NET plug-ins!!

Ok, so how does it work???
The python plug-in that you installed has a “.macrhi” file extension. This is really just a zip file that has had the file extension changed so Mac Rhino knows how to deal with it. Try changing the .macrhi file extension back to .zip and looking at the contents in finder.
macrhi_contents
You’ll notice that the zip file contain a single directory named IronPython with a bunch of dll, xml, and rhp files. The RhinoDLR_Python.rhp file is a .NET Rhino plug-in that was built against RhinoCommon. This rhp is loaded by Mac Rhino in a similar fashion as Windows Rhino. When you double click on a macrhi, Rhino unzips the contents of this file to a specific directory on your computer; specifically
~/Library/Application Support/McNeel/Rhinoceros/MacPlugIns/
macplugindir

When Rhino first runs, it walks through each of the directories in MacPlugIns and tries to load every .rhp file. You’ll notice in the previous screenshot that there was another directory called “HelloMonoPlugIn”. This is a plug-in project that I wrote that was entirely built and debugged on Mac Rhino.

Writing your own .NET plug-in for Mac Rhino
Let’s focus on how to write your own “HelloMonoPlugIn” so you can start experimenting with plug-in development on the Mac. First, you are going to need to install some development tools

  • Install XCode – this application comes with you Mac and is on your Mac DVD, but is not installed by default with OSX
  • Install MonoDevelop (version 2.4.2 at the time of this writing) – http://monodevelop.com/

MonoDevelop is the tool that you will use to write and test .NET (mono) plug-ins on Mac Rhino. If you’ve used Visual Studio, you shouldn’t have much difficulty getting used to MonoDevelop.
There are no project wizards yet, so we’re going to need to do this the long way
Fire up MonoDevelop and select “Start a New Solution”
newsolution
Create a new C# Library project named something like “MyMacPlugIn”. Don’t check and of the “Project Features”, you won’t need them. After clicking the OK button, you should have a simple C# library project ready for you to type on.
createproject
We need to add a reference to RhinoCommon.dll to our project. This dll is located inside of the Rhinoceros application bundle that is installed when you installed Mac Rhino. On the menu click Project and then “Edit References…”. Pick the “.NET Assembly” tab and find your way to the Rhinoceros.app inside of the applications directory. I know, the user interface for navigating to the assembly is a little weird in this dialog, but I’ve got faith in you:) You should be able to find RhinoCommon at
/Applications/Rhinoceros.app/Contents/Resources/RhinoCommon.dll
Double click on RhinoCommon.dll and it will be added to your project’s list of references
RhinoCommonReference

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: