Save UI data and load UI data from .txt file

On 29/03/2017 at 07:04, xxxxxxxx wrote:

Hi guys,

I am trying to save UI data to a .txt file and load UI settings back by the .txt file for the UI.
so for example:

If I have four GeDialog.AddEditText with different names in each one. and I have a save button and press it and save it right to the .txt file, which is good. now I have a Load button, but how you load the .txt file and read it, so it can fill in the four GeDialog.AddEditText with the data from .txt file.

This is how I am saving the .txt file and it works, but how to go about loading it back when I open it?

    def Save_UI_Settings_Data(self) :
        ChrName = self.GetString(self.ChrName)
        Save_file = p.join(p.split(__file__)[0], ChrName+'_Data.txt')
        doc = c4d.documents.GetActiveDocument()
        SubN1 = self.GetString(self.UI_SN_1) 
        SubN2 = self.GetString(self.UI_SN_2) 
        SubN3 = self.GetString(self.UI_SN_3) 
        SubN4 = self.GetString(self.UI_SN_4)
        if ChrName:
            with open(Save_file,'a') as type_file:

This is new to me when saving data for a plugin, so plz help , a tip or example on this that I can find online to help me.

On 30/03/2017 at 08:01, xxxxxxxx wrote:

Hi Ashton,

to be honest I don't understand the question. I mean, you already write the contents of string widgets into a file, where's the problem with the opposite?

On 30/03/2017 at 08:37, xxxxxxxx wrote:

Hi Andreas
I am saying i don't know how to do the opposite which is the loading.
So it like if I have a button that is for opening your save settings and you open it with a open file dialog , you select the file which is the .txt and it load  the UI settings that  you have in the .txt
So How you make it read .txt and load settings to ui.
Hope you understand what I am saying.

On 31/03/2017 at 07:58, xxxxxxxx wrote:

Hi Ashton,

in our C++ docs we do have a manual on GeDialog, which might shed some more light. In order to set the values of string gadgets, GeDialog.SetString() is the function to use. Depending on your needs InitValues() could be a good place to read the file and set these values, but it could of course also be done in reaction to a button press in GeGeDialog.Command().
Reading and writing files with standard Python functions is a bit beyond the scope of MAXON's SDK Team, but I'm sure the official Python docs can help here, see for example Chapter 7.2 Reading and Writing Files.