How can I determine if my node is selected in the node view?
Answer:
The display of image processing nodes in Shake's node view panel is managed by a specialized object called a 'sharing hook' (see NRiSharingHook.h). Shake assigns a sharing hook object to each image processing node in the node tree when Shake is run in interactive mode.
A registry of all the sharing hook objects in the script is maintained by the NRiSharingHook base class. To retrieve the sharing hook object assigned to your node, you would call the following:
The NRiSharingHook object owns a plug called 'grouped' that is set to 1 when a node is selected and to 0 when a node is unselected. To determine if your node is currently selected, you would call:
int isSelected = sh->grouped()->asInt();
Alternately, if you want to modify the selection state of your node, you would set the grouped plug on the sharing hook node to either 0 (not selected) or 1 (selected):
sh->grouped()->set(1); // selected
In addition, the NRiSharingHook object has member plugs that store the x and y position of the node in the node view. They can be retrieved as follows: