Python - Get current working 'HIP' directory

   6929   2   0
User Avatar
Member
2162 posts
Joined: Sept. 2015
Offline
Anyone know how to get the current working diretory of the scene file returned using python?

I can use hou.hipfile.path() or hou.hipfile.name() (both return the same result),
but then I have to parse what's returned to remove *.hip file referred when I just want the directory up to but not including the hip file name.

I can use hou.houdiniPath() and index to the HIP directory that gets 'Listed', but if I later add another location/s to HOUDINI_PATH later and forget about this indexing, the code gets broken.

So at the moment it seems the only way is to parse and truncate what I get with hou.hipfile.path() or .name(),
which is fine and not really an issue - just wondering if there is a simpler method.
Edited by BabaJ - April 9, 2022 20:22:22
User Avatar
Member
9376 posts
Joined: July 2007
Offline
you can for example do:
hou.text.expandString("$HIP")

but also this wouldnt be the end of the world especially if you are planning to deal with paths and use os module anyway:
import os
os.path.dirname(hou.hipFile.path())
Edited by tamte - April 9, 2022 21:28:54
Tomas Slancik
CG Supervisor
Framestore, NY
User Avatar
Member
2162 posts
Joined: Sept. 2015
Offline
Thanks Tamte...perfect.
  • Quick Links