JudeMarv Posted June 19, 2019 Share Posted June 19, 2019 Hello guys, Is there a way I can modify or create a custom viewer state for an existing node (polybevel, edit) through python. I essentially want to add advanced hotkeys and shortcuts to the existing nodes through python viewer states. I've tried writing a script that sets the viewer to a custom state upon the creation of node by adding OnCreated Python script to the Houdini scripts folder, but it refuses to switch the viewer state with this method. Thanks Quote Link to comment Share on other sites More sharing options...
vtrvtr Posted June 19, 2019 Share Posted June 19, 2019 I didn't actually went through doing something elaborated, but it seems to me I can enter a different state fine while selection polybevel import stateutils sv = stateutils.findSceneViewer() sv.currentState() >> polybevel::2.0 sv.setCurrentState("some_state") sv.currentState() >> some_state Quote Link to comment Share on other sites More sharing options...
JudeMarv Posted June 21, 2019 Author Share Posted June 21, 2019 What I am trying to do is write the script and save it at the following directory "scripts/sop/polybevel_2.0.py" so that every time a polybevel node is created, it runs the script at that location (https://www.sidefx.com/docs/houdini/hom/locations.html#node_event_files) I've found out that whenever I try to enter a new state using code in that location upon the creation of a polybevel node, the state will trigger and immediately exit and go to the default polybevel state. I hope this makes sense. Is this also what your were doing? Or did you just run the code in the python shell? I have no issues changing states in the python shell or using a tool script. Thanks Quote Link to comment Share on other sites More sharing options...
vtrvtr Posted June 21, 2019 Share Posted June 21, 2019 No, I was just using the shell Yeah, apparently the OnCreated callback (which is wrongly named OnCreate on that page btw) is called before the polybevel itself enters its state I guess your best bet is put a hotkey or shelf that changes the state when you use it. You could also make a wrapper HDA around polybevel. Quote Link to comment Share on other sites More sharing options...
JudeMarv Posted June 22, 2019 Author Share Posted June 22, 2019 Thanks! I had thought about putting it into a wrapper HDA, which works well for something like a polybevel, but doesn't work well for the edit SOP which I want to customize so that the controls match something like Maya. Any thoughts on how I can make this work? Thanks Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.