Could set initial selection to volatile selector?

   668   2   0
User Avatar
Member
628 posts
Joined: Nov. 2013
Offline
Hi,

In my python state, I want to set a group of points as initial selection when pressing 'S' to enter select state.
How to set the initial selection to volatile selector?

Thanks for any tips!
User Avatar
Staff
401 posts
Joined: Feb. 2018
Offline
You could try populating the selection in onStartSelection like this

    def _initGeoSelection(self):
        sel = hou.Selection(self._node.geometry(), hou.geometryType.Points, "0-25")
        self.scene_viewer.setCurrentGeometrySelection(hou.geometryType.Points, (self._node, ), (sel, ))
    
    def onStartSelection(self, kwargs):    
        self._node = kwargs["node"]
        hou.ui.postEventCallback(self._initGeoSelection)

I'm afraid the above won't work as onStartSelection is designed for python state selectors only. You could try however onInterrupt to configure the initial selection as the current state gets interrupted in the middle of the select state, before the selector is started up, so it might be possible to do something in there. But it's not ideal either, I guess the best way would be a new handler for this specific purpose.
Edited by mabelzile - April 18, 2023 11:54:30
User Avatar
Member
628 posts
Joined: Nov. 2013
Offline
Thanks for the tips!
  • Quick Links