Skip to content

A demo project for developing Grasshopper plugin with the MEF approach.

License

Notifications You must be signed in to change notification settings

xarthurx/Grasshopper-MEF-example-project

Repository files navigation

Grasshopper-MEF-Example-Project

An example project for developing Grasshopper plugin with the MEF approach.

Why

Related (Rhino Plugin)

Goal

After digging for a few days, I cannot really find a solution for How to developing GH plugin without restarting Rhino/GH everytime I change the code. So that's what this repo does -- An starter-kit for those who are familar with Grasshopper plugin development, but are annoyed with the tedious Rhino/GH restarting process.

What is "MEF"?

Official Page

Short summary

  • A framework that can link external .dll(s) to the main application online easily.
  • For Grasshopper development, it allows us to link an external dll to the loaded Grasshopper plugin in a way that:
    • the external dll can be independently compiled and re-compiled without affecting the loaded Grasshopper plugin.

Demo Video This approach will greatly increase the developing speed and eliminate the tedious waiting time with ease.

Project Structure

The project has following 3 sub-projects:

  • pluginComputation (backend): The core library contains the actural functions that do the work.
  • pluginLoader (frontend): The GH plugin that will be loaded in Grasshopper. It calls the function from the backend through the linker ("contract").
  • pluginContract: The definition (required by MEF) that works as the link between the backend (pluginComputation) and the frontend (pluginLoader).

When a RESTART is needed:

Once the pluginLoader is loaded in a Grasshopper session, changes made to the function body of any functions defined in pluginContract/pluginComputation do not require a restart. However, adding new functions (or change function names, return types, etc.) will require a hard RESTART of Rhino/Grasshopper.

Hot Reload in Visual Studio 2022

The new Hot Reload functionality available in VS2022 achieves some of the goals this plugin tries to provide.

I'm currently not sure how much are the two overlap. But if you're using VS2022, you're welcome to try out.

About

A demo project for developing Grasshopper plugin with the MEF approach.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages