Created
May 20, 2013 21:58
-
-
Save sbaer/5615915 to your computer and use it in GitHub Desktop.
Dynamic Command Creation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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