Rhino 8 rs.GetSettings not finding ConfigParser

Hello,

There seems to be an issue in Rhino 8 where the ConfigParser module is not in the expected place.

How do you feel about creating a corresponding rs.WriteSettings? Or maybe it is time to just use ConfigParser so that people can easily move from Python examples on the Internet to using it in Rhino.

Edit - I forgot about adding the magic
RHINOSCRIPT = ‘1c7a3523-9a8f-4cec-a8e0-310f580536a7’

in order to access the undocumented rs.SaveSettings

Henry

1 Like

@Alain - is this something you can have a look at?

Hello here,

I’ve got the same issue. When trying to rs.GetSettings(), I get "ModuleNotFoundError: No module named ‘ConfigParser’

Looking at py39-rh8\site-rhinopython\rhinoscript\utility.py line 407, I see “import ConfigParser”. Should it by “import configparser”, in lowercase? Trying that on a blank script, this seems to work.

Regards,

Alexandre

Hello Alexandre,

I actually gave up on using the Rhino solution for config files. It was too frustrating. Instead I wrote a “lightweight” parser for config files and have been using that instead. The code is attached if you want to try it.

Sorry that this is just a band-aid and doesn’t help with your direct question.

SimpleParser.py (3.6 KB)

Thanks for your answer.

How should i use it? Ive got several instances of rs.GetSettings() in my project, which was developed for IronPython. In order to make the transition, can I avoid replacing all rs.GetSettings()? On the other hand, If I did all the replacements, would it still work with IronPython?

Thanks again!

The way I have used it is to load the INI file into a dictionary using the previous module, then access the values in the “normal” way that you would expect from the configparser module. Something like value = dictName[‘Section’][‘Key’]. Load the INI file at the beginning of your program and then access the values from the dictionary as needed.

I don’t use IronPython so can’t offer any suggestions, but I think the method described above should work.

BTW, I sent you a older file with a mistake in it. Sorry about that. Please load the two attached py files into the Rhino editor and give it a try. Discard the older file.

The result should look like this (from Rhino 8)

Sample.ini (68 Bytes)
SimpleParserTest.py (295 Bytes)
SimpleParser.py (3.6 KB)