States: ‘kwargs’ in init and createViewerStateTemplate()?

   1687   3   1
User Avatar
Member
192 posts
Joined: April 2015
Offline
Hi,


I would like to create some handles based on node data (in the State class __init__) and bind them (in createViewerStateTemplate().

I am struggling to get the
kwargs[node]
data in these two parts of the code that you do have acces to in all the Event Handlers.

In __init__ I can type node = scene_viewer.currentNode(), but in createViewerStateTemplate() I did not find a way yet. I did try self.node, tried @classmethod.

Any ideas?


Thanks in advance.
Edited by OdFotan - May 27, 2020 03:16:08
User Avatar
Member
201 posts
Joined: July 2015
Offline
Take a look at the provided examples at $HH/viewer_states/examples.

The kwargs dict is given as an arg to a lot of the event callbacks like onEnter, onDraw, etc.

You can put this in onEnter self.node = kwargs and access it everywhere else afterwards.
Manuel Köster - Senior Technical Artist @Remedy Entertainment

https://www.remedygames.com/ [www.remedygames.com]
http://shadesoforange.de/ [shadesoforange.de]
https://twitter.com/ShadesOfOrange_ [twitter.com]
User Avatar
Member
192 posts
Joined: April 2015
Offline
Thanks for the help, but sorry I did not specify the problem accurate enough:
I get this error when using self in createViewerStateTemplate()

I just found about of this global keyword, but that also gives me this error when trying to acces from createViewerStateTemplate()

I suspect createViewerStateTemplate() and init are run before any of the event handlers are allowed to be called.

I also thought of creating or running a function there that gets the kwargs into these parts, but then, it seems, the function argument also needs to be (kwargs), which don’t exist there yet.
Edited by OdFotan - May 27, 2020 04:31:56

Attachments:
Screenshot 2020-05-27 at 10.06.28.png (6.1 KB)
Screenshot 2020-05-27 at 10.16.24.png (40.2 KB)

User Avatar
Staff
396 posts
Joined: Feb. 2018
Offline
The state instance doesn't exist at the point when createViewerStateTemplate is called by Houdini. createViewerStateTemplate will register a template for your state which Houdini can use to create instances of your state when requested (e.g. entering the state in the viewport).

Custom python handles are not supported yet.
  • Quick Links