"Reload Python Plugins" not reloading
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 30/03/2012 at 15:21, xxxxxxxx wrote:
The documentation states:
"With these commands, existing C.O.F.F.E.E. or Python plugins, respectively, can be reloaded (from the corresponding directories). Hence, if you have made a modification to the plugin's source code, the plugin can be reloaded without having to restart CINEMA 4D."
Im testing this with this "starter" plugin from here. http://www.smart-page.net/blog/2012/02/22/smart-hn-options-cinema-4d-python-commanddata-plugin-template/
And what I'm doing to test it, is just changing a string to be printed to the console in maindialog.py's CreateLayout method.
def CreateLayout(self) :
print "foo"to
def CreateLayout(self) :
print "bar"I load the plugin and "foo" prints. Change the source code to "bar". Then I click the "Reload Python Plugins" command. And load the plugin again; "foo" prints instead of "bar".
This command doesn't seem to work, unless I'm missing something.
I tried hooking into PluginMessage's c4d.C4DPL_RELOADPYTHONPLUGINS event reload everything with this python module reloader from https://github.com/jparise/python-reloader. It runs fine when I reload the smarthnoptions module, but nothing changes in C4D.
Any thoughts on this?
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 30/03/2012 at 15:40, xxxxxxxx wrote:
hm,
at least for objectdata and tooldata plugins it works quite well. could be a limitation of commanddata
plugins. i have observed the following : when your plugin has errors that prevent it to be loaded
correctly, reload plugins won't work (after fixing these errors). also any changes in your ressource
files aren't reflected in reload plugins. changing the code in the py file on a working plugin works for
me.edit : your console returns no erorrs on laoding this plugin ? in your example is missing at least a
return True as CreateLayout() has to return a boolean. -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 30/03/2012 at 15:50, xxxxxxxx wrote:
Hello fusepilot,
When the plugin is being reload, only the plugin-source (.pyp file) is evaluated. Modules that have already been imported will not be reloaded. Anyway, you seem to have that figured out, well.
I don't know how the reloader module is implemented but don't you need to specify what modules to reload? You may want to try the reload() function.
Cheers,
Niklas -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 30/03/2012 at 16:03, xxxxxxxx wrote:
littledevil,
That was be an unfortunate caveat. Especially since you could consider whats inside the module subfolder source code.
And there is a "return True" at the end of the method. I just posted what I thought was relevant.
NiklasR,
I also should have added that I first tried reload(), figured that wasn't working then tried python-reloader. Thanks for the tip that its works in the .pyp file. Tried it and confirmed.
So knowing that it works in the .pyp, is there anything besides reload() that I could try with the C4DPL_RELOADPYTHONPLUGINS hook? Or maybe someone has an example of reload working there?
Thanks guys.
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 31/03/2012 at 13:25, xxxxxxxx wrote:
The Python Reload function reloads and recompiles the source of a *.pyp file. Python modules which are imported by a *.pyp file will not be reloaded again. As already mentioned in a post before, this is related to the fact that Python first checks if the module is already imported - and if yes this is skipped and just the reference is set.
In other words, you can use the reload() function to make a force reload of a Python module when the C4DPL_RELOADPYTHONPLUGINS is called. This is also the place where you can close system resources (e.g. sockets) when you opened the before.
Cheers, Sebastian