Skip to content

A slightly opinionated starter template for Grasshopper plugin development with a variety of development aids.

Notifications You must be signed in to change notification settings

philipbelesky/GrasshopperBootstrap

Repository files navigation

Grasshopper Bootstrap

Build Action Test Action Maintainability Codacy Badge License: MIT

A slightly opinionated starter template for Grasshopper plugin development. Comes with a variety of templates and tools to help development. Most are unnecessary for most projects. However, most are easier to remove from a project than to add in.

Many of these features assume you are working on Github, using Visual Studio 2017/2019, and developing for Rhinoceros 6+ or higher.

Features

  • Grasshopper/RhinoCommon bundled using their NuGet packages
    • Ensures reference paths are maintained across local environments and can be controlled independently of the installed applications.
  • Setup release builds to produce a single gha that includes all other dependent dlls
    • ILRepack is used over ILMerge or Fody for better macOS compatibility. Refer to this repo for its documentation.
    • The sample code is setup to bundle Newtonsoft.Json as an example. Be sure to remove this and its reference in ILRepack.targets when starting your project!
  • Cross-compatibility between macOS and Windows versions of Visual Studio
    • GrasshopperBootstrap.csproj defines split build paths so that each OS will start its own version of Rhinoceros
  • Continuous Integration using GitHub Actions
    • See the steps in .github/workflows/dotnet-grasshopper.xml; currently the action will build the application and then upload the gha file from the Release build as an artefact. Build or linting failures will trigger a fail.
    • See the steps in .github/workflows/dotnet-tests.xml; currently the action will run the tests defined in GrasshopperBootstrap.Tests. Note that these tests can't depend on Rhinocommon.
  • Unit-testing framework (sort of)
    • The GrasshopperBootstrap.RhinoTests project is setup to run its tests within a headless version of Rhinoceros 7 so that all of Rhinocommon is accessible. Note that this project needs to be run as x64 (under the Test menu in Visual Studio).
    • *The GrasshopperBoostrap.Tests project is setup to run its tests without Rhinocommon access. This is mostly useful for doing CI testing (e.g. the GitHub action described above).
    • That same project has a Grasshopper definition that uses PancakeContract to show how to run unit tests within Grasshopper.
  • A shared class for all component files to inherit
    • Allows for shared functionality and/or easy implementation of error reporting
  • Affordances (via a shared GHBComponent class) for easily outputting debug and profiling information
    • When using DEBUG builds, all components have a Debug output paramater designed to be connected to a Panel component
    • Basic profiling information can be logged to this output with LogTiming(msg) as can general information with LogGeneral(msg)
  • Affordances (via a shared GHBAsyncComponent class) for easily creating Asychronous components
  • Linting using FxCop, StyleCop, an .editorconfig with a (relatively?) sane set of defaults
  • GitHub Pages setup for documentation
    • See the docs folder and the README there
  • Icons Illustrator template with some of the original Grasshopper icons provided as references
    • See the assets folder
  • A bundled template for an "About" component that reports current/latest version and links to documentation
    • See AboutComponent.cs and GrasshopperBootstrapInfo.cs
  • 3DM files setup to be stored using Git Large File Storage
  • Setup to optionally debug using the previous versions (v6) of Rhinoceros
    • Use the Debug (v6) build configuration if this is desirable. You may want to check the file paths in the csproj file match your local paths.
  • Code analysis with Codacy and Code Climate
    • These are not setup per-se; I've just added badges to this README. To use these in your projects you will need to add each app via the GitHub Marketplace
  • Message added below components showing current version when running in DEBUG
    • This is to easily identify the currently-loaded plugin version and as a safe guard against publishing development builds

Roadmap (PRs welcome!)

  • Real Unit testing via NodeInCode?
  • Performance tests using BenchmarkDotNet?
  • Error reporting using Sentry
  • Scripts for easily generating Yak releases
  • Automate Yak releases via GitHub actions?

Setup

This should all work out of the box. See features notes for optional setup steps.

Comments in the code with GrasshopperBootstrapTODO: highlight crucial changes to make when setting up your own plugin.

The default 'spiral' component from the McNeel sample plugin is included for reference and to demonstrate some features.

Acknowledgements

Thanks to Dimitrie Stefanescu for the async method developed in this repo.

Thanks to Tom Makin for the unit testing code developed in this repo.

Thanks to Andrew Heumann, Matthew Nelson, and Will Pearson for their recommendations.

About

A slightly opinionated starter template for Grasshopper plugin development with a variety of development aids.

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages