Community
VRED Forum
Welcome to Autodesk’s VRED Forums. Share your knowledge, ask questions, and explore popular VRED topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to 'Reload Scripts Plugin' using python

9 REPLIES 9
Reply
Message 1 of 10
Anonymous
764 Views, 9 Replies

How to 'Reload Scripts Plugin' using python

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

Labels (2)
9 REPLIES 9
Message 2 of 10
christian_aubert
in reply to: Anonymous

Bump

Message 3 of 10
sinje_thiedemann
in reply to: Anonymous

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.

Message 4 of 10

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

Message 5 of 10
sinje_thiedemann
in reply to: Anonymous

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

Message 6 of 10
christian_aubert
in reply to: Anonymous

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.

Message 7 of 10

Thanks, I've logged your request.
Message 8 of 10

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

Message 9 of 10

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
in reply to: Anonymous

Thank you Sinje😊

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Technology Administrators


Autodesk Design & Make Report