Save User Settings

On 18/06/2014 at 14:27, xxxxxxxx wrote:

If I want to save some of my python pluggin user-settings what is the best way?

Is there some built in way to do it in C4D?
Or should I just use 'pickle.dump' to a file stored next to the pluggin?



On 19/06/2014 at 00:20, xxxxxxxx wrote:

Take a look at the SDK function SetWorldPluginData(), assuming it's available in Python.

On 19/06/2014 at 07:47, xxxxxxxx wrote:

Unfortunately, It's not supported in Python Steve.
Which is the main reason why I write all of my preferences plugins in C++.

To store data. The usual tools for that in Python are BaseContainers and UserData.
You can hide the UserData gizmos if you don't want the user to see them.


On 19/06/2014 at 08:02, xxxxxxxx wrote:

Scott, why do you think it is not supported in Python?

import c4d
import datetime
from c4d.plugins import SetWorldPluginData, GetWorldPluginData
TIME_START = datetime.datetime(1970, 1, 1)
TIME_FORMAT = "%Y %B %d, %H:%M:%s"
def total_seconds(td) :
    # datetime.timedelta.total_seconds() was added
    # in Python 2.7
    temp = (td.microseconds + (td.seconds + td.days * 24 * 3600) * 10**6)
    return temp / 10**6
def main() :
    bc = GetWorldPluginData(PLUGIN_ID) or c4d.BaseContainer()
    if bc.GetType(1000) != c4d.DTYPE_NONE:
        dt = TIME_START + datetime.timedelta(seconds=bc.GetLong(1000))
        print "Last saved time:", dt.strftime(TIME_FORMAT)
    bc.SetLong(1000, total_seconds(( - TIME_START)))
    SetWorldPluginData(PLUGIN_ID, bc, add=False)
if __name__ == "__main__":


On 19/06/2014 at 08:31, xxxxxxxx wrote:

What I meant was that we can't create our own preferences so that the user can see them and change them (toggle them on/off).
AFAIK. The PrefsDialogObject class is not supported by Python.

It's kind of irritating that this is not available in Python.


Isn't storing data in the WorldContainer like this this kind of dangerous?
Since these containers will be there permanently. Even if the plugin is removed. And there's no visual reference to them in the preferences GUI.
What's to prevent plugin developers from filling people's WC with data that never gets flushed?