THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 10/06/2007 at 04:56, xxxxxxxx wrote:
Cinema 4D Version: 10.102
Platform: Windows ;
Language(s) : C++ ;
Sry for the somewhat unclear subject and for spawning another thread again already, but my problem is:
I'm writing a somewhat weird exporter kind of plugin (derived from CommandData), which exports to multiple files at once and uses some third company programs to compile those afterwards. For that I need some additional information by the user of course:
a) Where the third party programs are
b) Where he would like to have the result files and folder structure put
Now, I can save the info about the third party programs, I just save them in a BaseContainer obtained by GetWorldPluginData(...) (and eventually created with SetWorldPluginData(...)), no problem with that, works like a charm.
The problem is that the requested destination folder should be stored per-document, not in the C4D settings. I found GetToolPluginData(BaseDocument* doc, LONG id) to retrieve a BaseContainer related to a plugin from a document, but I can't seem to find the corresponding Set... function, so I suppose that's something to do with ToolData plugins and is not what I'm looking for?
Furthermore I have tried just writing the infos I need into a subcontainer of the BaseContainer obtained by doc->GetSettingsInstance(SETTINGS_GENERAL), but sadly that call always returns NULL, although I assumed every document has to have those general settings.
So, my question is: Where should I store plugin data related to a single document so that it gets saved with the document and is accessible when the document is reopened?
On 10/06/2007 at 08:08, xxxxxxxx wrote:
Get/SetWorldPluginData() are only good for general overall plugin preference settings - document and session independent.
BaseDocument::GetSettingsInstance() won't work here. If you look at the links in that call, they point to a BaseContainer with specific entries.
There are two possible ways to do this. There may be others - the R10.1 SDK is still rather new.
The first isn't guaranteed to work - that is, I haven't tried it and don't know if it is recommended. You could get the BaseDocument::GetDataInstance() and create a BaseContainer subcontainer with a 'unique ID' (one gotten here). Then you can store your settings in the subcontainer. If all goes well, the subcontainer should be saved with the document and can be accessed with BaseContainer::GetContainerInstance('unique ID').
The second is to create a plugin type that gets added to and saved with the document - plugin object, tag, material, shader. Store the settings in the plugin's BaseContainer (plugin::GetDataInstance()). Commands, scenehooks, tools, import/export filters, message plugins are not tied to a particular document.
On 11/06/2007 at 01:45, xxxxxxxx wrote:
Okay, I'll guess I'll try the "silent" way without a tag or anything similar. Would be better if the user didn't have to add something ominous to his scene just to use my exporter properly. I'll post whether that worked or not.
On 11/06/2007 at 01:53, xxxxxxxx wrote:
Great! It seems it's enough to just put a subcontainer with a unique ID into the data instance of the document. It gets saved with the file, doesn't trigger the "file changed" event it seems, so the user is not asked whether he wants to save his changes or not when closing the file. Using BaseDocument::SetChanged() should remedy that.
Thx for you help!