Jump to content

Modifying built in viewer states?


JudeMarv

Recommended Posts

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

 

Link to comment
Share on other sites

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

 

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

 

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...