How to 'Reload Scripts Plugin' using python

How to 'Reload Scripts Plugin' using python

Anonymous
Not applicable
1,707 Views
9 Replies
Message 1 of 10

How to 'Reload Scripts Plugin' using python

Anonymous
Not applicable

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).

0 Likes
1,708 Views
9 Replies
Replies (9)
Message 2 of 10

christian_aubert
Contributor
Contributor

Bump

0 Likes
Message 3 of 10

sinje_thiedemann
Autodesk
Autodesk

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.

0 Likes
Message 4 of 10

christian_aubert
Contributor
Contributor

I'm actually more interested in the ability to call "Edit>Reload Scripts Plugins" from a script.

0 Likes
Message 5 of 10

sinje_thiedemann
Autodesk
Autodesk

@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?

0 Likes
Message 6 of 10

christian_aubert
Contributor
Contributor

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.

0 Likes
Message 7 of 10

sinje_thiedemann
Autodesk
Autodesk
Thanks, I've logged your request.
0 Likes
Message 8 of 10

marc.winter2
Advocate
Advocate

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

0 Likes
Message 9 of 10

sinje_thiedemann
Autodesk
Autodesk

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)

 

 

Message 10 of 10

marc.winter2
Advocate
Advocate

Thank you Sinje😊

0 Likes