Plugin Licensing in GH
In this article, I will be writing about the integration of Licensing in custom Grasshopper plugin. We at DevCreate Solutions LLP have recently helped a client to integrate the licensing in GH.
There were two parts to this requirements
- Licensing portal and Licensing file generation.
- Integration of Licensing for Grasshopper components
I will be talking about the second part in today’s article.
For integration, we will have certain ground rules so that the code becomes easy to read and maintain.
All the custom components will be extending from BaseComponent.
public class MyCustomComponent : BaseComponent
The BaseComponent will have the code to check for the loaded license (from the local file which is downloaded. I will talk about that in a while ) and display the error message in case the license is not present or not present. It will also check the validity of the license, if one present. This way, all the custom components will be guarded against the usage until the license is imported.
One core class for the insertion of the license transaction.
public class CustomPluginPriority : GH_AssemblyPriority
This class will extend from GH_AssemblyPriority and overload the below method. As this will be only called once for each load of the plugin, this method will be used to insert the data regarding the usage of the license including the machine details, license details etc. This is necessary so that we will have data about the usage of the plugin and can guard against the plugin usage over and above the IP limit ( let’s suppose 3 IPs at a time.)
public override GH_LoadingInstruction PriorityLoad()
Commands to request the license.
We will need to have some mechanism for the user to request the license. This can be created in the form Rhino command
using Rhino.Commands;
namespace MyLicense.Commands
{
public class PluginLicenseRequest : Command
{
This command will be used to assemble the data required for the license ( like the Plugin Name, Version etc.) and either can send out a mail or create a template email to be sent manually. How the license will be generated & sent by the author ( through email/downloadable link/something else) is outside the scope of this article and hence not discussed.
Command to apply the license.
Once the license is received, it has to be applied so that the Plugin would know of its presence.
public class PluginLicenseUpdate : Command
This class is again will be a Rhino command and the implementation will be provided in the RunCommand method. The implemenation would involve the copying of the license file to pre-defined location from where the plugin would be checking its presence.
Once all these items are implementated, we will have a basic licensing system integrated into the Grasshopper Plugin.
If you have any questions, please feel free to let me know.
If you want to implement this functionality in your custom plugins, please contact us.