If I have module_A that I have previously used and have some generic object within it, how can I access that object in module_A from module_B?
I know I can use another module/extension’s logic but I need to access the instance of the object to check its state between 2 extensions.
You can only create new node types in C++. In Python but you can customize any existing nodes (add custom attributes, parameters, node references). If there is no specific node that you want the associate these additional information with then you can use a vtkMRMLScriptedModuleNode.
What kind of object do you want to share between modules? Is it Python-wrapped C++ object or a pure Python object? What does it store?
The extension i am working on creates a TCP/IP socket connection with a server. this sock variable stores the instance which I use throughout the extension to handle events of incoming data. I would like to be able to access that instance from another extension.
If there is only a single instance of this object, you don’t need to observe it, and you don’t need to serialize its state to the scene, you can simply make it a member of the module logic. You can access any a module’s logic class from any other module. From one Python scripted module you can access another Python scripted module’s logic like this:
I was able to access the object instance
I didn’t know slicer extension instances, once launched, are saved and can be accessed via slicer.modules… i thought i can only access logic and routines not instanced objects
slicer.modules.BlenderMonitorWidget.sock = instance pointed