Skip to main content
Participant
June 28, 2023
Answered

Is there any possible way to get the notification on "Node Selected Change" ?

  • June 28, 2023
  • 1 reply
  • 169 views

We are trying to build a plugin for setting each node properties more convenience, for some reason we need to know that the user change the current selected node to other node. Need to be a callback function.

 

We excepted to do this by Python, or any other possible method to achieve this, appreciate!

This topic has been closed for replies.
Correct answer Cyril Dellenbach

Hi @Posheng291083095rbo,

 

Thanks for the message,

 

Currently, there's no solution for a callback function, but your message has been taken into account, so maybe in the future.

 

In the meantime, you can compare lists from a getCurrentGraphSelectedNodes() call:

 

import sd, os
from sd.api import sdproperty
app = sd.getContext().getSDApplication()
ui_mgr = app.getQtForPythonUIMgr()
selection_a = [node.getIdentifier() for node in ui_mgr.getCurrentGraphSelectedNodes()]
# Put some code here for adding a delay...
selection_b = [node.getIdentifier() for node in ui_mgr.getCurrentGraphSelectedNodes()]
# Check if selection has changed
if selection_a != selection_b:
	print("Selection has changed!")

 

Definitely overkill, but can still be useful.

 

Best regards,

 

1 reply

Cyril Dellenbach
Community Manager
Cyril DellenbachCommunity ManagerCorrect answer
Community Manager
June 30, 2023

Hi @Posheng291083095rbo,

 

Thanks for the message,

 

Currently, there's no solution for a callback function, but your message has been taken into account, so maybe in the future.

 

In the meantime, you can compare lists from a getCurrentGraphSelectedNodes() call:

 

import sd, os
from sd.api import sdproperty
app = sd.getContext().getSDApplication()
ui_mgr = app.getQtForPythonUIMgr()
selection_a = [node.getIdentifier() for node in ui_mgr.getCurrentGraphSelectedNodes()]
# Put some code here for adding a delay...
selection_b = [node.getIdentifier() for node in ui_mgr.getCurrentGraphSelectedNodes()]
# Check if selection has changed
if selection_a != selection_b:
	print("Selection has changed!")

 

Definitely overkill, but can still be useful.

 

Best regards,

 

Cyril Dellenbach (Micro) | QA Support Artist | Adobe