Hi,
I want to load different UI-window based on the differernt node (with specific name) selected in VRED scenegraph.
For this, currently I need to click Edit>Reload Scripts Plugins option, everytime I select a new node, so that a different UI-window gets loaded according to the name of this newly selected node. (My python and ui scripts are present in 'Scripts' menu (plugin) of VRED.
But I would like to know, how can I implement this functinality using Python code itself so that I can avoid clicking Edit>Reload Scripts Plugins option, for every new node selection. Please find the attached screenshot.
Kindly feel free to reply if you have any relative solution/explanation/question (or also if you don't understand anything in what I have written).
Hi,
so essentially you want to react on changed node selection in your script plugin(s)?
This can be done by connecting a function to the signal vrNodeService.selectionChanged():
def onNodeSelectionChanged():
nodes = vrNodeService.getSelectedNodes()
print("selection changed", len(nodes))
# update GUI
# ...
vrNodeService.selectionChanged.connect(onNodeSelectionChanged)
In this function you'll need to update your GUI using the new selected nodes.
I'm actually more interested in the ability to call "Edit>Reload Scripts Plugins" from a script.
@christian_aubert There's no function to do that, as far as I know. What is your use case, maybe it can be done differently?
We have our own script distribution system that puts files in their proper place, but those scripts won't work until "reload scripts" takes places. Would like to automate that to avoid support calls of the "have you turned it off and on" type.
Hi Sinje,
in which VredVersion the vrNodeService.selectionChanged was added?
With my Vred2022.2 it seems not to work. 😞
Is there a good way for older VredVersions?
Best regards,
Marc
Hi Marc,
vrNodeService.selectionChanged was added in 2022.3.
An alternative are "old" messages from API v1 (vrController) which can be received via vrMessageService. Please note, when you change selection from nodeA to nodeB, you will get both a selected and deselected message. Maybe reacting on selected only is sufficient for your purpose.
def receivedMessage(msg, args):
if msg == vrController.VRED_MSG_SELECTED_NODE:
print("selected node")
elif msg == vrController.VRED_MSG_DESELECTED_NODE:
print("deselected node")
vrMessageService.message.connect(receivedMessage)
Can't find what you're looking for? Ask the community or share your knowledge.