[Closed] Initialize scripted plugin
When you create a scripted geometry plugin and want to create an instance of it through code (eg. PluginName()), it errors out until you drag and drop the plugin into the viewport to initialize it. It gets initially loaded through the scripts startup folder but that doesn’t seem to be sufficient.
Creating an instance through the create panel works fine, just not through code until you drag and drop the plugin to initialize it.
Any idea why I need to drag and drop it?
Thanks a lot,
Davy
I think that you are doing something wrong or there is a bug in your script…
Show the code and someone will help you for sure.
If there is a bug in my code, why does it work without issues when I manually drag and drop the plugin in my viewport and after that create an instance through code?
That points in a direction that the plugin does not initialize at startup, no?
it’s not initialized at startup for sure. but as i understood you want know not the fact of that but the reason.
Ok it is impossible to show the code but it’s good to know where to search. Let me try to convert it to the very basic and see if that works.
It is still a mistery that drag and drop actually works.
Looks like I had some code outside the plugin loop which is not allowed so it seems. It does not complain about it, it works…but not completely since it does not initialize the plugin at startup.
This could be caused because your scripted plugin might have a dependency on something in Max and is being run before Max’s own systems have fully loaded… For example, Scripted Materials in particular it seems will be run on startup before the Max’s material system has fully initialised and hence causes an error on load even though it works absolutely fine when run after Max has loaded.
The solution I use is to batch up stuff like this into a postsystemstartup callback so that it gets run directly after Max has fully finished loading.