Jump to content

Is there a way to distinguish between opening a file vs launching Houd


magneto

Recommended Posts

Hi,

I want to do some UI related actions if Houdini is launched by double clicking a hip file, but not when opening a file by using File -> Open.

456.py is executed in both cases. Is there a way to distinguish between the two so I can add this code inside 456.py that would bypass the UI related code inside?

Only way I could think of is to save the hou.hipFile.name() to somewhere and do a comparison. But I imagine this might slow down the startup slightly and has more book keeping that needs to be done, for example resetting the value back to some default on Houdini exit, etc.

Thanks :)

Link to comment
Share on other sites

From what I can tell, there's no way to really tell how Houdini was launched.

You could probably do something like the following though:

1. In pythonrc.py, store some variable in hou.session (hou.session.starting=True)

2. In 456.py, check the status of hou.session.starting and if it's True you are starting up Houdini. You could then check hou.hipFile.name() to see if you are starting up with a hip file (not untitled.hip). Also, you need to set hou.session.starting = False afterwards.

3. If you then do another File > Open, the starting variable is False so you know you are loading a hip from inside Houdini.

  • Like 1
Link to comment
Share on other sites

Thanks Graham. I just did it and it works great. Instead of using pythonrc which I couldn't find anything in the help, I am setting the variable in 123.py which is only executed when I directly launch Houdini. If I double click a hip file, then only 456.py seems to be executed.

So I am only running it if I can find the member in hou.session. If it's not there, I create it in 456.py so that when I open a different file, it doesn't run again.

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