Ever wondered how to permanently store and share
preferences and data created by custom GUIs?
Save your existing OptionVars from you custom GUI to a XML-File.
Restore your OptionVars from a XML-File.
optionVar -iv test_it_singleInteger 10;
is saved as:
Uses sligthly modified version of xml_lib.mel by J. Adrian Herbez
Bugs and feature suggestions: email@example.com
Put ks_optVarToXML.mel and modifiedXml_lib.mel in you script directory.
Source ks_optVarToXML.mel and start the GUI by typing "ks_optVarToXML" in the script editor.
Create OptionVars of any type.
As there is no way to savely determinate the type of
an existing OptionVar you have to stick to the following name convention:
VarPrefix_TypePrefix_VarName i.e. pre1_ia_mySliderValues
The first prefix can be anything followed by an underscore ("pre1_" in the above example).
The second prefix indicates the datatype of the OptionVar ("ia_" in the above example):
- "st_" for string,
- "it_" for integer,
- "fl_" for float value,
- "sa_" for string array,
- "ia_" for interger array,
- "fa_" for float array.
VarName can be anything you like ("mySliderValues_" in the above example).
Note that OptionVars not using this name convention are
ignored or cause errors when used with ks_optVarToXML.
To save OptionVars to XML-File:
Type the prefix or prefixes seperated by commas of OptionVars you want to save
in the textfield. Press the "saveOptionVarToFile" button to save the Xml-File.
To load OptionVars from XML-File:
Press the "Load/replace optVars with .xml" button and select the XML. file containig the optVar data.
This will delete the existing OptionVars and write the store ones to your userpref.mel.
If you choose "All in XML" it will replace all OptionVars starting with those prefixes in the XMlL file.
If you select "Those with prefixes given in text field"
only optionVars starting with a prefix or prefixes (separated by commas) given
in the text field will be replaced.