Skip to content

Instantly share code, notes, and snippets.

@sbaer
Created May 20, 2013 21:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sbaer/5615915 to your computer and use it in GitHub Desktop.
Save sbaer/5615915 to your computer and use it in GitHub Desktop.
Dynamic Command Creation
public class TestDynamicCommandPlugIn : Rhino.PlugIns.PlugIn
{
// Override CreateCommands to generate your own commands on the fly
protected override void CreateCommands()
{
base.CreateCommands();
// uncomment the following to get your "private" command to work
//var cmd = new TestSecretCommand();
//Rhino.Runtime.HostUtils.RegisterDynamicCommand(this, cmd);
}
}
// notice that this class is public so it will get found during the
// reflection loading of commands
public class TestPublicCommand : Command
{
public override string EnglishName { get { return "TestPublicCommand"; } }
protected override Result RunCommand(RhinoDoc doc, RunMode mode)
{
RhinoApp.WriteLine("This is the public class that is created like any typical command");
return Result.Success;
}
}
// notice that this class is private
class TestSecretCommand : Command
{
public override string EnglishName { get { return "TestSecretCommand"; } }
protected override Result RunCommand(RhinoDoc doc, RunMode mode)
{
RhinoApp.WriteLine("Secret Command that only gets created when the plug-in thinks it is appropriate.");
return Result.Success;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment