Jump to content

Creating Tools on the Shelf using HOM


Jason

Recommended Posts

I was skeptical at first but some quick investigation has proven it is indeed possible.

You can access all the Shelves, Shelf Sets and tool stuff through the hou.shelves submodule. From there I was able to create a new shelf, create new tools and add them to this shelf.

My current shelf set is the Technical Director one so the following code uses it. Others can be accessed from hou.shelves.shelfSets()

td = hou.shelves.shelfSets()["shelf_set_td"]

my_shelf = hou.shelves.newShelf("/tmp/my_shelf.shelf", "my_shelf", "My Cool Shelf")

my_tool = hou.shelves.newTool("/tmp/my_tool.shelf", "my_tool", "Print kwargs", script="print kwargs")
# The function to add a tool to the shelf takes a tuple/list so you are best off creating all your tools and adding them at once.  If
# you don't want to do that you can do something involving lists like myshelf.setTools(list(myshelf.tools()) + [tool1, tool2, etc])
my_shelf.setTools((my_tool,))
# The same must be done with hou.ShelfSet.setShelves.  Another example of using lists that you could do for a loop.   You can get a dictionary of every tool available in Houdini by doing hou.shelves.tools().  This allows you to use existing tools you might have already written as long as they are located in the HOUDINI_PATH.
td_shelves = list(td.shelves())
td_shelves.append(my_shelf)
td.setShelves(td_shelves)

Voila. My Cool Shelf with a Print kwargs tool on it. Hope that helps :)

Edited by graham
Link to comment
Share on other sites

Another quick bit, I must thank Jason for asking the question as I think it's helped me uncover a rather annoying permission error/crash with editing shelves on the Mac build.

Any time, and I must thank YOU profusely for posting this example:) You should wiggle it into the HOM Cookbook, or something like it!

Link to comment
Share on other sites

  • 1 month later...

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...