test for the exist of a preference-value

On 19/08/2014 at 08:29, xxxxxxxx wrote:


i want to check if a preference-value even exists.
But if I read the value I get an error.

data = c4d.plugins.GetWorldPluginData(PLUGIN_ID)   

retunes a false if the preferenzes does not exist.

But I have to check for a special value like:

last_usage_time = data.getString(1002)   

I only get his error:
AttributeError: 'c4d.BaseContainer' object has no attribute 'getString'

So, how can I check if the value isn't defined.

Thanks a lot

On 19/08/2014 at 21:26, xxxxxxxx wrote:


  1. GetWorldPluginData() will not return False, but None when the data does not exist yet.
  2. The method is called GetString, not getString, Python is case-sensitive

I'd suggest something like this

data = c4d.plugins.GetWorldPluginData(PLUGIN_ID)
if not data:
    data = c4d.BaseContainer()
last_usage = data.GetString(1002)
if not last_usage:
    # ...
    # ...