Rhino.GetSettings alternative in RhinoPython?

Could anyone help me with something?

What is the alternative of Rhino.GetSettings() in Python?

And Rhino6, in case it is old thing?

Thanks in advance.

Seems to be in rhinoscriptsyntax for V6 anyway…



def GetSettings(filename, section=None, entry=None):
    """Returns string from a specified section in a initialization file.
      filename (str): name of the initialization file
      section (str, optional): section containing the entry
      entry (str, optional): entry whose associated string is to be returned
      list(str, ...): If section is not specified, a list containing all section names
      list:(str, ...): If entry is not specified, a list containing all entry names for a given section
      str: If section and entry are specified, a value for entry
      None: if not successful
      import rhinoscriptsyntax as rs
      filename = rs.OpenFileName("Open", "Initialization Files (*.ini)|*.ini||")
      if filename:
          sections = rs.GetSettings(filename)
          if sections:
              section = rs.ListBox(sections, "Select a section", filename)
              if section:
                  entries = rs.GetSettings(filename, section)
                  if entries:
                      entry = rs.ListBox(entries, "Select an entry", section)
                      if entry:
                          value = rs.GetSettings(filename, section, entry)
                          if value: rs.MessageBox( value, 0, entry )
    See Also:
    import ConfigParser
        cp = ConfigParser.ConfigParser()
        if not section: return cp.sections()
        section = string.lower(section)
        if not entry: return cp.options(section)
        entry = string.lower(entry)
        return cp.get(section, entry)
    except IOError:
        return scriptcontext.errorhander()
    return scriptcontext.errorhandler()
1 Like

Hi @Helvetosaur,

Do you happen to also know the Rhino.SaveSettings?

I don’t see this one in rhinoscriptsyntax.

Thanks in advance.

Anyways maybe a suggestion to add it.
Something like:

def SetSettings(filename, section=None, entry=None, value=None):
    import ConfigParser
        cp = ConfigParser.ConfigParser()
        if not section: return
        if not entry:return
        cp[section][entry] = value
        with open(filename, 'w') as ini_file:
    except IOError:
        return scriptcontext.errorhandler()
    return scriptcontext.errorhandler()