RhinoScript SaveSettings in Python


I don’t see SaveSettings in RhinoScriptSyntax - is there a way to read/write an .ini file in a similar way in Python?



(Willem Derks) #2

Hi Jarek,

I’ve been using ConfigParser without issues so far:
Let me know if you don’t get it to work, I might have pruned my custom code a little too much

import ConfigParser

def read_ini_file(filepath):
    cnfg = ConfigParser.ConfigParser()
    config_dict = {}
    for section in cnfg.sections():
        section_dict = {}
        options = cnfg.options(section)
        for option in options:
            raw_value = cnfg.get(section, option)
            value = raw_value.decode("utf-8")#optional not essential
            section_dict[option] = value
        config_dict[section] = section_dict
    return config_dict



Thanks Willem! I will give it a shot and try to see if I can also make it write ini files…

(Willem Derks) #4

Ah yes the writing part… I only use it to fetch configuration files so never implemented writing out dictionaries.


Actually that’s good - an excuse for me to practice and learn :wink:
Found this for starters: https://docs.python.org/2/library/configparser.html#examples