I decided to post python viewer states problems in this thread.
In H17.5, after activation with onResume method, the state continues to generate the mouse move event (hou.uiEventReason.Located). But in H18 this type of event stops happening.
Test build: Houdini 18.0.318 Linux version
Python Viewer States Issues
2983 13 3- Alexey Vanzhula
- Member
- 538 posts
- Joined: 12月 2006
- Offline
- Alexey Vanzhula
- Member
- 538 posts
- Joined: 12月 2006
- Offline
I have solve the problem myself
Anyway, according to the documentation:
this value have to be True by default, but in fact it is not.
def onGenerate(self, kwargs): kwargs['state_flags']['mouse_drag'] = True
Anyway, according to the documentation:
Mouse drag events are generated by default (True)
this value have to be True by default, but in fact it is not.
Edited by Alexey Vanzhula - 2019年12月15日 08:30:56
- Alexey Vanzhula
- Member
- 538 posts
- Joined: 12月 2006
- Offline
- Alexey Vanzhula
- Member
- 538 posts
- Joined: 12月 2006
- Offline
- Alexey Vanzhula
- Member
- 538 posts
- Joined: 12月 2006
- Offline
Currently, we can't draw the drawable geometry immediately after activating the state in the onEnter or onGenerate methods. In the current Python states implementation, we must first move the mouse to update the drawables. So, we need a method to force update.
Edited by Alexey Vanzhula - 2019年12月22日 09:18:36
- Alexey Vanzhula
- Member
- 538 posts
- Joined: 12月 2006
- Offline
- mabelzile
- スタッフ
- 446 posts
- Joined: 2月 2018
- Offline
vux
I decided to post python viewer states problems in this thread.
In H17.5, after activation with onResume method, the state continues to generate the mouse move event (hou.uiEventReason.Located). But in H18 this type of event stops happening.
Test build: Houdini 18.0.318 Linux version
Ok thanks for reporting. It's best to log bugs though so python states issues don't fall in the cracks.
- mabelzile
- スタッフ
- 446 posts
- Joined: 2月 2018
- Offline
- mabelzile
- スタッフ
- 446 posts
- Joined: 2月 2018
- Offline
vux
Currently, we can't draw the drawable geometry immediately after activating the state in the onEnter or onGenerate methods. In the current Python states implementation, we must first move the mouse to update the drawables. So, we need a method to force update.
Use `hou.GeometryViewport.draw()` to force a redraw.
- Alexey Vanzhula
- Member
- 538 posts
- Joined: 12月 2006
- Offline
Thank you for answers!
Yes, but this did not work in my case. I will show my example in a few hours
mabelzilevux
Currently, we can't draw the drawable geometry immediately after activating the state in the onEnter or onGenerate methods. In the current Python states implementation, we must first move the mouse to update the drawables. So, we need a method to force update.
Use `hou.GeometryViewport.draw()` to force a redraw.
Yes, but this did not work in my case. I will show my example in a few hours
- Alexey Vanzhula
- Member
- 538 posts
- Joined: 12月 2006
- Offline
In this example, I want the circle to appear immediately after the state is activated. But it appears only after I start to manipulate the viewport using the Alt key.
class TestTemplate(object): _drawable_geo = hou.Geometry() circle = hou.sopNodeTypeCategory().nodeVerb("circle") circle.setParms({ "type": 2 }) circle.execute(_drawable_geo, []) del circle def __init__(self, scene_viewer, state_name): self.scene_viewer = scene_viewer self.state_name = state_name self._drawable = hou.SimpleDrawable(self.scene_viewer, self._drawable_geo, "test_drawable") def onGenerate(self, kwargs): self._drawable.enable(True) self._drawable.show(True) self.scene_viewer.curViewport().draw() # UNREGISTER if hou.ui.isRegisteredViewerState('test_state'): hou.ui.unregisterViewerState('test_state') # CREATE AND REGISTER template = hou.ViewerStateTemplate('test_state', 'Test State', hou.sopNodeTypeCategory()) template.bindFactory(TestTemplate) hou.ui.registerViewerState(template) # ACTIVATE scene_viewer = hou.ui.paneTabOfType(hou.paneTabType.SceneViewer) scene_viewer.setCurrentState("test_state")
- mabelzile
- スタッフ
- 446 posts
- Joined: 2月 2018
- Offline
It works fine in H18 with this python state file version:
Tools:
import hou import viewerstate.utils as su class State(object): _drawable_geo = hou.Geometry() circle = hou.sopNodeTypeCategory().nodeVerb("circle") circle.setParms({ "type": 2 }) circle.execute(_drawable_geo, []) del circle def __init__(self, scene_viewer, state_name): self.scene_viewer = scene_viewer self.state_name = state_name self._drawable = hou.SimpleDrawable(self.scene_viewer, self._drawable_geo, "test_drawable") def onGenerate(self, kwargs): self._drawable.enable(True) self._drawable.show(True) #self.scene_viewer.curViewport().draw() def createViewerStateTemplate(): """ Mandatory entry point to create and return the viewer state template to register. """ state_typename = "z" state_label = "Z" state_cat = hou.sopNodeTypeCategory() template = hou.ViewerStateTemplate(state_typename, state_label, state_cat) template.bindFactory(State) template.bindIcon("MISC_python") return template
Tools:
import stateutils as su viewer = su.findSceneViewer() viewer.setCurrentState("z")
Edited by mabelzile - 2020年1月5日 13:53:40
- Alexey Vanzhula
- Member
- 538 posts
- Joined: 12月 2006
- Offline
mabelzile
It works fine in H18 with this python state file version:import hou import viewerstate.utils as su class State(object): _drawable_geo = hou.Geometry() circle = hou.sopNodeTypeCategory().nodeVerb("circle") circle.setParms({ "type": 2 }) circle.execute(_drawable_geo, []) del circle def __init__(self, scene_viewer, state_name): self.scene_viewer = scene_viewer self.state_name = state_name self._drawable = hou.SimpleDrawable(self.scene_viewer, self._drawable_geo, "test_drawable") def onGenerate(self, kwargs): self._drawable.enable(True) self._drawable.show(True) #self.scene_viewer.curViewport().draw() def createViewerStateTemplate(): """ Mandatory entry point to create and return the viewer state template to register. """ state_typename = "z" state_label = "Z" state_cat = hou.sopNodeTypeCategory() template = hou.ViewerStateTemplate(state_typename, state_label, state_cat) template.bindFactory(State) template.bindIcon("MISC_python") return template
Tools:import stateutils as su viewer = su.findSceneViewer() viewer.setCurrentState("z")
Houdini 18.0.340 Linux. The drawable appear only after moving the mouse. Test it from the Python Source Editor.
- Alexey Vanzhula
- Member
- 538 posts
- Joined: 12月 2006
- Offline
-
- Quick Links