magneto Posted December 8, 2013 Share Posted December 8, 2013 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 Quote Link to comment Share on other sites More sharing options...
crunch Posted December 8, 2013 Share Posted December 8, 2013 I'm sure there are other ways, but you could try something like: try: from hou import ui graphical = True except: graphical = False P.S. This would be a great question for http://area51.stacke...s/57115/houdini 1 Quote Link to comment Share on other sites More sharing options...
magneto Posted December 8, 2013 Author Share Posted December 8, 2013 Thanks, it returns True in both cases. There is also hou.isUIAvailable() which I am using, but I think 456.py is executed after the UI is already loaded. Quote Link to comment Share on other sites More sharing options...
graham Posted December 8, 2013 Share Posted December 8, 2013 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. 1 Quote Link to comment Share on other sites More sharing options...
magneto Posted December 9, 2013 Author Share Posted December 9, 2013 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.