How do I get command bar options to save? Rhino student needs help!

I learned how to create and use command bar options in c#, and everything works. Something I’d like to change is not having to input the same option over and over again, if I put it once I want it to be the default in the next time I call the command. How can I do this?

Side note: where can I install Visual Studio 2005 for making 32-bit plugins?

Each command has a Settings object that you can use to store and retrieve settings. They are saved to disk after rhino quits, and restored from disk when rhino starts.

How do I use it? I’m looking I’m not seeing anything.

Ok, I do this code from memory, so it may be incorrect. There is a Settings property on each command. You can get and set values on it, like a dictionary.

protected Result RunCommand(RhinoDoc doc, CommandMode mode)
{
    int savedInteger = Settings.GetInteger("key", 4);
    Result res = RhinoGet.GetInteger("Give integer", ref savedInteger);
    if (res != Result.Success) return res;
    Settings.SetInteger("key", savedInteger);
    return Result.Success;
}

So every time I run this command, it won’t always start as 4?

That is correct

If no setting was found, for example when the command is run for the first time, the value of 4 is the default value.

1 Like

Thanks for all of your help, I got it to work.