Hi there;
I'd like to craft a python script in TOPS that does one thing if I'm in an interactive Houdini session (which is to say: working in the UI), and a different thing if the file is being controlled via Hython on the command line (so, no UI). Is this possible, and if so, what is the Python syntax for detecting this?
Thanks!
Detecting session type
1020 4 1- dhemberg
- Member
- 207 posts
- Joined: 11月 2015
- Offline
- tamte
- Member
- 8449 posts
- Joined: 7月 2007
- Offline
- dhemberg
- Member
- 207 posts
- Joined: 11月 2015
- Offline
- dhemberg
- Member
- 207 posts
- Joined: 11月 2015
- Offline
Hm, this command seems to actually perform in an unexpected way in TOPS. If I have my scene file open (because I am actively developing in it), but I also open a command prompt session to try testing my setup via hython, I seem to enter some sort of Heisenberg Uncertainty state, where Houdini sees the UI as both open and not open, and I end up getting two scene files saved to two different locations using this Python code in a Python TOP:
This seems to be agitated by a ROP Geometry Output node; upstream of this node, I do not get this weird file duplication problem, but downstream of the node, I do. I can't find any options on the ROP Geometry Output node itself that indicate why it might be, um, forking itself or whatever mysterious behavior it's doing.
I can close my Houdini UI session and things work as expected, but having to constantly open and close Houdini to be able to test my setup is a hassle.
import hou
print ("Saving scene...")
# If we are in an interactive session, just save over the current file.
if hou.isUIAvailable():
hou.hipFile.save()
else:
hip_out = hou.contextOption("hip_file_archive")
hou.hipFile.save(hip_out)
This seems to be agitated by a ROP Geometry Output node; upstream of this node, I do not get this weird file duplication problem, but downstream of the node, I do. I can't find any options on the ROP Geometry Output node itself that indicate why it might be, um, forking itself or whatever mysterious behavior it's doing.
I can close my Houdini UI session and things work as expected, but having to constantly open and close Houdini to be able to test my setup is a hassle.
- johnmather
- スタッフ
- 459 posts
- Joined: 8月 2019
- Offline
-
- Quick Links