How to dynamic load custom "Dynamic Simulations" plugins?

   111   0   0
User Avatar
Member
1 posts
Joined: Nov. 2021
Offline
Hi all,
I wrote a plugin. The plugin's code referenced houdini HDK, Dynamic Simulations plugin example, see this page: https://www.sidefx.com/docs/hdk/_h_d_k__intro__creating_plugins.html [www.sidefx.com]

Now I want to implement dynamic loading for this plugin. But there were some problems.

First, I tried to use python API to load it.
hou.nodeTypeCategories()['Dop'].loadDSO('--dll path--')
Since its registration function is initializeSIM () and not newDopOperator (). Therefore the load fails.

Then, I tried to use _ctypes to load it.
import _ctypes
handle = _ctypes.LoadLibrary('--dll path--')
The handle is not None. But I can't create the node in Dop Network. I think I missed some operations like registering it in houdini. But I don't know how to do it.


Due to my SOP plugins can be loaded by
hou.nodeTypeCategories()['Sop'].loadDSO('--dll path--')
Maybe I can use a SOP to load Dynamic Simulations plugins! I made the following attempts in a SOP plugin C++ code.
    static UT_DSOHandle* dsoHandle;
    UT_DSO dso;
    UT_String* errorOutput = NULL;
    const char dsoFile[] = "--dll path--";
    dsoHandle = dso.loadDSO(dsoFile,
        false,
        errorOutput
    );
    const char symbolName[] = "initializeSIM";
    UT_StringHolder* errorOutput1 = NULL;
    UT_StringHolder fileName = dso.getFilePath(dsoHandle, *errorOutput1);
    
    bool result = dso.run(dsoFile, symbolName);
I think the dll is loaded, but it still not create node in dop network.

Another idea is to dynamic update the HOUDINI_DSO_PATH, and rescan this path.
The python code like:
import hou

current_dso_path = hou.getenv("HOUDINI_DSO_PATH")
my_plugin_path = "/path/to/my/custom/plugins"
new_dso_path = current_dso_path + ";" + my_plugin_path 
hou.putenv("HOUDINI_DSO_PATH", new_dso_path)
But I can't find the rescan command.

My expectation is that when this plugin is not in the dso folder, it can be loaded and used without restarting houdini.
Is there any solution for this problem?

Thank you very much!
  • Quick Links