Run Plugin Last
-
Hi guys,
I'm drafting a tool that will inform the user with any plugins/scripts updates and that will point to the relevant wiki page for more information.
I have a few questions that hopefully you can help me address.
- Is it possible to run the plugin last or after everything else is loaded?
Because I'm dynamically creating the IDs for the buttons on the left, what would be the best approach to retrieve the correct id to link it it to the correct command, once the button is pressed?
Perhaps collect the data in the plugin's BaseContainer()?
Found the solution here: https://developers.maxon.net/forum/topic/6375/6817_nth-button-press/2
I should give sequential IDs to make it easier to collect them. I've then created a BaseContainer() under the plugin with each id and values. The values were separated by commas for me to split later. Perhaps this is bit too complex?
The next steps would be to change the dialog to a treeview, which will look a lot cleaner.
Thank you in advance!
Andre
-
Hi @AndreAnjos ,
Cinema 4D offers multiple Messages that can be caught in the PluginMessage method of your plugin.
You can find relevant messages ID in the Plugin Functions Manual C++ manuals in the Start section.
Note all these Messages are also sent to Python plugin. See c4dpl
Here a full example
import c4d PLUGIN_ID = 1000001 class MyDialog(c4d.gui.GeDialog): def CreateLayout(self): self.SetTitle("My Python Dialog") return True def PluginMessage(id, data): print "Pluginmessage" if id==c4d.C4DPL_PROGRAM_STARTED: c4d.CallCommand(PLUGIN_ID) class CommandDataPlugin(c4d.plugins.CommandData): dialog = None def Execute(self, doc): if self.dialog is None: self.dialog = MyDialog() return self.dialog.Open(dlgtype=c4d.DLG_TYPE_ASYNC, pluginid=PLUGIN_ID, defaulth=400, defaultw=400) def RestoreLayout(self, sec_ref): if self.dialog is None: self.dialog = MyDialog() return self.dialog.Restore(pluginid=PLUGIN_ID, secret=sec_ref) if __name__ == "__main__": c4d.plugins.RegisterCommandPlugin( PLUGIN_ID, "CommandDataPlugin", 0, None, None, CommandDataPlugin())
- Yes, this is the correct way for doing it. Maybe you can simplify this by not using a BaseContainer but simply looping over and using a BaseID + the ID of the item in the loop.
Another way could be to implement SubDialog, A good example can be found at https://labs.maxon.net/?p=3235 where each COFFEE element is a SubDialog.
But in any case, this will not work for a TreeView.
If you have any questions please let me now.
Cheers,
Maxime. - Yes, this is the correct way for doing it. Maybe you can simplify this by not using a BaseContainer but simply looping over and using a BaseID + the ID of the item in the loop.
-
@m_adam
Hi Maxime,It works like a treat!
I've ended up changing the UI to a treeView and it's still working great.
Thank you very much!Andre