ah-fx Posted January 12, 2018 Share Posted January 12, 2018 Hey everyone, Is it possible to use python or hscript to tell me which context houdini is running in. For example, mantra, hython, or interactive / native houdini? Adam Quote Link to comment Share on other sites More sharing options...
symek Posted January 13, 2018 Share Posted January 13, 2018 4 hours ago, ah-fx said: Hey everyone, Is it possible to use python or hscript to tell me which context houdini is running in. For example, mantra, hython, or interactive / native houdini? Adam Houdini and hython/hbatch/engine is simple: hou.isUIAvailable() // spots the difference For python in Mantra filtering, check if you can import mantra module, and handle exception properly is_this_mantra_filter = False try: import mantra is_this_mantra_filter = True except: pass For python running inside HDA instanced by Mantra afaik it is less obvious. I can deduce it from a details like content of sys.argv. From what I see in Mantra case it's empty: import sys if not sys.argv[0]: # this seems to be Engine running inside Mantra pass highly unreliable. hth, skk. Quote Link to comment Share on other sites More sharing options...
ah-fx Posted January 16, 2018 Author Share Posted January 16, 2018 On 1/12/2018 at 7:45 PM, symek said: Houdini and hython/hbatch/engine is simple: hou.isUIAvailable() // spots the difference For python in Mantra filtering, check if you can import mantra module, and handle exception properly is_this_mantra_filter = False try: import mantra is_this_mantra_filter = True except: pass For python running inside HDA instanced by Mantra afaik it is less obvious. I can deduce it from a details like content of sys.argv. From what I see in Mantra case it's empty: import sys if not sys.argv[0]: # this seems to be Engine running inside Mantra pass highly unreliable. hth, skk. This is perfect, thanks symek 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.