Hey everyone,
not sure I'm finding the right words, or the right explanation for my problem, but I'll try to explain as thorough as possible. :)
I'm currently developing a new plugin that shares one important global variable, amongst others, across different CommandData
plugins. It's a "global" filepath called rootfolder
a user can select within a GeDialog
.
I guess my main question is, how one would go about sharing this filepath
with different classes, because I find it kind of ugly to init
the same thing over and over again...
For example, I have a myObject()
within myOverview()
within a ListView(c4d.gui.TreeViewFunctions)
and every class should know about the rootfolder
deriving from the OptionsDialog(c4d.gui.GeDialog)
.
Currently my OptionsDialog(c4d.gui.GeDialog)
is initialized like this:
def __init__(self):
self._treegui = None # Our CustomGui TreeView
self._listView = None # Our Instance of c4d.gui.TreeViewFunctions
#loading from c4d.plugins.GetWorldPluginData()
self._data = myContainer.load()
self.rootfolder = self._data.GetFilename(ids.IDC_FILEPATH) or self.GetFilename(ids.IDC_FILEPATH) or None
I basically could use myContainer.load().GetFilename(ids.IDC_FILEPATH)
in every other class, but it seems a little bit awkward, so I'm just wondering what's the best way to store this "global" path from the GeDialog
and it reusing all over the places.
How would you guys go about this, is c4d.plugins.GetWorldPluginData()
really the best way store the data and initializing it in every Class..? I mean it's working okay I guess, but I was wondering if there are better decisions code/design wise out there...
If you need any further explanation or examples, I'm happy to see what I can share.
Thanks for reading, and happy coding.
Cheers,
Lasse