Is it possible to execute Python before opening a hipfile?

   408   1   0
User Avatar
Member
28 posts
Joined: 8月 2017
Online
My goal is to check conditions when I open a hip file.

My hipfile has a JSON file next to it with info.

If I go to File > Open... and my current houdini session doesn't meet the conditions (i.e. the JSON file states Redshift is required and I don't have Redshift, or my houdini version is too low) it stops loading the file. And then executes more logic, maybe starts a new houdini process that meets the criteria.

Is there an event I can plug into? And how?

Edit:
After some digging, I see I probably need to use hou.hipFileEventType.BeforeLoad. But how do I stop the file from being loaded?
Edited by alexmajewski - 2024年11月27日 08:22:52
User Avatar
Member
222 posts
Joined: 5月 2017
Offline
Hi I did not find any command with py/hscript to stop or hold the loading process. But as you already found out you could use Before/AfterLoad to (re)load a hip under custom conditions.

A cleaner variant (direct through houdini) would be to create a custom hip loader. A menu item that executes a loading process.
You can create a new menu section or add an item to the native menu. Under $HH/MainMenuCommon.xml or a custom $HOUDINI_PATH/MainMenuCommon.xml.

Customize menus [www.sidefx.com]
Dialog to select a hip file...
hou.ui module [www.sidefx.com]
Edited by viklc - 2024年11月27日 13:15:37

Attachments:
Menu.jpg (24.2 KB)

  • Quick Links