Save custom data to Rhino App

is there a way to save custom data to Rhino app or Rhino Settings? Thanks a lot.

What kind of data @Robin3? Simple strings? Complex Objects?

Thanks csykes, a simple string will work, any ideas? Thanks a lot!

I tried the below codes to save a settings, but next time when I debug the plugin, the settings was not there, still plmSettings is null, any ideas? Thanks a lot!

        var pluginSettings = RhinoPlugin.Instance.Settings;
        PersistentSettings plmcSettings = null;
        pluginSettings.TryGetChild("PLMC_Settings", out plmcSettings);
        if (plmcSettings == null)
        {
            appSettings.AddChild("PLMC_Settings");
            appSettings.SetBool("PLMC_Settings", true);
            RhinoPlugin.Instance.SaveSettings();
        }

Hi @Robin3,

Maybe something like this?

public class TestClass
{
  public bool TestValue { get; set } = true;

  public void LoadSettings()
  {
    try
    {
      var settings = RhinoPlugin.Instance.Settings.GetChild(nameof(TestClass));
      if (null != settings)
      {
        if (settings.TryGetBool(nameof(TestValue), out bool value))
          TestValue = value;
      }
    }
    catch
    {
      // Do nothing
    }

  }

  public void SaveSettings()
  {
    try
    {
      var settings = RhinoPlugin.Instance.Settings.AddChild(nameof(TestClass));
      if (null != settings)
      {
        settings.SetBool(nameof(TestValue), TestValue);
      }
    }
    catch
    {
      // Do nothing
    }
  }
}

– Dale

Let me try, Thanks Dale!

You right, my bad, I set the bool to the wrong settings, it works fine now. Thanks Dale!!!