Call Function on Save

On 27/09/2016 at 08:57, xxxxxxxx wrote:

I was wondering if there was a way to tie a function in a plugin to a c4d command like save, or save as new version. The overall purpose would be to update a database when a file is saved or versioned up.

Currently users have to press a button on the plugin to save the document and pass the information to the database, but I would like to avoid the need for the user to change their saving behavior.


On 28/09/2016 at 02:53, xxxxxxxx wrote:


welcome to the Plugin Café forums 🙂

Unfortunately in Python there's no good way to achieve completely what you want. You could create your own CommandData plugin, encapsulating the save operation and your database access. In this way, users would be able to have a button in the interface or remap their save keyboard shortcut to your command.

In C++ you could implement a SceneHook with a Message() function reacting on MSG_DOCUMENTINFO of type MSG_DOCUMENTINFO_TYPE_SAVE_AFTER (see also DocumentInfoData). In this case I'd recommend to also add an option to the preferences, so the user has an option to disable this behavior.