When can I display a dialog at startup?
-
I am writing my own plugin management system to download and install plugins. After download I would like to ask the user to reboot C4D, then when rebooting I want to display an install dialog to install the plugins over the top of the existing ones (meaning they can't be loaded by C4D yet). This is similar to the C4D installer dialog.
Is there a way to do this? Can I display a dialog and run a process before plugins of a certain priority are loaded?
Or can I tell a plugin to release itself so that I can replace it, then ask the user to restart?
-
Hi Kent,
no, you won't be able to reliably get in front of all plugins.
Maybe you can do it the other way round. While it's not possible to delete the plugin binary, while still in use, you should be able to rename the plugin folder.
So the workflow could look like this:
- Rename the plugin folder to be updated (and remember its name for next start).
- Install the updated plugin.
- Restart Cinema 4D.
- On next start delete the old folder during
C4DPL_STARTACTIVITY
.
But while this works for me, when renaming the folder manually in file explorer (while still in use by C4D), I have to admit, I did not succeed using Cinema's
GeFRename()
as it fails with permission denied. So you may need to look for some OS specific solution here.Cheers,
Andreas -
You won't be able to rename the plugin folder since the plugin will already have been loaded by C4D. Also renaming folders is not really a good solution.
I am only using R20 for this, and it seems that ALL the plugins are loaded at startup, then the PluginStart() method is called for each of them. But even if PluginStart returns false, the plugin stays loaded so it is still locked by the operating system.
One solution that would work for me is if C4D unloaded a plugin if PluginStart() returns false.
Is there some reason why plugins are not unloaded if PluginStart() returns false?
-
I have decided to go with a two step install. Telling the user that they need to close down C4D and delete the plugin manually from their machine, then restart twice (once to install, second to load it up). A bit messy, but it works for now.
If we can ever unload a plugin, or tell it not to load via PluginStart returning false, then that would clean this up a lot.
-
@kbar said in When can I display a dialog at startup?:
You won't be able to rename the plugin folder since the plugin will already have been loaded by C4D. Also renaming folders is not really a good solution.
I am only using R20 for this, and it seems that ALL the plugins are loaded at startup, then the PluginStart() method is called for each of them. But even if PluginStart returns false, the plugin stays loaded so it is still locked by the operating system.
One solution that would work for me is if C4D unloaded a plugin if PluginStart() returns false.
Is there some reason why plugins are not unloaded if PluginStart() returns false?
Hi Kent,
well, the hint actually came from Rick, who's using this technique in the Cineversity Toolbox for updating plugins.
And as I said, while I was not able to rename the folder with our API, it was very well possible to rename the folder containing a plugin in use (while it was not possible for the actual plugin binary) using the explorer. So I still think, this should be possible somehow.
On the other hand you seem to have a solution for now, great.For R20 and beyond things get actually even more complicated and less likely to have an unload option for plugins. MAXON API plugins don't have the PluginX() functions anymore. Their load order gets determined by dependencies and it is very easy to make use of one plugin from another plugin, making unloading of plugins even more complicated. As we are moving away from the classic API, it gets more and more unlikely the mechanism will change for classic plugins.
Nevertheless I see your need and will forward the request to development.Cheers,
Andreas -
Thanks Andreas. I will try Rick's trick again today. When I looked into it yesterday it didn't seem to work, but now I am wondering if perhaps it was visual studio locking the folders, and not actually C4D, since I was debugging at the time. I just tested renaming files manually (without running it through VS) and it was possible.
I think Ricks dialog was done in Python, so he wouldn't have hit this VS issue. Fingers crossed it all works today.