Jump to content
haggi

How to execute shelf button via python?

Recommended Posts

Hi,

I'd like to execute a shelf button from python? Is this possible?

Share this post


Link to post
Share on other sites
my_shelf_tool = hou.shelves.tool("my_shelf_tool_internal_name")
my_script = my_shelf_tool.script()
exec(my_script)

or

hou.SceneViewer.runShelfTool("my_internal_shelf_tool_name")

 

Share this post


Link to post
Share on other sites

Thanks, that was fast.

Unfortunately I have problems with both methods. The first method gives me (with a simple test tool which creates a sphere):

>>> st = hou.shelves.tool("converter")
>>> s=st.script()
>>> exec(s)
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "<string>", line 12, in <module>
NameError: name 'kwargs' is not defined
>>> 

And the other one seems only to work from within the UI, but I'd like to execute the shelf button from hython commandline.

Share this post


Link to post
Share on other sites

Yeah I see, I'm getting this error too, because I guess the shelf tool needs some sort of info to set up kwargs and executing it from a script doesn't seem to give it the info. Why not creating a normal  script and then executing it with hython instead of creating a shelf tool ?

Share this post


Link to post
Share on other sites

I just set the kwargs with:

kwargs={}

and it seems to work :)

  • Thanks 1

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×